Further reduce worker counts, JVM heap, Node memory, and CMake parallelism to lower CI costs. These incremental adjustments complement recent optimizations.
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
const { withDangerousMod } = require('@expo/config-plugins');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const MAX_JOBS = '3';
|
|
|
|
// React Native's hermes-engine build hardcodes
|
|
// Runtime.getRuntime().availableProcessors()
|
|
// for `cmake --build -j`, ignoring the CMAKE_BUILD_PARALLEL_LEVEL env var.
|
|
// On high-core CI runners this exhausts memory.
|
|
// This plugin caps it during prebuild.
|
|
const withCmakeJobLimit = (config) =>
|
|
withDangerousMod(config, [
|
|
'android',
|
|
async (config) => {
|
|
const root = config.modRequest.projectRoot;
|
|
|
|
const hermesPath = path.join(
|
|
root,
|
|
'node_modules',
|
|
'react-native',
|
|
'ReactAndroid',
|
|
'hermes-engine',
|
|
'build.gradle.kts',
|
|
);
|
|
if (fs.existsSync(hermesPath)) {
|
|
let content = fs.readFileSync(hermesPath, 'utf-8');
|
|
content = content.replace(
|
|
/Runtime\.getRuntime\(\)\.availableProcessors\(\)\.toString\(\)/,
|
|
`"${MAX_JOBS}"`,
|
|
);
|
|
fs.writeFileSync(hermesPath, content);
|
|
console.log(`[withCmakeJobLimit] capped hermes-engine jobs to ${MAX_JOBS}`);
|
|
}
|
|
|
|
return config;
|
|
},
|
|
]);
|
|
|
|
module.exports = withCmakeJobLimit;
|