Skip to content

Conversation

@kraenhansen
Copy link
Collaborator

@kraenhansen kraenhansen commented Jun 19, 2025

Merging this PR will:

  • Fix the Ferric CLI to pass NDK tools to Cargo correctly on Windows, by conditionally appending .exe or .cmd on Windows.

@kraenhansen kraenhansen self-assigned this Jun 19, 2025
@kraenhansen kraenhansen added bug Something isn't working Ferric 🦀 labels Jun 19, 2025
@changeset-bot
Copy link

changeset-bot bot commented Jun 19, 2025

⚠️ No Changeset found

Latest commit: 4fefa06

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

This was referenced Jun 19, 2025
@kraenhansen kraenhansen requested a review from Copilot June 20, 2025 05:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the Ferric CLI’s cargo configuration to correctly append Windows file extensions when invoking NDK toolchain binaries on Windows.

  • Introduce cmdMaybe and exeMaybe to conditionally add .cmd or .exe on Windows
  • Append cmdMaybe to all clang/clang++ invocations and exeMaybe to llvm-ar/llvm-ranlib
  • (Unrelated) PATH concatenation remains unchanged
Comments suppressed due to low confidence (2)

packages/ferric/src/cargo.ts:171

  • There are no existing tests covering the Windows-specific behavior of cmdMaybe/exeMaybe. Consider adding unit tests to verify correct suffixes on Windows targets.
    const exeMaybe = process.platform === "win32" ? ".exe" : "";

packages/ferric/src/cargo.ts:210

  • On Windows, PATH segments should be joined with ; instead of :. Consider using path.delimiter to handle this cross-platform.
      PATH: `${toolchainBinPath}:${process.env.PATH}`,

Comment on lines +182 to +202
`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}`
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.

Comment on lines +170 to +171
const cmdMaybe = process.platform === "win32" ? ".cmd" : "";
const exeMaybe = process.platform === "win32" ? ".exe" : "";
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";?

Comment on lines +170 to +171
const cmdMaybe = process.platform === "win32" ? ".cmd" : "";
const exeMaybe = process.platform === "win32" ? ".exe" : "";
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";?

@kraenhansen kraenhansen merged commit 48ac294 into main Jun 22, 2025
4 checks passed
@kraenhansen kraenhansen deleted the kh/ferric-ndk-executable-extensions branch June 22, 2025 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Ferric 🦀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants