-
Couldn't load subscription status.
- Fork 4
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
Changes from all commits
1aa7541
bb197ee
ee234b5
a635795
9852f7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "cmake-rn": minor | ||
| --- | ||
|
|
||
| Derive default targets from the CMAKE_RN_TARGETS environment variable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ferric-cli": minor | ||
| --- | ||
|
|
||
| Derive default targets from the FERRIC_TARGETS environment variable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,10 +41,23 @@ const configurationOption = new Option("--configuration <configuration>") | |
| // TODO: Derive default targets | ||
| // This is especially important when driving the build from within a React Native app package. | ||
|
|
||
| const targetOption = new Option( | ||
| "--target <target...>", | ||
| "Targets to build for" | ||
| ).choices(allTargets); | ||
| const { CMAKE_RN_TARGETS } = process.env; | ||
|
|
||
| const defaultTargets = CMAKE_RN_TARGETS ? CMAKE_RN_TARGETS.split(",") : []; | ||
|
|
||
| for (const target of defaultTargets) { | ||
|
||
| assert( | ||
| (allTargets as string[]).includes(target), | ||
| `Unexpected target in CMAKE_RN_TARGETS: ${target}` | ||
| ); | ||
| } | ||
|
|
||
| const targetOption = new Option("--target <target...>", "Targets to build for") | ||
| .choices(allTargets) | ||
| .default( | ||
| defaultTargets, | ||
| "CMAKE_RN_TARGETS environment variable split by ','" | ||
| ); | ||
|
Comment on lines
+55
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I last used There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| const buildPathOption = new Option( | ||
| "--build <path>", | ||
|
|
@@ -148,16 +161,19 @@ program = program.action( | |
| }); | ||
|
|
||
| // Configure every triplet project | ||
| const targetsSummary = chalk.dim( | ||
| `(${getTargetsSummary(targetContexts)})` | ||
| ); | ||
| await oraPromise( | ||
| Promise.all( | ||
| targetContexts.map(({ platform, ...context }) => | ||
| configureProject(platform, context, baseOptions) | ||
| ) | ||
| ), | ||
| { | ||
| text: "Configuring projects", | ||
| text: `Configuring projects ${targetsSummary}`, | ||
| isSilent: baseOptions.verbose, | ||
| successText: "Configured projects", | ||
| successText: `Configured projects ${targetsSummary}`, | ||
| failText: ({ message }) => `Failed to configure projects: ${message}`, | ||
| } | ||
| ); | ||
|
|
@@ -208,6 +224,23 @@ program = program.action( | |
| } | ||
| ); | ||
|
|
||
| function getTargetsSummary( | ||
| targetContexts: { target: string; platform: Platform }[] | ||
| ) { | ||
| const targetsPerPlatform: Record<string, string[]> = {}; | ||
| for (const { target, platform } of targetContexts) { | ||
| if (!targetsPerPlatform[platform.id]) { | ||
| targetsPerPlatform[platform.id] = []; | ||
| } | ||
| targetsPerPlatform[platform.id].push(target); | ||
| } | ||
| return Object.entries(targetsPerPlatform) | ||
| .map(([platformId, targets]) => { | ||
| return `${platformId}: ${targets.join(", ")}`; | ||
| }) | ||
| .join(" / "); | ||
| } | ||
|
|
||
| function getBuildPath({ build, source }: BaseOpts) { | ||
| // TODO: Add configuration (debug vs release) | ||
| return path.resolve(process.cwd(), build || path.join(source, "build")); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,7 @@ import { | |||||||||||||
| prettyPath, | ||||||||||||||
| } from "react-native-node-api"; | ||||||||||||||
|
|
||||||||||||||
| import { UsageError } from "./errors.js"; | ||||||||||||||
| import { UsageError, assertFixable } from "./errors.js"; | ||||||||||||||
| import { ensureCargo, build } from "./cargo.js"; | ||||||||||||||
| import { | ||||||||||||||
| ALL_TARGETS, | ||||||||||||||
|
|
@@ -62,9 +62,26 @@ const ANDROID_TRIPLET_PER_TARGET: Record<AndroidTargetName, AndroidTriplet> = { | |||||||||||||
| const DEFAULT_NDK_VERSION = "27.1.12297006"; | ||||||||||||||
| const ANDROID_API_LEVEL = 24; | ||||||||||||||
|
|
||||||||||||||
| const { FERRIC_TARGETS } = process.env; | ||||||||||||||
|
|
||||||||||||||
| function getDefaultTargets() { | ||||||||||||||
|
Comment on lines
+65
to
+67
|
||||||||||||||
| const { FERRIC_TARGETS } = process.env; | |
| function getDefaultTargets() { | |
| function getDefaultTargets() { | |
| const { FERRIC_TARGETS } = process.env; |
There was a problem hiding this comment.
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
aarch64while cmake-rn handlesarm64?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.