Skip to content

Commit a635795

Browse files
committed
Use FERRIC_TARGETS as default targets for Ferric
1 parent ee234b5 commit a635795

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

.changeset/loud-paths-eat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ferric-cli": minor
3+
---
4+
5+
Derive default targets from the FERRIC_TARGETS environment variable

packages/ferric/src/build.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
prettyPath,
1919
} from "react-native-node-api";
2020

21-
import { UsageError } from "./errors.js";
21+
import { UsageError, assertFixable } from "./errors.js";
2222
import { ensureCargo, build } from "./cargo.js";
2323
import {
2424
ALL_TARGETS,
@@ -62,9 +62,26 @@ const ANDROID_TRIPLET_PER_TARGET: Record<AndroidTargetName, AndroidTriplet> = {
6262
const DEFAULT_NDK_VERSION = "27.1.12297006";
6363
const ANDROID_API_LEVEL = 24;
6464

65+
const { FERRIC_TARGETS } = process.env;
66+
67+
function getDefaultTargets() {
68+
const result = FERRIC_TARGETS ? FERRIC_TARGETS.split(",") : [];
69+
for (const target of result) {
70+
assertFixable(
71+
(ALL_TARGETS as readonly string[]).includes(target),
72+
`Unexpected target in FERRIC_TARGETS: ${target}`,
73+
{
74+
instructions:
75+
"Pass only valid targets via FERRIC_TARGETS (or remove them)",
76+
}
77+
);
78+
}
79+
return result as (typeof ALL_TARGETS)[number][];
80+
}
81+
6582
const targetOption = new Option("--target <target...>", "Target triple")
6683
.choices(ALL_TARGETS)
67-
.default([]);
84+
.default(getDefaultTargets());
6885
const appleTarget = new Option("--apple", "Use all Apple targets");
6986
const androidTarget = new Option("--android", "Use all Android targets");
7087
const ndkVersionOption = new Option(

0 commit comments

Comments
 (0)