Skip to content

Commit c490dd5

Browse files
committed
Support multiple purposes when picking default triplets
1 parent 43ce065 commit c490dd5

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

packages/cmake-rn/src/cli.ts

Lines changed: 2 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 platform.triplets) {
190+
for (const triplet of await platform.defaultTriplets("release")) {
191191
triplets.add(triplet);
192192
}
193193
}
@@ -196,7 +196,7 @@ 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()) {
199+
for (const triplet of await platform.defaultTriplets("development")) {
200200
triplets.add(triplet);
201201
}
202202
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ export const platform: Platform<Triplet[], AndroidOpts> = {
100100
"i686-linux-android",
101101
"x86_64-linux-android",
102102
],
103-
defaultTriplets() {
104-
if (process.arch === "arm64") {
103+
defaultTriplets(purpose) {
104+
if (purpose === "release") {
105+
return this.triplets;
106+
} else if (process.arch === "arm64") {
105107
return ["aarch64-linux-android"];
106108
} else if (process.arch === "x64") {
107109
return ["x86_64-linux-android"];

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,27 @@ export const platform: Platform<Triplet[], AppleOpts> = {
210210
"arm64-apple-visionos-sim",
211211
"arm64;x86_64-apple-visionos-sim",
212212
],
213-
defaultTriplets() {
214-
return process.arch === "arm64" ? ["arm64-apple-ios-sim"] : [];
213+
defaultTriplets(purpose) {
214+
if (purpose === "release") {
215+
return [
216+
"arm64;x86_64-apple-darwin",
217+
218+
"arm64-apple-ios",
219+
"arm64;x86_64-apple-ios-sim",
220+
221+
"arm64-apple-tvos",
222+
"arm64;x86_64-apple-tvos-sim",
223+
224+
"arm64-apple-visionos",
225+
"arm64;x86_64-apple-visionos-sim",
226+
];
227+
} else if (process.arch === "arm64") {
228+
return ["arm64-apple-ios-sim"];
229+
} else if (process.arch === "x64") {
230+
return ["x86_64-apple-ios-sim"];
231+
} else {
232+
return [];
233+
}
215234
},
216235
amendCommand(command) {
217236
return command.addOption(xcframeworkExtensionOption);

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type Platform<
3333
Triplets extends string[] = string[],
3434
Opts extends cli.OptionValues = Record<string, unknown>,
3535
Command = ExtendedCommand<Opts>,
36+
Triplet extends string = Triplets[number],
3637
> = {
3738
/**
3839
* Used to identify the platform in the CLI.
@@ -47,9 +48,12 @@ export type Platform<
4748
*/
4849
triplets: Readonly<Triplets>;
4950
/**
50-
* Get the limited subset of triplets that should be built by default for this platform, to support a development workflow.
51+
* Get the limited subset of triplets that should be built by default for this platform.
52+
*
5153
*/
52-
defaultTriplets(): Triplets[number][] | Promise<Triplets[number][]>;
54+
defaultTriplets(
55+
purpose: "development" | "release",
56+
): Readonly<Triplets> | Promise<Readonly<Triplets>>;
5357
/**
5458
* Implement this to add any platform specific options to the command.
5559
*/
@@ -62,15 +66,15 @@ export type Platform<
6266
* Configure all projects for this platform.
6367
*/
6468
configure(
65-
triplets: TripletContext<Triplets[number]>[],
69+
triplets: TripletContext<Triplet>[],
6670
options: BaseOpts & Opts,
6771
spawn: Spawn,
6872
): Promise<void>;
6973
/**
7074
* Platform specific command to build a triplet project.
7175
*/
7276
build(
73-
context: TripletContext<Triplets[number]>,
77+
context: TripletContext<Triplet>,
7478
options: BaseOpts & Opts,
7579
): Promise<void>;
7680
/**
@@ -81,7 +85,7 @@ export type Platform<
8185
* Location of the final prebuilt artefact.
8286
*/
8387
outputPath: string,
84-
triplets: TripletContext<Triplets[number]>[],
88+
triplets: TripletContext<Triplet>[],
8589
options: BaseOpts & Opts,
8690
): Promise<void>;
8791
};

0 commit comments

Comments
 (0)