Skip to content

Commit d703f8d

Browse files
authored
Build simulators by default (#118)
1 parent 4afef09 commit d703f8d

File tree

4 files changed

+60
-11
lines changed

4 files changed

+60
-11
lines changed

packages/cmake-rn/src/android.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,8 @@ export function getAndroidConfigureCmakeArgs({
9494
.join(" ")}`,
9595
];
9696
}
97+
98+
export function isAndroidSupported() {
99+
const { ANDROID_HOME } = process.env;
100+
return typeof ANDROID_HOME === "string" && fs.existsSync(ANDROID_HOME);
101+
}

packages/cmake-rn/src/apple.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,7 @@ export function getAppleBuildArgs() {
107107
// We expect the final application to sign these binaries
108108
return ["CODE_SIGNING_ALLOWED=NO"];
109109
}
110+
111+
export function isAppleSupported() {
112+
return process.platform === "darwin";
113+
}

packages/cmake-rn/src/cli.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import chalk from "chalk";
1010

1111
import {
1212
DEFAULT_APPLE_TRIPLETS,
13+
isAppleSupported,
1314
getAppleBuildArgs,
1415
getAppleConfigureCmakeArgs,
1516
} from "./apple.js";
1617
import {
1718
DEFAULT_ANDROID_TRIPLETS,
19+
isAndroidSupported,
1820
getAndroidConfigureCmakeArgs,
1921
} from "./android.js";
2022
import { getWeakNodeApiVariables } from "./weak-node-api.js";
@@ -129,19 +131,23 @@ export const program = new Command("cmake-rn")
129131
}
130132

131133
if (triplets.size === 0) {
134+
if (isAndroidSupported()) {
135+
if (process.arch === "arm64") {
136+
triplets.add("aarch64-linux-android");
137+
} else if (process.arch === "x64") {
138+
triplets.add("x86_64-linux-android");
139+
}
140+
}
141+
if (isAppleSupported()) {
142+
if (process.arch === "arm64") {
143+
triplets.add("arm64-apple-ios-sim");
144+
}
145+
}
132146
console.error(
133-
"Nothing to build 🤷",
134-
"Please specify at least one triplet with",
135-
chalk.dim("--triplet"),
136-
`(or use the ${chalk.dim("--android")} or ${chalk.dim(
137-
"--apple"
138-
)} shorthands)`
147+
chalk.yellowBright("ℹ"),
148+
"Using default triplets",
149+
chalk.dim("(" + [...triplets].join(", ") + ")")
139150
);
140-
for (const triplet of SUPPORTED_TRIPLETS) {
141-
console.error(`${chalk.dim("--triplet")} ${triplet}`);
142-
}
143-
process.exitCode = 1;
144-
return;
145151
}
146152

147153
const tripletContext = [...triplets].map((triplet) => {

packages/ferric/src/build.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,31 @@ export const buildCommand = new Command("build")
118118
targets.add(target);
119119
}
120120
}
121+
122+
if (targets.size === 0) {
123+
if (isAndroidSupported()) {
124+
if (process.arch === "arm64") {
125+
targets.add("aarch64-linux-android");
126+
} else if (process.arch === "x64") {
127+
targets.add("x86_64-linux-android");
128+
}
129+
}
130+
if (isAppleSupported()) {
131+
if (process.arch === "arm64") {
132+
targets.add("aarch64-apple-ios-sim");
133+
}
134+
}
135+
console.error(
136+
chalk.yellowBright("ℹ"),
137+
chalk.dim(
138+
`Using default targets, pass ${chalk.italic(
139+
"--android"
140+
)}, ${chalk.italic("--apple")} or individual ${chalk.italic(
141+
"--target"
142+
)} options, to avoid this.`
143+
)
144+
);
145+
}
121146
ensureCargo();
122147
ensureInstalledTargets(targets);
123148

@@ -314,3 +339,12 @@ async function combineLibraries(
314339
return [...result, universalPath];
315340
}
316341
}
342+
343+
export function isAndroidSupported() {
344+
const { ANDROID_HOME } = process.env;
345+
return typeof ANDROID_HOME === "string" && fs.existsSync(ANDROID_HOME);
346+
}
347+
348+
export function isAppleSupported() {
349+
return process.platform === "darwin";
350+
}

0 commit comments

Comments
 (0)