build: Honor CARGO_TARGET_DIR in client build scripts#679
Open
celikgo wants to merge 2 commits into
Open
Conversation
The Java JNI, Node, and Swift build steps assumed the Cargo target
directory was always `target` (relative to the workspace root), so a
build with a user-defined target directory failed to locate the compiled
libraries.
- java/build_jni.sh: read the desktop/server artifacts from
`${CARGO_TARGET_DIR:-target}` instead of a hardcoded `target`. (The
Android path already uses `--artifact-dir` and is unaffected.)
- node/build_node_bridge.py: default `--cargo-build-dir` to
`CARGO_TARGET_DIR` when set. Previously the script forced
CARGO_BUILD_TARGET_DIR=../target, which Cargo's CARGO_TARGET_DIR
overrides, so the build landed somewhere the script never looked.
- swift/Package.swift: derive the link path from CARGO_TARGET_DIR.
This matches the convention swift/build_ffi.sh already used
(`${CARGO_TARGET_DIR:-target}`).
Fixes signalapp#655
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Previously copy_built_library silently did nothing when no matching library was found in the build directory. A misconfigured target dir would leave the native library out of the resources dir, surfacing later as a confusing "jar not found"/zip error in the Gradle packaging step rather than at the actual point of failure. Fail loudly with the searched directory and library name instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
Friendly nudge on this one — it's a small, self-contained build fix for #655 (honoring |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #655.
The Java JNI, Node, and Swift build steps assumed the Cargo target directory was always
target(relative to the workspace root). When a user configures a different target directory viaCARGO_TARGET_DIR, Cargo builds the libraries there, but these scripts kept looking intarget/and failed to find them.swift/build_ffi.shalready honoredCARGO_TARGET_DIR(${CARGO_TARGET_DIR:-target}); this change makes the rest of the client build scripts consistent with that convention.Changes
java/build_jni.sh— read the desktop/server artifacts from${CARGO_TARGET_DIR:-target}instead of a hardcodedtarget. This is the exact line the issue points at. (The Android path already usescargo build --artifact-dir, so it's unaffected.)node/build_node_bridge.py— default--cargo-build-dirtoCARGO_TARGET_DIRwhen it's set. Previously the script unconditionally setCARGO_BUILD_TARGET_DIR=../target; since Cargo'sCARGO_TARGET_DIRenv var takes precedence overCARGO_BUILD_TARGET_DIR, a user withCARGO_TARGET_DIRset had Cargo build into their directory while the script looked in../targetand found nothing.swift/Package.swift— derive the link path (-L) fromCARGO_TARGET_DIR, falling back to../target.bin/build_helpers.sh— makecopy_built_libraryfail with a clear error when no built library is found, instead of silently doing nothing. This is what made the original report confusing: a wrong target dir left the native library out of the resources dir, so the failure surfaced later as ajar not found/zip error in the Gradle packaging step rather than at the actual point of breakage. It now reports the directory searched and the library name, so any future path mismatch (e.g. a target dir set only via.cargo/config.toml, see below) fails loudly and actionably.Notes / scope
CARGO_TARGET_DIRenvironment variable specifically (the documented, standard way to relocate the target dir, and whatbuild_ffi.shalready keyed off). A target dir set only via.cargo/config.toml'sbuild.target-diris out of scope here; resolving that reliably would mean shelling out tocargo metadata. With thecopy_built_librarychange above, that case now fails with a clear error rather than a silent miss.bash -n java/build_jni.sh,bash -n bin/build_helpers.sh,python3 -m py_compile node/build_node_bridge.py, andswift package describeall pass.🤖 Generated with Claude Code