Skip to content

Commit 5cb8fe8

Browse files
committed
Add verbose option
1 parent d9e1a96 commit 5cb8fe8

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

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
}

0 commit comments

Comments
 (0)