Skip to content
Closed
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: 16 additions & 2 deletions packages/cmake-rn/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,16 @@ const cleanOption = new Option(
"Delete the build directory before configuring the project"
);

const outPathOption = new Option(
const outOption = new Option(
"--out <path>",
"Specify the output directory to store the final build artifacts"
);

const outToBuildOption = new Option(
"--out-to-build",
"Use `./build/${configuration}` directory as output (like `node-gyp` and `cmake-js`)"
);

const ndkVersionOption = new Option(
"--ndk-version <version>",
"The NDK version to use for Android builds"
Expand Down Expand Up @@ -118,7 +123,8 @@ export const program = new Command("cmake-rn")
.addOption(androidOption)
.addOption(appleOption)
.addOption(buildPathOption)
.addOption(outPathOption)
.addOption(outOption)
.addOption(outToBuildOption)
.addOption(cleanOption)
.addOption(ndkVersionOption)
.addOption(androidSdkVersionOption)
Expand Down Expand Up @@ -169,6 +175,14 @@ export const program = new Command("cmake-rn")
}
}

if (globalContext.outToBuild) {
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

Instead of manually asserting mutual exclusion at runtime, use Commander.js's .conflicts() API to declare that --out and --out-to-build cannot be used together, providing built-in CLI validation and clearer error messaging.

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.

We'll want to make this the default behavior and as such, I expect it to just end up as default for the --out parameter.

assert(
globalContext.out === undefined,
"Cannot use --out with --out-to-build"
);
globalContext.out = path.join(buildPath, globalContext.configuration);
}

const tripletContext = [...triplets].map((triplet) => {
const tripletBuildPath = getTripletBuildPath(buildPath, triplet);
return {
Expand Down
Loading