WIP: build(tools): every build tool made from pinned sources and uploaded by the release, llvm in place of emsdk, offline builders #2295
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2295
Loadingβ¦
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:build/tools-cleanup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The builder now owns its build tools. Three installers (the Windows setup in C,
builder/linux/linux_tools.py, andthe Launcher's own) and three environment builders had drifted apart. Now
nx2/make_game.py's first stage,tools,finds or installs tools.lock's tools on both systems with one Python implementation,
scripts/tools_store.py, and setstheir variables itself. Nothing else installs them, so the Launcher, RecompLauncher and
--cliget the same tools andthe same progress. On top of that, each tool is made from pinned sources and uploaded by the release.
Three of the Windows builder's build tools in
tools.lockwere still Hookshot v2.1.0's archives, and nobody could makethem again:
python(3.14.7, numpy 2.5.3 whererequirements.txtpins 2.5.4),cpm(an MSVC build of FFmpeg that neededhost/mingw_msvc_shims.c) andthird-party(a stalea64emit.dll, stampa0c19728against the sources'f7a5a193,so every player's PC built it again anyway; a 56 MB
lld-link.exethe llvm-mingw build never uses; zbic; the SDL DLLs).The Linux compiler was called
emsdkalthough it is a plain LLVM 23.1.5. Developers'mise installpulled in tools onlyCircleCI work or the website needs.
This PR:
Every tool is made from pinned sources and releases.
scripts/windows/deps.sh(scripts/linux/docker.sh windows-tools) makes Windows'python(python-build-standalone 3.12.16, the same as the AppImage's, withrequirements.txt's wheels),cpm(the Linux cpm's headers, dav1d, and FFmpeg 9.0.2 cross-built with llvm-mingw:lib*.a, VP8/VP9,w32threads) andsdl(libsdl's SDL3 3.4.20 and sdl2-compat 2.32.74 DLLs, the versionsthird_party/sdl2/VERSION.txtnames).third-partyis gone: a64emit, zbic and lld-link are already built fromthird_partyon first use. Windows tools go from 120 MB to 67 MB zipped, plus llvm-mingw.Each archive comes out the same twice (Windows' three built twice, llvm built from
deps.shand repacked: sameSHA-256 each time).
tools.py packwas already deterministic; nasm now runs with--reproduciblefor FFmpeg too.The release uploads them, nobody's token. A pull request writes the line (
tools.py add ... --no-upload). Therelease's version job lists lines whose copy the store lacks (
tools.py missing);tools-makemakes them again inUbuntu 22.04 and
tools-publish(deploy runner) checks each is the archive its line names (tools.py publish) anduploads it as the BeanTools account (a team with Packages: Write alone), whose
write:packagetoken is thesealed secret
PACKAGES_TOKEN_SEALED: only the deploy runner'sseal.keyopens it, like the release key. Thebuilders wait for both.
tools.py assemble(which built on top of Hookshot's archives) isremoved. The sysroot is the build system's files of the day, so a new one is still uploaded by hand.
emsdkisllvm(usr/lib/longshot/llvm, an LLVM release's layoutbin/), named byLONGSHOT_LLVM(
third_party/a64-kit/tools/toolchain.pyllvm_bin).EMSDKstill works for an emsdk checkout, and an older LongshotLauncher, which sets
EMSDK=<lib>/emsdk, still builds a new version: the tools stage setsLONGSHOT_LLVMover it.dev.py basebuilds an older revision with that revision's owntools.lock(EMSDK, its SDL DLLs). Each Linux playerdownloads the 141 MB compiler once more after updating.
The tools stage (
scripts/tools_store.py). A tool comes from the first of:<tools>/.tools/, or placed there by an older Launcherwhose
toolchain.jsonnames it;<store>/<sha256>/, atLONGSHOT_TOOLS_STORE, else the builder's home;It prints
@@stage toolsand@@progress, orprogresslines with--prepare.make_game.py --tools-onlyruns onlythis stage, and
--stampsprints the compiler and translator stamps the Launcher keys shader caches by.tools_store.py gccleans the store, andbuilder.jsonmarks a builder that owns its tools.The rest gets smaller.
builder/setup/setup.cno longer downloads, unpacks or reuses parts: it copies and publishes the builder andstarts it. WinHTTP and bcrypt are gone, and the
--winecheck now runs the builder's--cli --stamps.AppRun --clihands straight tomake_game.py, andbuilder/linux/linux_tools.pyis deleted.Runner.csand AppRun take the PC's own tool variables out, so a player'sRX_CPMorLONGSHOT_MINGWnever standsin for the builder's tools.
dev.pyuses the same store (tools-store/in the development folder, shared by every checkout).LONGSHOT_SDL_DIR.The Windows zip carries its Python at
LongshotBuilder\tools\python, pinned inbuilder/windows/python.lock, soit is no longer a
tools.lockline. An older Launcher never adds a second copy.Offline builders. Each release also ships
LongshotBuilder-<v>-windows-x64-offline.zipandLongshot-<v>-offline-x86_64.AppImage, with every tool unpacked at its dest and stamped. The tools stage takes themas they are, so nothing is downloaded on the player's PC. The Launcher side (installing a builder whose tools it
owns, and importing an offline one) is a LongshotLauncher pull request, to follow.
mise: conftest and circleci-cli are opt in (
mise.circleci.toml,MISE_ENV=circleci mise install), as only achange to
.circleci/needs them. Node moves towebsite/mise.toml, at 22.23.4: the old pin, 22.12.0, was belowwebsite/package.json'sengines(>=22.23.4).Read first:
scripts/tools_store.py,nx2/make_game.py(build_tools,print_stamps),scripts/windows/deps.sh,.forgejo/workflows/release.yml(tools-make,tools-publish),scripts/tools.py(missing,publish),third_party/a64-kit/tools/toolchain.pyllvm_bin,builder/setup/setup.c(
work),scripts/builder_package.py(make_zip),nx2/build.pyffmpeg_windows_libs.Testing
Tested: not in the game yet (opened with
--forceat the maintainer's request). On this PC (CachyOS, Linux):scripts/tools_store.py env --installinto an empty store installed all five Linux tools in 5 s; a second rundownloaded nothing.
make_game.py --tools-only,--prepare --tools-onlyand--stampsall work, anddev.py envuses the shared store.--tools-onlywith an empty store downloadednothing.
setup.ccompiles with llvm-mingw and no warnings. Also:scripts/linux/docker.sh windows-toolstwice andONLY=llvm scripts/linux/docker.sh tools, each archive the sameSHA-256 every time; the archives' contents checked (numpy 2.5.4, no Tk, FFmpeg's
lib*.awith_beginthreadex, the twoSDL DLLs); the workflows parse. No checks run on this PC (the maintainer's rule): left to CI.
Still to test:
scripts/linux/docker.sh), build and play with the offlineone with the network off, expecting no download and the game as on main (by hand)
VP9, dav1d AV1) and controllers to work (SDL) (@Beanstalk, once the archives are in the store)
each part and the build to finish (by hand)
tools-makeandtools-publishand uploads the four archives asBeanTools (set up: the account, its team and
PACKAGES_TOKEN_SEALED, checked to open on the server)Measurements
Nothing to measure in the game: the same LLVM, FFmpeg version and SDL DLLs, built from the same pins. Sizes instead:
Windows' tools without llvm-mingw 120.1 MB β 67.2 MB zipped (python 56.0 β 55.7, cpm 19.8 β 10.2, third-party 26.6 β
sdl 1.3); llvm 141.5 MB, as emsdk. The offline files add about the tools' size to each release.
Risks
tools-publish,and no builder is built that night (the release run's log says why). The setup is done (releases.md, One-time setup).
there. Revert is enough.
llvmreplacesemsdk). An older launcher keeps working.third_party/a64-kit/tools/toolchain.pychanged by four lines:LONGSHOT_LLVM/binwhen it is set, else emsdk'supstream/binas before. Recorded in itsPROVENANCE.md, tree hash updated.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (left to CI)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.(
third_party/a64-kit/tools/toolchain.py's LLVM lookup, recorded in its PROVENANCE.md: accepted by the maintainer)When it applies
tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.π€ Generated with Claude Code
Built on this PC (CachyOS) with this head, in scripts/linux/docker.sh: Longshot-dev-x86_64.AppImage (104 MB) and Longshot-dev-offline-x86_64.AppImage (243 MB, every linux-x64 tool at its dest inside). Not yet played: the game run with the offline one, network off, is next (Still to test).
Possibly related, for context:
The Launcher's side: MagicBeanDev/LongshotLauncher#256 (LONGSHOT_LLVM for an llvm version, EMSDK for an older one; install from an offline builder, checked against the release's signed SHA256SUMS).
Pushed the refactor: the build owns its tools (make_game.py's tools stage, scripts/tools_store.py), the setup and AppRun install none, linux_tools.py is gone, the Windows zip carries its Python (builder/windows/python.lock), offline builders carry their tools at their dests. Checked on this PC as Testing says; not yet in the game.
The Launcher's side is now MagicBeanDev/LongshotLauncher#257 (replacing #256 there): it installs only a builder that owns its tools, runs make_game.py --tools-only with its store, keys shader caches by --stamps, and imports offline builders. Also pushed here: an older Launcher's tools are found by its record (its dest and folder name, as Core/ToolsLock.cs writes them), so a new release under an old Launcher downloads nothing again.
@review
Recommendation: Request changes. The offline Windows builder can ignore its carried tools when the same version was installed previously, and development builds of older revisions lose tools they expect. The changed build and release paths also still need the stated platform runs.
The change centralizes tool installation, rebuilds Windows dependencies from pinned sources, and adds offline builders. It reduces the stated Windows tool archive size from 120.1 MB to 67.2 MB, but introduces compatibility problems for existing installations and older development revisions.
Blocking (3): must change before merging.
builder/setup/setup.c:363: The offline zip reuses an existing installation of the same version without copying its carried tools. When: A player first starts the online zip, then takes the offline zip for that version to the same PC with an empty tool store and no network. The existing marker and healthy executable skip the copy, so the builder starts the online installation and attempts downloads instead of using the offline zip. Do: Detect and install or merge the offline package's stamped tools when the existing version lacks them, and test online-then-offline installation of the same version.scripts/devtools/build.py:350: Building a base from an older Windows revision no longer puts SDL's DLLs where that revision reads them. (more on the line) Do: Stage the DLLs into older worktrees when their build code does not support LONGSHOT_SDL_DIR, and cover a base built from a revision before this change.scripts/devtools/build.py:185: The environment supplied to an older Linux base no longer identifies its compiler to that revision. (more on the line) Do: Provide an EMSDK-compatible layout or other compatibility environment when building revisions whose toolchain only understands EMSDK, and test that path against the base revision.Should fix (1): not blocking, but worth doing before merging.
scripts/tools_store.py:208: Applying the installed Windows tools sets LONGSHOT_MINGW even when LONGSHOT_MSVC=1 requests the Visual Studio route. (more on the line) Do: Honor LONGSHOT_MSVC when applying the compiler environment, and add a test that checks the selected toolchain.Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
.forgejo/workflows/release.yml:267: The new release path has not demonstrated that its integration token can publish the missing archives. (more on the line) Do: Exercise a release-equivalent missing-tool upload with the configured Authorized Integration and verify both builder jobs proceed.@fixcan do L1, L2, L3 and L4.Checks: Failing on this head, which is behind its base, where it passes:
Guide screenshots / Guide images and local UI source review (pull_request).@rebase(or@fix) brings it up to date and runs it again; not held against it.More: does it help, other systems, switches, what was read
Does it help: Unproven: the author reports archive sizes and successful tool-stage and packaging checks, but neither platform has completed a game build and play test with these tools. The release upload integration is also untested.
Other systems: Windows setup, older revisions built through dev.py, Linux AppImage builds, the Launcher, FFmpeg movie decoding, SDL controllers, and release publishing are affected. The supplied runs do not establish end-to-end behavior on Windows or a Linux offline game build.
Switches: LONGSHOT_LLVM selects an LLVM release directory; LONGSHOT_TOOLS_STORE selects the shared store; --tools-only runs tool preparation; --stamps prints cache stamps; OFFLINE defaults to 1 when producing AppImages. LONGSHOT_MSVC=1 is still documented as selecting MSVC, but the new tool stage overrides that selection in installed Windows builders.
Reviewed:
7741e4930dagainst753fb5af68: Read the repository instructions, contribution rules, PR template and standards; commit history; tools_store.py, tools.py, AppRun, Runner.cs, Windows dependency script, toolchain.py, and relevant setup, packaging, release and build paths. Skimmed the remaining changed diffs, tests, documentation and workflow files; did not read every changed code file in full.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, tests or project scripts were run. The author reports Linux tool-stage and AppImage packaging checks, but no completed game run.
Overlaps and merge order: LongshotLauncher#257 is the stated companion for builder-owned tools and offline imports; its merge order and compatibility need maintainer coordination.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -130,0 +264,4 @@run: |[[ -n $AUDIENCE ]] || { echo "::error::no PACKAGES_AUDIENCE variable: docs/dev/reference/releases.md, One-time setup"; exit 1; }RELEASE_TOKEN=$(curl -fsS --retry 3 -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=$AUDIENCE" | python3 -c 'import json, sys; print(json.load(sys.stdin)["value"])')L7 (should fix): The new release path has not demonstrated that its integration token can publish the missing archives.
When: When a required archive is absent, both builder jobs wait for tools-publish; a rejected token or registry upload prevents the release from producing either builder.
Do: Exercise a release-equivalent missing-tool upload with the configured Authorized Integration and verify both builder jobs proceed.
@ -248,0 +182,4 @@found, error = tools_store.ensure(True, ROOT, env, system(), tools_store.text_say())if error:die(error)py_dir = NoneL3 (blocking): The environment supplied to an older Linux base no longer identifies its compiler to that revision.
When: dev.py base builds the merge base in a clean worktree, but supplies LONGSHOT_LLVM. The base's toolchain.py only reads EMSDK, so it falls back to a host compiler or fails to find clang; a host compiler can also fail to read the shipped LLVM profile.
Do: Provide an EMSDK-compatible layout or other compatibility environment when building revisions whose toolchain only understands EMSDK, and test that path against the base revision.
@ -404,8 +348,6 @@ def cmd_base(a):else:out(["git", "worktree", "add", "--detach", src, commit])try:L2 (blocking): Building a base from an older Windows revision no longer puts SDL's DLLs where that revision reads them.
When: dev.py base creates a clean worktree at the merge base. That revision's nx2/build.py only copies SDL2.dll and SDL3.dll from its third_party/sdl2 directory and ignores LONGSHOT_SDL_DIR; the removed windows_prebuilt step leaves that directory without the DLLs, so the resulting game lacks controller support.
Do: Stage the DLLs into older worktrees when their build code does not support LONGSHOT_SDL_DIR, and cover a base built from a revision before this change.
@ -0,0 +205,4 @@"""ensure, then the variables set in environ for this process and what it starts. Returns the error text or None"""found, error = ensure(True, root, environ, system, say, getter)environ.update(environment({n: f for n, f in found.items() if f}, system))return errorL4 (should fix): Applying the installed Windows tools sets LONGSHOT_MINGW even when LONGSHOT_MSVC=1 requests the Visual Studio route.
When: An installed builder inherits LONGSHOT_MSVC=1. The tools stage sets LONGSHOT_MINGW before bundled_mingw checks the switch, and toolchain.mingw() then selects MinGW for compilation and linking.
Do: Honor LONGSHOT_MSVC when applying the compiler environment, and add a test that checks the selected toolchain.
c8f49b8d97a44378da56Thanks. Fixed in
a44378da, on current main:builder/setup/setup.c: an installed version is copied again when it lacks a tool the zip carries (carries_all: eachtools\.tools\<name>stamp of the zip, compared with the installed one). An offline zip over the same version's online install now takes its carried tools.scripts/devtools/build.py:dev.py basebuilds an older revision with that revision's owntools.lock(build_tools(tree)), as it reads them. On Linux itsemsdkgoes in asEMSDK. On Windows itsthird-partySDL DLLs go into itsthird_party/sdl2, as the oldwindows_prebuiltdid, and it uses its own Python. Every older archive is still in the store, which is never pruned.scripts/tools_store.pyenvironment: withLONGSHOT_MSVC=1, llvm-mingw'sLONGSHOT_MINGWis left out, so the Visual Studio route stays.tools-publishwould have got it. The upload is now the BeanTools account'swrite:packagetoken, sealed asPACKAGES_TOKEN_SEALED, opened only on the deploy runner like the release key. The account, its team (Packages: Write alone) and the secret are set up; the secret opens on the server. The first nightly after merge is its first real upload.Checks for L1 to L4 are in
tests/test_offline_builder.pyandtests/test_dev_build.py.HumanBean referenced this pull request2026-11-23 06:43:17 +00:00
Superseded by #2286: the Rust builder now owns its tools (
longshot-builder dev toolsis tools.lock's one implementation, tools.py is gone) and installs them itself, which is everything this PR set out to do. Closing in its favour.Pull request closed