packaging: build_cuda_windows.py takes SHAPE=<geometry> like shape_build.sh does on Linux

SHAPE=q4_lite configures -DSTRATA_GEOMETRY=q4_lite, checks that strata.exe
--geometry names the shape, keeps the symbols under strata-q4-lite-... and
packages with package_engine.py --shape, so the Windows CUDA 13 / 12 engine of
a model shape is its own component (strata-q4-lite). Without SHAPE nothing
changes.
This commit is contained in:
Niko1221 committed 2026-12-04 07:36:22 +01:00
1 parent ffa0fc8516
commit 450e9c7071
1 file changed
+19 -1
+19 -1
View File
@@ -18,6 +18,8 @@ Settings (environment, all optional):
ARCHS the architecture list instead of the variant's (semicolons, e.g. 120; the last one also gets PTX), as in build_cuda_linux.sh
BUILD_JOBS compile jobs (default 6: the CUDA compiler takes several GB of RAM per job)
COMMIT the source commit for the build id (default: git rev-parse HEAD; required in a tree without .git)
SHAPE the engine of a model shape (SHAPE=q4_lite): configures -DSTRATA_GEOMETRY=<SHAPE>, checks `strata.exe --geometry`, packages it with
package_engine.py --shape (its own component strata-q4-lite, next to the Strata engine), as tools/packaging/shape_build.sh does on Linux
"""
from __future__ import annotations
@@ -168,6 +170,14 @@ def main(argv: list[str]) -> int:
out = Path(os.environ.get("OUT") or src / ("out-engine-win-" + variant))
jobs = os.environ.get("BUILD_JOBS") or "6"
extra = (os.environ.get("STRATA_CMAKE_EXTRA") or "").split()
shape = os.environ.get("SHAPE", "") # the engine of a model shape (SHAPE=q4_lite): its own component, as tools/packaging/shape_build.sh does on Linux
if shape:
if not re.fullmatch(r"[a-z][a-z0-9_]*", shape):
fail("SHAPE=%s is not a geometry name (lower case, digits and _, like q4_lite)" % shape)
if not any(x.startswith("-DSTRATA_GEOMETRY") for x in extra): # a header named there (a file made from the model's GGUF) has its own kGeometryName, checked below
if not (ENGINE_SRC / "include" / "strata" / "core" / "geometries" / (shape + ".hpp")).is_file():
fail("no header engine/include/strata/core/geometries/%s.hpp; name the model's header with STRATA_CMAKE_EXTRA=-DSTRATA_GEOMETRY_FILE=<path>" % shape)
extra.append("-DSTRATA_GEOMETRY=" + shape)
version, commit = project_version(ENGINE_SRC), source_commit(src)
cuda = find_cuda(variant)
env = msvc_env()
@@ -179,7 +189,13 @@ def main(argv: list[str]) -> int:
targets = engine_targets(cmake, build, env)
print("engine targets: " + " ".join(targets), flush=True)
run([cmake, "--build", str(build), "-j", jobs, "--target", *targets], env)
symbols = Path(os.environ.get("SYMBOLS_DIR") or src / "symbols") / ("strata-engine-%s-windows-x86_64-cuda-%s" % (version, variant))
if shape:
named = subprocess.run([str(build / "strata.exe"), "--geometry"], capture_output=True, text=True, env=env, errors="replace").stdout.splitlines()
if (named[0].strip() if named else "") != shape:
fail("the engine built here says --geometry %r, not %r (the header's kGeometryName must be the shape's name)" % (named[0] if named else "", shape))
print("the engine is built for %s (strata.exe --geometry)" % shape, flush=True)
sym_base = ("strata-" + shape.replace("_", "-")) if shape else "strata-engine" # the same names as build_cuda_linux.sh
symbols = Path(os.environ.get("SYMBOLS_DIR") or src / "symbols") / ("%s-%s-windows-x86_64-cuda-%s" % (sym_base, version, variant))
if keep_symbols():
# the PDBs of the exes this package ships, copied out of the build folder before anything cleans it (never into the package)
run([sys.executable, str(PACKAGING / "keep_symbols.py"), "pe", "--out", str(symbols), "--pdb-dir", str(build), "--require",
@@ -208,6 +224,8 @@ def main(argv: list[str]) -> int:
*[x for a in archs for x in ("--arch", "sm_%d" % a)], "--arch", "compute_%d" % archs[-1], "--min-driver", "nvidia=" + mindriver,
"--variant", variant, "--platform", "windows-x86_64", "--build-id", "%s+cuda%s" % (commit[:12], cu),
"--include", "strata-vision.exe", "--include", "strata_kq.dll"]
if shape:
cmd += ["--shape", shape]
run(cmd, env)
finally:
shutil.rmtree(stage, ignore_errors=True)