Skip to content
Merged
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 packages/cmake-rn/src/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ export function getAndroidConfigureCmakeArgs({
.join(" ")}`,
];
}

export function isAndroidSupported() {
const { ANDROID_HOME } = process.env;
return typeof ANDROID_HOME === "string" && fs.existsSync(ANDROID_HOME);
}
4 changes: 4 additions & 0 deletions packages/cmake-rn/src/apple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,7 @@ export function getAppleBuildArgs() {
// We expect the final application to sign these binaries
return ["CODE_SIGNING_ALLOWED=NO"];
}

export function isAppleSupported() {
return process.platform === "darwin";
}
28 changes: 17 additions & 11 deletions packages/cmake-rn/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import chalk from "chalk";

import {
DEFAULT_APPLE_TRIPLETS,
isAppleSupported,
getAppleBuildArgs,
getAppleConfigureCmakeArgs,
} from "./apple.js";
import {
DEFAULT_ANDROID_TRIPLETS,
isAndroidSupported,
getAndroidConfigureCmakeArgs,
} from "./android.js";
import { getWeakNodeApiVariables } from "./weak-node-api.js";
Expand Down Expand Up @@ -129,19 +131,23 @@ export const program = new Command("cmake-rn")
}

if (triplets.size === 0) {
if (isAndroidSupported()) {
if (process.arch === "arm64") {
triplets.add("aarch64-linux-android");
} else if (process.arch === "x64") {
triplets.add("x86_64-linux-android");
}
}
if (isAppleSupported()) {
if (process.arch === "arm64") {
triplets.add("arm64-apple-ios-sim");
}
}
console.error(
"Nothing to build 🤷",
"Please specify at least one triplet with",
chalk.dim("--triplet"),
`(or use the ${chalk.dim("--android")} or ${chalk.dim(
"--apple"
)} shorthands)`
chalk.yellowBright("ℹ"),
"Using default triplets",
chalk.dim("(" + [...triplets].join(", ") + ")")
);
for (const triplet of SUPPORTED_TRIPLETS) {
console.error(`${chalk.dim("--triplet")} ${triplet}`);
}
process.exitCode = 1;
return;
}

const tripletContext = [...triplets].map((triplet) => {
Expand Down
34 changes: 34 additions & 0 deletions packages/ferric/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,31 @@ export const buildCommand = new Command("build")
targets.add(target);
}
}

if (targets.size === 0) {
if (isAndroidSupported()) {
if (process.arch === "arm64") {
targets.add("aarch64-linux-android");
} else if (process.arch === "x64") {
targets.add("x86_64-linux-android");
}
}
if (isAppleSupported()) {
if (process.arch === "arm64") {
targets.add("aarch64-apple-ios-sim");
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the ARM64 simulator is added for Apple; consider also adding x86_64-apple-ios-sim when process.arch === "x64" to cover Intel-based simulators.

Suggested change
targets.add("aarch64-apple-ios-sim");
targets.add("aarch64-apple-ios-sim");
} else if (process.arch === "x64") {
targets.add("x86_64-apple-ios-sim");

Copilot uses AI. Check for mistakes.

}
}
console.error(
chalk.yellowBright("ℹ"),
chalk.dim(
`Using default targets, pass ${chalk.italic(
"--android"
)}, ${chalk.italic("--apple")} or individual ${chalk.italic(
"--target"
)} options, to avoid this.`
)
);
}
ensureCargo();
ensureInstalledTargets(targets);

Expand Down Expand Up @@ -314,3 +339,12 @@ async function combineLibraries(
return [...result, universalPath];
}
}

export function isAndroidSupported() {
const { ANDROID_HOME } = process.env;
return typeof ANDROID_HOME === "string" && fs.existsSync(ANDROID_HOME);
}

export function isAppleSupported() {
return process.platform === "darwin";
}