68 lines
1.7 KiB
JavaScript
68 lines
1.7 KiB
JavaScript
const {
|
|
withAppBuildGradle,
|
|
withGradleProperties,
|
|
} = require("expo/config-plugins");
|
|
|
|
const TARGET_KEYS = new Set([
|
|
"org.gradle.java.installations.auto-detect",
|
|
"org.gradle.java.installations.auto-download",
|
|
"org.gradle.java.installations.fromEnv",
|
|
"org.gradle.java.installations.paths",
|
|
]);
|
|
|
|
function upsertProperty(entries, key, value) {
|
|
const existing = entries.find(
|
|
(entry) => entry.type === "property" && entry.key === key
|
|
);
|
|
|
|
if (existing) {
|
|
existing.value = value;
|
|
return;
|
|
}
|
|
|
|
entries.push({ type: "property", key, value });
|
|
}
|
|
|
|
function addCppFlag(contents) {
|
|
const flag = 'cppFlags "-Wno-error=deprecated-declarations"';
|
|
if (contents.includes(flag)) {
|
|
return contents;
|
|
}
|
|
|
|
return contents.replace(
|
|
/(buildConfigField "String", "REACT_NATIVE_RELEASE_LEVEL", "[^\n]*"\n)/,
|
|
`$1 externalNativeBuild {\n cmake {\n ${flag}\n }\n }\n`
|
|
);
|
|
}
|
|
|
|
module.exports = function withPortableGradleToolchain(config) {
|
|
config = withGradleProperties(config, (config) => {
|
|
config.modResults = config.modResults.filter(
|
|
(entry) => !(entry.type === "property" && TARGET_KEYS.has(entry.key))
|
|
);
|
|
|
|
upsertProperty(
|
|
config.modResults,
|
|
"org.gradle.java.installations.auto-detect",
|
|
"false"
|
|
);
|
|
upsertProperty(
|
|
config.modResults,
|
|
"org.gradle.java.installations.auto-download",
|
|
"false"
|
|
);
|
|
upsertProperty(
|
|
config.modResults,
|
|
"org.gradle.java.installations.fromEnv",
|
|
"JAVA_HOME"
|
|
);
|
|
|
|
return config;
|
|
});
|
|
|
|
return withAppBuildGradle(config, (config) => {
|
|
config.modResults.contents = addCppFlag(config.modResults.contents);
|
|
return config;
|
|
});
|
|
};
|