From b05aadb31c87547312708391a2ea874c3c0a4b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sat, 7 Feb 2026 20:38:02 +0100 Subject: [PATCH] Error early when using conflicting architectures --- .changeset/witty-cats-admire.md | 5 +++ packages/cmake-rn/src/cli.ts | 3 ++ packages/cmake-rn/src/platforms/android.ts | 1 + packages/cmake-rn/src/platforms/apple.ts | 36 ++++++++++++++++++++++ packages/cmake-rn/src/platforms/types.ts | 5 +++ 5 files changed, 50 insertions(+) create mode 100644 .changeset/witty-cats-admire.md diff --git a/.changeset/witty-cats-admire.md b/.changeset/witty-cats-admire.md new file mode 100644 index 00000000..cc563367 --- /dev/null +++ b/.changeset/witty-cats-admire.md @@ -0,0 +1,5 @@ +--- +"cmake-rn": patch +--- + +Error early when using conflicting architectures for across triplets diff --git a/packages/cmake-rn/src/cli.ts b/packages/cmake-rn/src/cli.ts index a96279ed..4783f37b 100644 --- a/packages/cmake-rn/src/cli.ts +++ b/packages/cmake-rn/src/cli.ts @@ -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, diff --git a/packages/cmake-rn/src/platforms/android.ts b/packages/cmake-rn/src/platforms/android.ts index 4e505ca8..dd6234bb 100644 --- a/packages/cmake-rn/src/platforms/android.ts +++ b/packages/cmake-rn/src/platforms/android.ts @@ -122,6 +122,7 @@ export const platform: Platform = { .addOption(ndkVersionOption) .addOption(androidSdkVersionOption); }, + assertValidTriplets() {}, async configure( triplets, { diff --git a/packages/cmake-rn/src/platforms/apple.ts b/packages/cmake-rn/src/platforms/apple.ts index cb2e7f1b..7ea17009 100644 --- a/packages/cmake-rn/src/platforms/apple.ts +++ b/packages/cmake-rn/src/platforms/apple.ts @@ -4,6 +4,7 @@ import fs from "node:fs"; import cp from "node:child_process"; import { + assertFixable, Option, oraPromise, prettyPath, @@ -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 = { id: "apple", name: "Apple", @@ -243,6 +250,35 @@ export const platform: Platform = { .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 }, diff --git a/packages/cmake-rn/src/platforms/types.ts b/packages/cmake-rn/src/platforms/types.ts index 6944d4bf..d6cd3963 100644 --- a/packages/cmake-rn/src/platforms/types.ts +++ b/packages/cmake-rn/src/platforms/types.ts @@ -53,6 +53,11 @@ export type Platform< defaultTriplets( mode: "current-development" | "all", ): Triplet[] | Promise; + /** + * 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. */