Skip to content

build: source rayforce from upstream at pinned SHA#8

Merged
singaraiona merged 2 commits into
mainfrom
feat/rayforce-upstream
May 1, 2026
Merged

build: source rayforce from upstream at pinned SHA#8
singaraiona merged 2 commits into
mainfrom
feat/rayforce-upstream

Conversation

@singaraiona
Copy link
Copy Markdown
Contributor

Summary

  • Replace the drifted (incomplete — no Makefile) vendored rayforce/ copy with an auto-clone flow pinned to a SHA in .rayforce-version.
  • All make lib work now happens in OUT_DIR/rayforce-build/; source tree is never modified — required for cargo package verification to pass.
  • Cargo.toml include whitelist ships vendor/rayforce/{Makefile,LICENSE,src/**,include/**} in the published .crate so end users cargo install raysense offline. CI populates vendor/ explicitly before cargo package (publish.yml).

Resolution modes (build.rs)

Mode Triggered when What happens
External RAYFORCE_DIR set Link the externally-built librayforce.a (dev mode, unchanged)
Bundled vendor/rayforce/Makefile exists Copy source to OUT_DIR, build there
Auto-clone Neither Shallow git clone upstream at the pinned SHA into OUT_DIR, build there

CFLAGS override

Upstream RELEASE_CFLAGS includes -march=native and -Werror. Both are poison for distribution: -march=native bakes the build host's CPU into the .a (crashes on older CPUs of the same arch), -Werror breaks downstream builds on new compiler warnings. build.rs overrides RELEASE_CFLAGS to a portable baseline.

Verified locally

  • cargo fmt --check clean
  • cargo test — 123/123 green (auto-clone path)
  • cargo test — 123/123 green (bundled-vendor path simulating CI publish)
  • cargo package — 167 files, 838 KiB compressed (well under the crates.io 10 MiB ceiling). Verification build passes.
  • Source tree stays pristine across all three modes (no .o, no librayforce.a, no vendor/ pollution)

Test plan for reviewer

  • Fresh clone, cargo build — confirm auto-clone runs and produces a working binary
  • Set RAYFORCE_DIR=/abs/path/to/rayforce (with a pre-built librayforce.a) — confirm dev path links external lib
  • CI publish dry-run: gh workflow run publish.yml -f dry_run=true — confirm new "Vendor rayforce at pinned SHA" step runs and cargo package --dry-run succeeds
  • Bump pin: edit .rayforce-version, cargo clean -p raysense && cargo build — confirm rebuild picks up the new SHA

Out of scope / follow-ups

  • Cross-platform: upstream Makefile is Linux + macOS only. Windows build path is not in this PR.
  • README's "Building from source" section now says "no external setup, no submodules" — that's stale and should be updated in a follow-up (the cargo install path still works; just the docs lag).

Anton added 2 commits May 1, 2026 16:59
The vendored rayforce/ copy had drifted from upstream and shipped
incomplete (no Makefile). Replace it with an auto-clone flow that
sources rayforce from the pinned SHA in `.rayforce-version`.

Resolution order in build.rs:

  1. RAYFORCE_DIR set      -> link external librayforce.a (dev mode,
                              unchanged)
  2. vendor/rayforce/      -> source bundled inside the published
       Makefile exists       .crate tarball (or populated by CI before
                              `cargo package`); copy to OUT_DIR, build
  3. neither               -> shallow clone upstream at the pinned SHA
                              into OUT_DIR, build there

All `make lib` work happens in `OUT_DIR/rayforce-build/`. The source
tree is never modified — required for `cargo package` to verify clean.

CFLAGS override: drop `-march=native` and `-Werror` from the upstream
RELEASE_CFLAGS so the produced .a runs on any CPU of the target arch
and downstream builds don't break on new compiler warnings.

Cargo.toml `include` whitelists vendor/rayforce/{Makefile,LICENSE,
src/**,include/**} so the published .crate ships the source needed
for offline downstream builds. .gitignore drops vendor/ from tracking;
CI populates it explicitly before `cargo package` (publish.yml).

Pin format: single-line hex SHA in .rayforce-version. Bump by editing
the file and running `cargo clean -p raysense && cargo build`.

Verified locally:
  - cargo test: 123/123 green
  - cargo fmt --check: clean
  - cargo package: 167 files, 838 KiB compressed (under crates.io 10
    MiB limit). Verification build passes — source dir unmodified.
@singaraiona singaraiona merged commit f529b52 into main May 1, 2026
1 check passed
@singaraiona singaraiona deleted the feat/rayforce-upstream branch May 1, 2026 15:45
singaraiona added a commit that referenced this pull request May 1, 2026
* build: source rayforce from upstream at pinned SHA

The vendored rayforce/ copy had drifted from upstream and shipped
incomplete (no Makefile). Replace it with an auto-clone flow that
sources rayforce from the pinned SHA in `.rayforce-version`.

Resolution order in build.rs:

  1. RAYFORCE_DIR set      -> link external librayforce.a (dev mode,
                              unchanged)
  2. vendor/rayforce/      -> source bundled inside the published
       Makefile exists       .crate tarball (or populated by CI before
                              `cargo package`); copy to OUT_DIR, build
  3. neither               -> shallow clone upstream at the pinned SHA
                              into OUT_DIR, build there

All `make lib` work happens in `OUT_DIR/rayforce-build/`. The source
tree is never modified — required for `cargo package` to verify clean.

CFLAGS override: drop `-march=native` and `-Werror` from the upstream
RELEASE_CFLAGS so the produced .a runs on any CPU of the target arch
and downstream builds don't break on new compiler warnings.

Cargo.toml `include` whitelists vendor/rayforce/{Makefile,LICENSE,
src/**,include/**} so the published .crate ships the source needed
for offline downstream builds. .gitignore drops vendor/ from tracking;
CI populates it explicitly before `cargo package` (publish.yml).

Pin format: single-line hex SHA in .rayforce-version. Bump by editing
the file and running `cargo clean -p raysense && cargo build`.

Verified locally:
  - cargo test: 123/123 green
  - cargo fmt --check: clean
  - cargo package: 167 files, 838 KiB compressed (under crates.io 10
    MiB limit). Verification build passes — source dir unmodified.

* fmt: collapse read_pin one-liner per rustfmt

---------

Co-authored-by: Anton <anton.kundenko@gmail.com>
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