Skip to content

Commit 8de6f11

Browse files
committed
Renamed purpose to mode and values to be more semantic
1 parent ce35dd9 commit 8de6f11

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

packages/cmake-rn/src/cli.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ program = program.action(
187187
for (const platform of Object.values(platforms)) {
188188
// Forcing the types a bit here, since the platform id option is dynamically added
189189
if ((baseOptions as Record<string, unknown>)[platform.id]) {
190-
for (const triplet of await platform.defaultTriplets("release")) {
190+
for (const triplet of await platform.defaultTriplets("all")) {
191191
triplets.add(triplet);
192192
}
193193
}
@@ -196,7 +196,9 @@ program = program.action(
196196
if (triplets.size === 0) {
197197
for (const platform of Object.values(platforms)) {
198198
if (platform.isSupportedByHost()) {
199-
for (const triplet of await platform.defaultTriplets("development")) {
199+
for (const triplet of await platform.defaultTriplets(
200+
"current-development",
201+
)) {
200202
triplets.add(triplet);
201203
}
202204
}

packages/cmake-rn/src/platforms/android.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,21 @@ export const platform: Platform<Triplet[], AndroidOpts> = {
100100
"i686-linux-android",
101101
"x86_64-linux-android",
102102
],
103-
defaultTriplets(purpose) {
104-
if (purpose === "release") {
103+
defaultTriplets(mode) {
104+
if (mode === "all") {
105105
return [...this.triplets];
106-
} else if (process.arch === "arm64") {
107-
return ["aarch64-linux-android"];
108-
} else if (process.arch === "x64") {
109-
return ["x86_64-linux-android"];
106+
} else if (mode === "current-development") {
107+
// We're applying a heuristic to determine the current simulators
108+
// TODO: Run a command to probe the currently running emulators instead
109+
if (process.arch === "arm64") {
110+
return ["aarch64-linux-android"];
111+
} else if (process.arch === "x64") {
112+
return ["x86_64-linux-android"];
113+
} else {
114+
return [];
115+
}
110116
} else {
111-
return [];
117+
throw new Error(`Unexpected mode: ${mode as string}`);
112118
}
113119
},
114120
amendCommand(command) {

packages/cmake-rn/src/platforms/apple.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ export const platform: Platform<Triplet[], AppleOpts> = {
210210
"arm64-apple-visionos-sim",
211211
"arm64;x86_64-apple-visionos-sim",
212212
],
213-
defaultTriplets(purpose) {
214-
if (purpose === "release") {
213+
defaultTriplets(mode) {
214+
if (mode === "all") {
215215
return [
216216
"arm64;x86_64-apple-darwin",
217217

@@ -224,8 +224,12 @@ export const platform: Platform<Triplet[], AppleOpts> = {
224224
"arm64-apple-visionos",
225225
"arm64;x86_64-apple-visionos-sim",
226226
];
227-
} else {
227+
} else if (mode === "current-development") {
228+
// We're applying a heuristic to determine the current simulators
229+
// TODO: Run a command to probe the currently running simulators instead
228230
return ["arm64;x86_64-apple-ios-sim"];
231+
} else {
232+
throw new Error(`Unexpected mode: ${mode as string}`);
229233
}
230234
},
231235
amendCommand(command) {

packages/cmake-rn/src/platforms/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ export type Platform<
4949
triplets: Readonly<Triplets>;
5050
/**
5151
* Get the limited subset of triplets that should be built by default for this platform.
52-
*
5352
*/
5453
defaultTriplets(
55-
purpose: "development" | "release",
54+
mode: "current-development" | "all",
5655
): Triplet[] | Promise<Triplet[]>;
5756
/**
5857
* Implement this to add any platform specific options to the command.

0 commit comments

Comments
 (0)