Skip to content

Commit d5aaa3d

Browse files
committed
Filter CMake targets by target name when passed
1 parent b91415b commit d5aaa3d

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

.changeset/cold-showers-arrive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cmake-rn": patch
3+
---
4+
5+
Filter CMake targets by target name when passed

packages/cmake-rn/src/cli.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ const defineOption = new Option(
109109

110110
const targetOption = new Option(
111111
"--target <target...>",
112-
"CMake targets to build",
113-
).default([] as string[], "Build all targets of the CMake project");
112+
"CMake targets to build (default: all targets of the CMake project)",
113+
);
114114

115115
const noAutoLinkOption = new Option(
116116
"--no-auto-link",
@@ -361,7 +361,9 @@ async function buildProject<T extends string>(
361361
buildPath,
362362
"--config",
363363
configuration,
364-
...(options.target.length > 0 ? ["--target", ...options.target] : []),
364+
...(options.target && options.target.length > 0
365+
? ["--target", ...options.target]
366+
: []),
365367
"--",
366368
...platform.buildArgs(context, options),
367369
],

packages/cmake-rn/src/platforms/android.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ export const platform: Platform<Triplet[], AndroidOpts> = {
121121
const { ANDROID_HOME } = process.env;
122122
return typeof ANDROID_HOME === "string" && fs.existsSync(ANDROID_HOME);
123123
},
124-
async postBuild({ outputPath, triplets }, { autoLink, configuration }) {
124+
async postBuild(
125+
{ outputPath, triplets },
126+
{ autoLink, configuration, target },
127+
) {
125128
const prebuilds: Record<
126129
string,
127130
{ triplet: Triplet; libraryPath: string }[]
@@ -135,7 +138,8 @@ export const platform: Platform<Triplet[], AndroidOpts> = {
135138
"2.0",
136139
);
137140
const sharedLibraries = targets.filter(
138-
(target) => target.type === "SHARED_LIBRARY",
141+
({ type, name }) =>
142+
type === "SHARED_LIBRARY" && (target ? target.includes(name) : true),
139143
);
140144
assert.equal(
141145
sharedLibraries.length,

packages/cmake-rn/src/platforms/apple.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export const platform: Platform<Triplet[], AppleOpts> = {
133133
},
134134
async postBuild(
135135
{ outputPath, triplets },
136-
{ configuration, autoLink, xcframeworkExtension },
136+
{ configuration, autoLink, xcframeworkExtension, target },
137137
) {
138138
const prebuilds: Record<string, string[]> = {};
139139
for (const { buildPath } of triplets) {
@@ -144,7 +144,8 @@ export const platform: Platform<Triplet[], AppleOpts> = {
144144
"2.0",
145145
);
146146
const sharedLibraries = targets.filter(
147-
(target) => target.type === "SHARED_LIBRARY",
147+
({ type, name }) =>
148+
type === "SHARED_LIBRARY" && (target ? target.includes(name) : true),
148149
);
149150
assert.equal(
150151
sharedLibraries.length,

0 commit comments

Comments
 (0)