Repository navigation
Expand file tree
/
Copy pathxmake.lua
More file actions
219 lines (202 loc) · 8.31 KB
/
Copy pathxmake.lua
File metadata and controls
219 lines (202 loc) · 8.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
set_project("ice")
set_version("0.1.0")
set_languages("c++20")
add_rules("mode.debug", "mode.release")
add_requires("spdlog", "nlohmann_json", "clipper2")
-- Bake a small build fingerprint into icelib so MCP clients can detect a
-- long-lived server that was started before the last install.
--
-- The fingerprint must be stable across no-op xmake invocations. Deriving the
-- timestamp from the clock here makes every `xmake run/build` look like a
-- configuration change, invalidating all cached objects. Use the newest
-- first-party source timestamp instead, and fall back to the clock only when
-- no source files are available.
-- Set ICE_BUILD_COMMIT/ICE_BUILD_TIME explicitly for reproducible packaging.
local build_commit = os.getenv("ICE_BUILD_COMMIT") or "unknown"
local build_time = os.getenv("ICE_BUILD_TIME")
if not build_time then
local latest_mtime = 0
local fingerprint_files = {
"xmake.lua",
"src/**.cpp",
"src/**.hpp",
"include/**.hpp",
"tests/**.cpp",
}
for _, pattern in ipairs(fingerprint_files) do
for _, file in ipairs(os.files(pattern)) do
local mtime = os.mtime(file)
if mtime and mtime > latest_mtime then
latest_mtime = mtime
end
end
end
if latest_mtime == 0 then
latest_mtime = os.time()
end
build_time = os.date("!%Y-%m-%dT%H:%M:%SZ", latest_mtime)
end
local build_type = is_mode("release") and "release" or "debug"
-- Agent Client Protocol support. The normal build uses the bundled
-- third_party/agentsdk-cpp submodule. AGENTSDK_CPP_DIR and a sibling checkout
-- remain supported for downstream packaging.
local agentsdk_dir = os.getenv("AGENTSDK_CPP_DIR")
if not agentsdk_dir or not os.isdir(agentsdk_dir) then
local bundled = path.join(os.projectdir(), "third_party", "agentsdk-cpp")
if os.isdir(bundled) then
agentsdk_dir = bundled
end
end
if not agentsdk_dir or not os.isdir(agentsdk_dir) then
local sibling = path.join(os.projectdir(), "..", "agentsdk-cpp")
if os.isdir(sibling) then
agentsdk_dir = sibling
end
end
local has_agentsdk = agentsdk_dir and os.isdir(path.join(agentsdk_dir, "src", "agentsdk"))
if has_agentsdk then
agentsdk_dir = path.absolute(agentsdk_dir)
add_requires("simdjson", "libcurl")
else
print("warning: agentsdk-cpp is missing; run `git submodule update --init --recursive` to enable the Agent tab")
end
-- First-party warnings. Third-party headers are included via system paths, so
-- -Werror is intentionally not enabled.
local first_party_warnings = {"-Wall", "-Wextra", "-Wpedantic", "-Wno-missing-field-initializers"}
target("icelib")
set_kind("static")
add_files("src/icelib/*.cpp")
add_includedirs("include", {public = true})
add_defines('ICE_SOURCE_DIR="' .. os.projectdir() .. '"',
'ICE_BUILD_COMMIT="' .. build_commit .. '"',
'ICE_BUILD_TIME="' .. build_time .. '"',
'ICE_BUILD_TYPE="' .. build_type .. '"',
{public = true})
add_cxxflags("-fPIC", {public = true})
add_cxxflags(first_party_warnings)
add_packages("spdlog", "nlohmann_json", "clipper2")
-- System-provided dependencies without xmake packages (Debian/Ubuntu layout).
-- TODO: replace hardcoded /usr paths with packaged deps or pkg-config checks.
add_includedirs("/usr/include/toml++", "/usr/include")
add_links("crypto")
add_includedirs("/usr/include/ngspice")
add_links("ngspice")
if has_agentsdk then
target("agentsdk")
set_kind("shared")
set_languages("c++20")
add_files(path.join(agentsdk_dir, "src", "agentsdk", "**.cpp"))
add_includedirs(path.join(agentsdk_dir, "src"), {public = true})
add_packages("spdlog", "libcurl", "simdjson", {public = true})
add_cxxflags("-fPIC")
if is_plat("linux") then
-- The package metadata provides headers here, but does not add
-- the libraries to the link line when the system installations
-- are selected. Keep the SDK shared object self-contained.
add_syslinks("curl", "simdjson", "pthread")
elseif is_plat("windows") then
add_syslinks("ws2_32", "wsock32")
end
end
target("ice")
set_kind("binary")
add_files("src/ice/*.cpp")
add_deps("icelib")
add_defines('ICE_SOURCE_DIR="' .. os.projectdir() .. '"')
add_includedirs("include", "/usr/include/qt6", "/usr/include/qt6/QtCore",
"/usr/include/qt6/QtGui", "/usr/include/qt6/QtWidgets",
"/usr/include/qt6/QtSvg", "/usr/include/qt6/QtSvgWidgets")
add_syslinks("Qt6Widgets", "Qt6Gui", "Qt6Core", "Qt6Svg", "Qt6SvgWidgets")
add_installfiles("assets/icons/tabs/*.svg", {prefixdir = "share/ice/icons/tabs"})
add_cxxflags("-fPIC", {force = true})
add_cxxflags(first_party_warnings)
add_ldflags("-no-pie", {force = true})
if has_agentsdk then
add_deps("agentsdk")
add_defines("ICE_HAVE_AGENTSDK=1")
if is_plat("linux") then
-- app_widgets.cpp uses simdjson directly, and the SDK's curl
-- symbols must also be resolvable when linking the executable.
add_syslinks("curl", "simdjson", "pthread")
add_rpathdirs("$ORIGIN/../lib")
elseif is_plat("windows") then
add_syslinks("ws2_32", "wsock32")
end
end
target("ice-cli")
set_kind("binary")
add_files("src/ice-cli/main.cpp")
add_deps("icelib")
add_cxxflags(first_party_warnings)
add_includedirs("include")
add_defines('ICE_SOURCE_DIR="' .. os.projectdir() .. '"')
add_packages("spdlog", "nlohmann_json")
target("ice-pkg")
set_kind("binary")
add_files("src/ice-pkg/main.cpp")
add_deps("icelib")
add_cxxflags(first_party_warnings)
add_includedirs("include")
target("ice-mcp")
set_kind("binary")
add_files("src/ice-mcp/main.cpp")
add_deps("icelib")
add_cxxflags(first_party_warnings)
add_includedirs("include")
add_defines('ICE_SOURCE_DIR="' .. os.projectdir() .. '"')
add_packages("nlohmann_json")
if has_agentsdk then
add_deps("agentsdk")
add_defines("ICE_HAVE_AGENTSDK=1")
if is_plat("linux") then
-- Keep the executable link complete when the AgentSDK package
-- exposes curl and simdjson only through its public headers.
add_syslinks("curl", "simdjson", "pthread")
add_rpathdirs("$ORIGIN/../lib")
elseif is_plat("windows") then
add_syslinks("ws2_32", "wsock32")
end
end
target("doctest")
set_kind("binary")
add_files("tests/*.cpp")
add_deps("icelib")
add_cxxflags(first_party_warnings)
add_includedirs("include")
add_defines('ICE_SOURCE_DIR="' .. os.projectdir() .. '"')
target("icepy")
set_kind("shared")
set_prefixname("")
add_files("src/icepy/module.cpp", "/usr/lib/python3.14/site-packages/nanobind/src/nb_combined.cpp")
add_deps("icelib")
add_includedirs("include", "/usr/include/python3.14",
"/usr/lib/python3.14/site-packages/nanobind/include",
"/usr/lib/python3.14/site-packages/nanobind/src")
add_links("python3.14", "dl")
add_installfiles("python/icepy_pcells.py", {prefixdir = "share/ice/python"})
add_installfiles("python/icepy_sim.py", {prefixdir = "share/ice/python"})
add_installfiles("assets/simulation/report_runner.py", {prefixdir = "share/ice/assets/simulation"})
add_installfiles("assets/layout/procedural_runner.py", {prefixdir = "share/ice/assets/layout"})
add_installfiles("assets/layout/ihp.sg13g2.json", {prefixdir = "share/ice/assets/layout"})
task("test")
on_run(function ()
os.exec("xmake build doctest")
os.exec("xmake run doctest")
end)
set_menu {usage = "Run the doctest-compatible icelib test target"}
task("format")
on_run(function ()
for _, file in ipairs(os.files("include/**.hpp|src/**.cpp|tests/**.cpp")) do
os.exec("clang-format -i " .. file)
end
end)
task("docs")
on_run(function ()
os.exec("sphinx-build -b html docs docs/_build")
end)
set_menu {usage = "Build the Sphinx documentation site"}
task("openroad-sdk")
on_run(function ()
os.exec("bash scripts/build-ice-openroad.sh")
end)
set_menu {usage = "Build the experimental C++ OpenROAD backend"}