Skip to content
Merged
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
18 changes: 10 additions & 8 deletions packages/ferric/src/cargo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ export function getTargetEnvironmentVariables({
const targetArch = getTargetAndroidArch(target);
const targetPlatform = getTargetAndroidPlatform(target);
const weakNodeApiPath = getWeakNodeApiAndroidLibraryPath(target);
const cmdMaybe = process.platform === "win32" ? ".cmd" : "";
const exeMaybe = process.platform === "win32" ? ".exe" : "";
Comment on lines +170 to +171
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

[nitpick] The platform-suffix logic is repeated in two separate variables—consider extracting this into a small helper function to reduce duplication and clarify intent.

Suggested change
const cmdMaybe = process.platform === "win32" ? ".cmd" : "";
const exeMaybe = process.platform === "win32" ? ".exe" : "";
const cmdMaybe = getPlatformSuffix("cmd");
const exeMaybe = getPlatformSuffix("exe");

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe const isWindows = process.platform == "win32";?


return {
CARGO_ENCODED_RUSTFLAGS: [
Expand All @@ -177,32 +179,32 @@ export function getTargetEnvironmentVariables({
].join(String.fromCharCode(0x1f)),
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER: joinPathAndAssertExistence(
toolchainBinPath,
`aarch64-linux-android${androidApiLevel}-clang`
`aarch64-linux-android${androidApiLevel}-clang${cmdMaybe}`
),
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER: joinPathAndAssertExistence(
toolchainBinPath,
`armv7a-linux-androideabi${androidApiLevel}-clang`
`armv7a-linux-androideabi${androidApiLevel}-clang${cmdMaybe}`
),
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER: joinPathAndAssertExistence(
toolchainBinPath,
`x86_64-linux-android${androidApiLevel}-clang`
`x86_64-linux-android${androidApiLevel}-clang${cmdMaybe}`
),
CARGO_TARGET_I686_LINUX_ANDROID_LINKER: joinPathAndAssertExistence(
toolchainBinPath,
`i686-linux-android${androidApiLevel}-clang`
`i686-linux-android${androidApiLevel}-clang${cmdMaybe}`
),
TARGET_CC: joinPathAndAssertExistence(
toolchainBinPath,
`${targetArch}-linux-${targetPlatform}-clang`
`${targetArch}-linux-${targetPlatform}-clang${cmdMaybe}`
),
TARGET_CXX: joinPathAndAssertExistence(
toolchainBinPath,
`${targetArch}-linux-${targetPlatform}-clang++`
`${targetArch}-linux-${targetPlatform}-clang++${cmdMaybe}`
Comment on lines +182 to +202
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

Clang in the Android NDK on Windows is a native .exe, not a batch .cmd. You should use exeMaybe instead of cmdMaybe when appending the extension for clang/clang++.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not correct.

),
TARGET_AR: joinPathAndAssertExistence(toolchainBinPath, `llvm-ar`),
TARGET_AR: joinPathAndAssertExistence(toolchainBinPath, `llvm-ar${exeMaybe}`),
TARGET_RANLIB: joinPathAndAssertExistence(
toolchainBinPath,
`llvm-ranlib`
`llvm-ranlib${exeMaybe}`
),
ANDROID_NDK: ndkPath,
PATH: `${toolchainBinPath}:${process.env.PATH}`,
Expand Down
Loading