Skip to content

feat(ferric): add --cwd option to build - #486

Merged
kraenhansen merged 4 commits into
nextfrom
ferric-cwd
Oct 31, 2026
Merged

kraenhansen merged 4 commits into
nextfrom
ferric-cwd

Conversation

@kraenhansen

@kraenhansen kraenhansen commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Adds ferric build --cwd <path>, as agreed in #195, mirroring napi-rs' --cwd. This supersedes #205 (thanks to dougg0k for the original work), leaving out its dist output change and dependency bumps.

  • --cwd resolves against the invocation directory, so relative and absolute paths both work, and it applies to every cargo and napi-rs call, including --clean and --dts-only.
  • --output defaults to the --cwd directory. An explicit relative --output still resolves against the invocation directory.
  • Cargo is spawned with cwd rather than --manifest-path, so the crate's .cargo/config.toml and toolchain files still apply.
  • The target directory comes from cargo metadata, and the library is picked by its exact name, so workspace members and CARGO_TARGET_DIR work and a stale local target/ is ignored.
  • The installed-targets and napi feature checks run from the --cwd directory, so a crate's rust-toolchain.toml is respected.
  • cargo metadata output is validated with zod.

Test plan

  • pnpm run build, pnpm run lint, pnpm run prettier:check
  • pnpm --filter ferric-cli run test, with a CLI test that scaffolds a crate via ferric init and builds it with --cwd
  • ferric build --cwd packages/ferric-example --target aarch64-apple-ios-sim from the repo root puts the outputs in the crate directory
  • --dts-only with a relative --cwd, with an absolute --cwd plus relative --output, and with no --cwd from the crate directory
  • A missing --cwd directory gives a clear error
  • Two-member workspace, a stale local target/, and CARGO_TARGET_DIR on aarch64-apple-ios-sim
  • Toolchain check run from the --cwd directory, using a stand-in rustup
  • Android target through --cwd
  • --clean through --cwd

🤖 Generated with Claude Code

@kraenhansen kraenhansen mentioned this pull request Oct 31, 2026
2 tasks done
@kraenhansen kraenhansen added Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) labels Oct 31, 2026
kraenhansen and others added 4 commits October 31, 2026 13:20
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@kraenhansen
kraenhansen changed the base branch from main to next October 31, 2026 12:23
@kraenhansen
kraenhansen marked this pull request as ready for review October 31, 2026 12:45
@kraenhansen
kraenhansen merged commit 090adf0 into next Oct 31, 2026
16 checks passed
@kraenhansen
kraenhansen deleted the ferric-cwd branch October 31, 2026 12:48
kraenhansen added a commit that referenced this pull request Oct 31, 2026
* feat(ferric): add --cwd option to build

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(ferric): resolve target dir and toolchain from the crate

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor(ferric): validate cargo metadata with zod

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(ferric): cover --cwd, workspaces and the toolchain check

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
kraenhansen added a commit that referenced this pull request Oct 31, 2026
* feat(ferric): add --cwd option to build

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(ferric): resolve target dir and toolchain from the crate

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor(ferric): validate cargo metadata with zod

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(ferric): cover --cwd, workspaces and the toolchain check

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) Ferric 🦀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant