@@ -4,6 +4,7 @@ import fs from "node:fs";
44import cp from "node:child_process" ;
55
66import {
7+ assertFixable ,
78 Option ,
89 oraPromise ,
910 prettyPath ,
@@ -193,6 +194,12 @@ async function readCmakeSharedLibraryTarget(
193194 return sharedLibrary ;
194195}
195196
197+ const SIMULATOR_TRIPLET_SUFFIXES = [
198+ "apple-ios-sim" ,
199+ "apple-tvos-sim" ,
200+ "apple-visionos-sim" ,
201+ ] as const ;
202+
196203async function getCompilerPath (
197204 name : "clang" | "clang++" ,
198205 { buildBinPath, ccachePath } : { buildBinPath : string ; ccachePath : string } ,
@@ -254,6 +261,35 @@ export const platform: Platform<Triplet[], AppleOpts> = {
254261 . addOption ( xcframeworkExtensionOption )
255262 . addOption ( appleBundleIdentifierOption ) ;
256263 } ,
264+ assertValidTriplets ( triplets ) {
265+ for ( const suffix of SIMULATOR_TRIPLET_SUFFIXES ) {
266+ const suggestion = `use the universal 'arm64;x86_64-${ suffix } ' triplet instead` ;
267+ assertFixable (
268+ ! triplets . includes ( `x86_64-${ suffix } ` ) ||
269+ ! triplets . includes ( `arm64-${ suffix } ` ) ,
270+ `Conflicting triplet variants for ${ suffix } ` ,
271+ {
272+ instructions : `Remove either the arm64 or x86_64 variant of the ${ suffix } triplet or ${ suggestion } ` ,
273+ } ,
274+ ) ;
275+ assertFixable (
276+ ! triplets . includes ( `x86_64-${ suffix } ` ) ||
277+ ! triplets . includes ( `arm64;x86_64-${ suffix } ` ) ,
278+ `Conflicting triplet variants for ${ suffix } ` ,
279+ {
280+ instructions : `Remove the x86_64 variant of the ${ suffix } triplet and ${ suggestion } ` ,
281+ } ,
282+ ) ;
283+ assertFixable (
284+ ! triplets . includes ( `arm64-${ suffix } ` ) ||
285+ ! triplets . includes ( `arm64;x86_64-${ suffix } ` ) ,
286+ `Conflicting triplet variants for ${ suffix } ` ,
287+ {
288+ instructions : `Remove the arm64 variant of the ${ suffix } triplet and ${ suggestion } ` ,
289+ } ,
290+ ) ;
291+ }
292+ } ,
257293 async configure (
258294 triplets ,
259295 { source, build, define, weakNodeApiLinkage, cmakeJs, ccachePath } ,
0 commit comments