Skip to content

Change patcher build from Meson/Ninja/virtualenv/Go to Bazel#86

Merged
afq984 merged 15 commits intomainfrom
push-orqtsxqpsotu
Mar 22, 2026
Merged

Change patcher build from Meson/Ninja/virtualenv/Go to Bazel#86
afq984 merged 15 commits intomainfrom
push-orqtsxqpsotu

Conversation

@afq984
Copy link
Copy Markdown
Owner

@afq984 afq984 commented Mar 22, 2026

No description provided.

afq984 added 13 commits March 23, 2026 05:34
…cies

Configure Bazel 8.6.0 with toolchains_chromium for hermetic C++ builds.
Port ooz C++ libraries (libooz, bunutil, libpoe, libbun) and the extract
binary to native Bazel cc_library/cc_binary targets. Use simde and
libsodium from the Bazel Central Registry. ooz is fetched as an external
dependency via git_override with a build_file overlay.

libunistring (needed by utf.cpp in bunutil and libpoe) is not yet on BCR
and is temporarily excluded.
Build a minimal subset of libunistring (u16_tolower, u16_to_u8, u8_to_u16)
from source via archive_override, with a handwritten BUILD file covering
22 .c files plus a u16_normalize stub. Public headers are generated from
.in.h templates via patch_cmds (sed substitution of @variable@ markers).
A minimal config.h replaces the full autoconf-generated one.

This completes the ooz C++ build — all targets now compile with no
excluded files and no system library dependencies.
Replace the genrule .so copy hack with a proper cc_shared_library target
for libooz. Use the @rules_cc//cc/runfiles library to locate liblibooz.so
at runtime via Rlocation(), guarded behind BAZEL_BUILD so the meson build
still works unchanged.

Add extract_bazel_wrapper.sh as a drop-in replacement for the meson-built
extract binary. It delegates to `bazel run --run_in_cwd` so that runfiles
are set up and the working directory is preserved for genbuild.py/ninja.

Clean up extract.cpp: use #else instead of fallback check
Add rules_go and gazelle to MODULE.bazel. Gazelle generates BUILD files
for all Go packages under patcher/ (cmd/dat2jsonl, cmd/poepatcher,
dat/, dat/schema, dat/types, poepatcher/).

Go test (dat/types) passes under bazel test.

Add install-bazel.sh as a drop-in replacement for install.sh that builds
Go and C++ via Bazel and places binaries where main.sh expects them.
Verified: install-bazel.sh + main.sh produces identical output.
Extract the non-hermetic game data fetch logic from genbuild.py into
fetch.py, exposed as a py_binary target. It runs poepatcher to download
game files and extract in discovery mode to resolve bundle paths.

install-bazel.sh now calls bazel run //patcher:fetch at the end.
The fetch logic (poepatcher + extract discovery) is now handled by
bazel run //patcher:fetch. genbuild.py only generates build.ninja.
The stamp file now depends on the bundle index file to detect changes.
Port the full patcher pipeline (extract → dat2jsonl → datrelease/
statparse/charversion/fingerprint) to Bazel genrules.

Game data is wired in via @gamedata repo with --override_repository.
A default empty repo is provided via local_path_override; the actual
data is supplied at build time:
  bazel build //patcher/pipeline:fingerprint \
    --override_repository=gamedata+=$PWD/patcher/Content.ggpk.d/latest

All 6 release files are identical to the ninja-produced baseline.

Also: replace asserts with proper error handling in extract.cpp,
add -DIN_LIBUNISTRING to fix inline redefinition under -O2, and
set --host_compilation_mode=dbg in .bazelrc to work around ooz UB.
Add pkg_tar target that packages all release files. Update main.sh to
build the pipeline via Bazel and extract the tarball directly into
web/nebuloch/data/, replacing the genbuild.py + ninja + release.sh flow.
fetch.sh now just downloads schema.min.json and runs bazel run //patcher:fetch.
The old install.sh (meson/go build) is removed — Bazel handles all builds.
Extract patcher_extract() and patcher_dat2jsonl() macros into defs.bzl.
The BUILD file is now ~100 lines instead of ~210, with the table list
and language iteration defined once.
…ython3

Convert datrelease, statparse, charversion, fingerprint to py_binary
targets with proper deps. Refactor datrelease.py to accept --input-dir
and --output-dir args (removes symlink hack in genrule). Add a stub
tqdm module so statparse works without the pip package.
Delete meson.build, genbuild.py, shell.nix, extract_bazel_wrapper.sh.
Remove ooz submodule and .gitmodules.
Remove #ifdef BAZEL_BUILD from extract.cpp — only the Bazel/runfiles
code path remains. Clean up .gitignore.
@afq984 afq984 force-pushed the push-orqtsxqpsotu branch from e4e021d to 1d3505e Compare March 22, 2026 22:02
afq984 added 2 commits March 23, 2026 06:05
README: document fetch.sh + main.sh + release.sh workflow.
CI: use setup-bazel action, run bazel test and the patcher pipeline.
Dockerfile: replace meson/go/ninja with Bazel via bazelisk.

Update READMEs for Bazel workflow
Add empty stub files and mark all @gamedata targets with
target_compatible_with = @platforms//:incompatible in the stub repo.
Pipeline targets are cleanly skipped without --override_repository.
Add platforms dep to MODULE.bazel.
@afq984 afq984 force-pushed the push-orqtsxqpsotu branch from 1d3505e to 8181746 Compare March 22, 2026 22:05
@afq984 afq984 merged commit 7d18abf into main Mar 22, 2026
4 checks passed
@afq984 afq984 deleted the push-orqtsxqpsotu branch March 22, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant