Skip to content

Commit 2442a5e

Browse files
committed
Include config in Android build directory names
1 parent ea2aea4 commit 2442a5e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from "react-native-node-api";
1414
import * as cmakeFileApi from "cmake-file-api";
1515

16-
import type { Platform } from "./types.js";
16+
import type { BaseOpts, Platform } from "./types.js";
1717
import { toDefineArguments } from "../helpers.js";
1818
import {
1919
getCmakeJSVariables,
@@ -45,8 +45,12 @@ const androidSdkVersionOption = new Option(
4545

4646
type AndroidOpts = { ndkVersion: string; androidSdkVersion: string };
4747

48-
function getBuildPath(baseBuildPath: string, triplet: Triplet) {
49-
return path.join(baseBuildPath, triplet);
48+
function getBuildPath(
49+
baseBuildPath: string,
50+
triplet: Triplet,
51+
configuration: BaseOpts["configuration"],
52+
) {
53+
return path.join(baseBuildPath, triplet + "-" + configuration);
5054
}
5155

5256
export const platform: Platform<Triplet[], AndroidOpts> = {
@@ -127,7 +131,7 @@ export const platform: Platform<Triplet[], AndroidOpts> = {
127131

128132
await Promise.all(
129133
triplets.map(async ({ triplet, spawn }) => {
130-
const buildPath = getBuildPath(build, triplet);
134+
const buildPath = getBuildPath(build, triplet, configuration);
131135
const outputPath = path.join(buildPath, "out");
132136
// We want to use the CMake File API to query information later
133137
await cmakeFileApi.createSharedStatelessQuery(
@@ -141,6 +145,8 @@ export const platform: Platform<Triplet[], AndroidOpts> = {
141145
source,
142146
"-B",
143147
buildPath,
148+
// Ideally, we would use the "Ninja Multi-Config" generator here,
149+
// but it doesn't support the "RelWithDebInfo" configuration on Android.
144150
"-G",
145151
"Ninja",
146152
"--toolchain",
@@ -159,8 +165,8 @@ export const platform: Platform<Triplet[], AndroidOpts> = {
159165
}),
160166
);
161167
},
162-
async build({ triplet, spawn }, { target, build }) {
163-
const buildPath = getBuildPath(build, triplet);
168+
async build({ triplet, spawn }, { target, build, configuration }) {
169+
const buildPath = getBuildPath(build, triplet, configuration);
164170
await spawn("cmake", [
165171
"--build",
166172
buildPath,
@@ -182,7 +188,7 @@ export const platform: Platform<Triplet[], AndroidOpts> = {
182188
> = {};
183189

184190
for (const { triplet } of triplets) {
185-
const buildPath = getBuildPath(build, triplet);
191+
const buildPath = getBuildPath(build, triplet, configuration);
186192
assert(fs.existsSync(buildPath), `Expected a directory at ${buildPath}`);
187193
const targets = await cmakeFileApi.readCurrentTargetsDeep(
188194
buildPath,

0 commit comments

Comments
 (0)