Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ninja makefile fallback#108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
kraenhansen wants to merge3 commits intomain
base:main
Choose a base branch
Loading
fromkh/ninja-makefile-fallback
Draft
Show file tree
Hide file tree
Changes fromall 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
29 changes: 11 additions & 18 deletionspackages/react-native-node-api-cmake/src/android.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,16 @@ import path from "node:path";

import { AndroidTriplet } from "react-native-node-api-modules";

import { isNinjaAvailable } from "./ninja.js";

function getCmakeGenerator() {
if (isNinjaAvailable()) {
return "Ninja";
} else {
return "Unix Makefiles";
}
}

export const DEFAULT_ANDROID_TRIPLETS = [
"aarch64-linux-android",
"armv7a-linux-androideabi",
Expand DownExpand Up@@ -48,16 +58,9 @@ export function getAndroidConfigureCmakeArgs({
);
const architecture = ANDROID_ARCHITECTURES[triplet];

const linkerFlags: string[] = [
// `--no-version-undefined`,
// `--whole-archive`,
// `--no-whole-archive`,
];

return [
// Use the XCode as generator for Apple platforms
"-G",
"Ninja",
getCmakeGenerator(),
"--toolchain",
toolchainPath,
"-D",
Expand All@@ -68,8 +71,6 @@ export function getAndroidConfigureCmakeArgs({
// `CMAKE_INSTALL_PREFIX=${installPath}`,
// "-D",
// `CMAKE_BUILD_TYPE=${configuration}`,
"-D",
"CMAKE_MAKE_PROGRAM=ninja",
// "-D",
// "CMAKE_C_COMPILER_LAUNCHER=ccache",
// "-D",
Expand All@@ -84,13 +85,5 @@ export function getAndroidConfigureCmakeArgs({
// `ANDROID_NATIVE_API_LEVEL=${ANDROID_API_LEVEL}`,
"-D",
"ANDROID_STL=c++_shared",
// Pass linker flags to avoid errors from undefined symbols
// TODO: Link against a weak-node-api to avoid this (or whatever other lib which will be providing the symbols)
// "-D",
// `CMAKE_SHARED_LINKER_FLAGS="-Wl,--allow-shlib-undefined"`,
"-D",
`CMAKE_SHARED_LINKER_FLAGS=${linkerFlags
.map((flag) => `-Wl,${flag}`)
.join(" ")}`,
];
}
39 changes: 39 additions & 0 deletionspackages/react-native-node-api-cmake/src/ninja.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
import chalk from "chalk";
import cp from "node:child_process";

export function getNinjaVersion(): string | undefined {
try {
const ninjaVersion = cp
.execSync("ninja --version", {
encoding: "utf-8",
stdio: "pipe",
})
.trim();
return ninjaVersion;
} catch {
return undefined;
}
}

let ninjaAvailable: boolean | undefined;

export function isNinjaAvailable(log = true): boolean {
if (typeof ninjaAvailable === "boolean") {
return ninjaAvailable;
}

const ninjaVersion = getNinjaVersion();
ninjaAvailable = typeof ninjaVersion === "string";

if (log && ninjaAvailable) {
console.log(chalk.dim(`Using Ninja ${ninjaVersion} for Android builds`));
} else if (log && !ninjaAvailable) {
console.log(
`Using Unix Makefiles as fallback, as Ninja was not found.\n${chalk.dim(
"Install Ninja for faster builds."
)}`
);
}

return ninjaAvailable;
}

[8]ページ先頭

©2009-2025 Movatter.jp