Skip to content

Commit ece778a

Browse files
authored
Add --verbose option to cmake-rn (#130)
* Add verbose option * Upgrading bufout to not fail when flushing in verbose mode
1 parent 04545b8 commit ece778a

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cmake-rn/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"dependencies": {
2525
"@commander-js/extra-typings": "^13.1.0",
26-
"bufout": "^0.3.1",
26+
"bufout": "^0.3.2",
2727
"chalk": "^5.4.1",
2828
"cmake-js": "^7.3.1",
2929
"commander": "^13.1.0",

packages/cmake-rn/src/cli.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ const DEFAULT_NDK_VERSION = "27.1.12297006";
4242

4343
// TODO: Add automatic ccache support
4444

45+
const verboseOption = new Option(
46+
"--verbose",
47+
"Print more output during the build"
48+
).default(process.env.CI === "true");
49+
4550
const sourcePathOption = new Option(
4651
"--source <path>",
4752
"Specify the source directory containing a CMakeLists.txt file"
@@ -100,6 +105,7 @@ const xcframeworkExtensionOption = new Option(
100105

101106
export const program = new Command("cmake-rn")
102107
.description("Build React Native Node API modules with CMake")
108+
.addOption(verboseOption)
103109
.addOption(sourcePathOption)
104110
.addOption(configurationOption)
105111
.addOption(tripletOption)
@@ -163,6 +169,7 @@ export const program = new Command("cmake-rn")
163169
// Configure every triplet project
164170
await oraPromise(Promise.all(tripletContext.map(configureProject)), {
165171
text: "Configuring projects",
172+
isSilent: globalContext.verbose,
166173
successText: "Configured projects",
167174
failText: ({ message }) => `Failed to configure projects: ${message}`,
168175
});
@@ -182,6 +189,7 @@ export const program = new Command("cmake-rn")
182189
),
183190
{
184191
text: "Building projects",
192+
isSilent: globalContext.verbose,
185193
successText: "Built projects",
186194
failText: ({ message }) => `Failed to build projects: ${message}`,
187195
}
@@ -365,8 +373,14 @@ function getBuildArgs(triplet: SupportedTriplet) {
365373
}
366374

367375
async function configureProject(context: TripletScopedContext) {
368-
const { triplet, tripletBuildPath, source, ndkVersion, weakNodeApiLinkage } =
369-
context;
376+
const {
377+
verbose,
378+
triplet,
379+
tripletBuildPath,
380+
source,
381+
ndkVersion,
382+
weakNodeApiLinkage,
383+
} = context;
370384
await spawn(
371385
"cmake",
372386
[
@@ -381,13 +395,14 @@ async function configureProject(context: TripletScopedContext) {
381395
}),
382396
],
383397
{
384-
outputMode: "buffered",
398+
outputMode: verbose ? "inherit" : "buffered",
399+
outputPrefix: verbose ? chalk.dim(`[${triplet}] `) : undefined,
385400
}
386401
);
387402
}
388403

389404
async function buildProject(context: TripletScopedContext) {
390-
const { triplet, tripletBuildPath, configuration } = context;
405+
const { verbose, triplet, tripletBuildPath, configuration } = context;
391406
await spawn(
392407
"cmake",
393408
[
@@ -399,7 +414,8 @@ async function buildProject(context: TripletScopedContext) {
399414
...getBuildArgs(triplet),
400415
],
401416
{
402-
outputMode: "buffered",
417+
outputMode: verbose ? "inherit" : "buffered",
418+
outputPrefix: verbose ? chalk.dim(`[${triplet}] `) : undefined,
403419
}
404420
);
405421
}

packages/ferric/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"dependencies": {
1919
"@napi-rs/cli": "3.0.0-alpha.80",
2020
"@commander-js/extra-typings": "^13.1.0",
21-
"bufout": "^0.3.1",
21+
"bufout": "^0.3.2",
2222
"chalk": "^5.4.1",
2323
"commander": "^13.1.0",
2424
"ora": "^8.2.0"

packages/host/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"license": "MIT",
7777
"dependencies": {
7878
"@commander-js/extra-typings": "^13.1.0",
79-
"bufout": "^0.3.1",
79+
"bufout": "^0.3.2",
8080
"chalk": "^5.4.1",
8181
"commander": "^13.1.0",
8282
"ora": "^8.2.0",

0 commit comments

Comments
 (0)