Skip to content

Determine default targets from CMAKE_RN_TARGETS and FERRIC_TARGETS environment variable #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 22, 2025

Conversation

kraenhansen
Copy link
Collaborator

@kraenhansen kraenhansen commented Jul 22, 2025

We're currently building for Android x86_64 while running an x86 emulator.

Merging this PR will:

  • Introduce environment variables which will be split by comma to and used as default for the --target runtime option when running the cmake-rn and ferric CLIs.
  • Add printing of the platforms and underlying targets to the "configure projects" step in the cmake-rn CLI.
  • Update CI to use this new argument.

@kraenhansen kraenhansen self-assigned this Jul 22, 2025
@kraenhansen kraenhansen added enhancement New feature or request CMake RN Our `cmake` wrapping CLI labels Jul 22, 2025
Copy link

changeset-bot bot commented Jul 22, 2025

🦋 Changeset detected

Latest commit: 9852f7e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
cmake-rn Minor
ferric-cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kraenhansen kraenhansen added Apple 🍎 Anything related to the Apple platform (iOS, macOS, Cocoapods, Xcode, XCFrameworks, etc.) Android 🤖 Anything related to the Android platform (Gradle, NDK, Android SDK) labels Jul 22, 2025
@kraenhansen kraenhansen force-pushed the kh/default-targets-from-env branch from 70624d4 to ee234b5 Compare July 22, 2025 20:34
@kraenhansen kraenhansen requested a review from Copilot July 22, 2025 21:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces environment variable-based default target configuration for both cmake-rn and ferric CLIs. The purpose is to allow users to specify default build targets via environment variables rather than requiring explicit command-line arguments each time.

  • Adds CMAKE_RN_TARGETS environment variable support for cmake-rn CLI default targets
  • Adds FERRIC_TARGETS environment variable support for ferric CLI default targets
  • Enhances CLI output to show platform and target information during project configuration

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/cmake-rn/src/cli.ts Implements CMAKE_RN_TARGETS parsing, validation, and adds target summary display
packages/ferric/src/build.ts Implements FERRIC_TARGETS parsing with validation using assertFixable
.github/workflows/check.yml Updates CI configuration to use the new environment variables
.changeset/loud-paths-eat.md Documents ferric-cli changes
.changeset/loud-dodos-kneel.md Documents cmake-rn changes


const defaultTargets = CMAKE_RN_TARGETS ? CMAKE_RN_TARGETS.split(",") : [];

for (const target of defaultTargets) {
Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The target validation logic is duplicated between cmake-rn and ferric packages. Consider extracting this validation into a shared utility function to maintain consistency and reduce code duplication.

Copilot uses AI. Check for mistakes.

Comment on lines +65 to +67
const { FERRIC_TARGETS } = process.env;

function getDefaultTargets() {
Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The environment variable extraction is placed at module level but only used within getDefaultTargets(). Consider moving this extraction inside the function to improve encapsulation and make the dependency more explicit.

Suggested change
const { FERRIC_TARGETS } = process.env;
function getDefaultTargets() {
function getDefaultTargets() {
const { FERRIC_TARGETS } = process.env;

Copilot uses AI. Check for mistakes.

@kraenhansen kraenhansen changed the title Determine default targets from CMAKE_RN_TARGETS environment variable Determine default targets from CMAKE_RN_TARGETS and FERRIC_TARGETS environment variable Jul 22, 2025
@kraenhansen kraenhansen merged commit 8557768 into main Jul 22, 2025
6 checks passed
@kraenhansen kraenhansen deleted the kh/default-targets-from-env branch July 22, 2025 21:42
Copy link
Collaborator

@shirakaba shirakaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some post-review questions.

Comment on lines +79 to +80
CMAKE_RN_TARGETS: arm64-apple-ios-sim
FERRIC_TARGETS: aarch64-apple-ios-sim
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why Ferric handles the build of aarch64 while cmake-rn handles arm64?

Copy link
Collaborator Author

@kraenhansen kraenhansen Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a naming difference between Xcode and the Rust compiler targets.

Comment on lines +55 to +60
const targetOption = new Option("--target <target...>", "Targets to build for")
.choices(allTargets)
.default(
defaultTargets,
"CMAKE_RN_TARGETS environment variable split by ','"
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I last used [email protected], when invoking the cmake-rn and cmake-rn --android --ios commands, the CLI didn't prompt me for what targets to build. Is that still the case, or has something changed recently?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's another fallback default if no targets are provided through the CLI runtime options. The reason that is not handled here is because I wanted to print a warning in that case.

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.) CMake RN Our `cmake` wrapping CLI enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants