Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/witty-cats-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cmake-rn": patch
---

Error early when using conflicting architectures for across triplets
3 changes: 3 additions & 0 deletions packages/cmake-rn/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ program = program.action(
platformHasTriplet(platform, triplet),
);
if (relevantTriplets.length > 0) {
platform.assertValidTriplets(
relevantTriplets.map(({ triplet }) => triplet),
);
await platform.configure(
relevantTriplets,
baseOptions,
Expand Down
1 change: 1 addition & 0 deletions packages/cmake-rn/src/platforms/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export const platform: Platform<Triplet[], AndroidOpts> = {
.addOption(ndkVersionOption)
.addOption(androidSdkVersionOption);
},
assertValidTriplets() {},
async configure(
triplets,
{
Expand Down
36 changes: 36 additions & 0 deletions packages/cmake-rn/src/platforms/apple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fs from "node:fs";
import cp from "node:child_process";

import {
assertFixable,
Option,
oraPromise,
prettyPath,
Expand Down Expand Up @@ -193,6 +194,12 @@ async function readCmakeSharedLibraryTarget(
return sharedLibrary;
}

const SIMULATOR_TRIPLET_SUFFIXES = [
"apple-ios-sim",
"apple-tvos-sim",
"apple-visionos-sim",
] as const;

export const platform: Platform<Triplet[], AppleOpts> = {
id: "apple",
name: "Apple",
Expand Down Expand Up @@ -243,6 +250,35 @@ export const platform: Platform<Triplet[], AppleOpts> = {
.addOption(xcframeworkExtensionOption)
.addOption(appleBundleIdentifierOption);
},
assertValidTriplets(triplets) {
for (const suffix of SIMULATOR_TRIPLET_SUFFIXES) {
const suggestion = `use the universal 'arm64;x86_64-${suffix}' triplet instead`;
assertFixable(
!triplets.includes(`x86_64-${suffix}`) ||
!triplets.includes(`arm64-${suffix}`),
`Conflicting triplet variants for ${suffix}`,
{
instructions: `Remove either the arm64 or x86_64 variant of the ${suffix} triplet or ${suggestion}`,
},
);
assertFixable(
!triplets.includes(`x86_64-${suffix}`) ||
!triplets.includes(`arm64;x86_64-${suffix}`),
`Conflicting triplet variants for ${suffix}`,
{
instructions: `Remove the x86_64 variant of the ${suffix} triplet and ${suggestion}`,
},
);
assertFixable(
!triplets.includes(`arm64-${suffix}`) ||
!triplets.includes(`arm64;x86_64-${suffix}`),
`Conflicting triplet variants for ${suffix}`,
{
instructions: `Remove the arm64 variant of the ${suffix} triplet and ${suggestion}`,
},
);
}
},
async configure(
triplets,
{ source, build, define, weakNodeApiLinkage, cmakeJs },
Expand Down
5 changes: 5 additions & 0 deletions packages/cmake-rn/src/platforms/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export type Platform<
defaultTriplets(
mode: "current-development" | "all",
): Triplet[] | Promise<Triplet[]>;
/**
* Assert the combination of triplets is supported by the platform.
* @throws {Error} If the combination of triplets is not supported.
*/
assertValidTriplets(triplets: Triplet[]): void;
/**
* Implement this to add any platform specific options to the command.
*/
Expand Down
Loading