mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
iOS: Use pre-built hermesc if available (#33827)
Summary: Use pre-built hermesc if available by generating a ImportHermesc.cmake file that points to the hermesc binary. Recent `react-native` releases should have hermesc available in sdks/hermesc. Hermes build scripts have been updated to support a `HERMES_OVERRIDE_HERMESC_PATH` envvar which can point to this generated ImportHermesc.cmake file. Pull Request resolved: https://github.com/facebook/react-native/pull/33827 Changelog: [iOS] [Changed] - Use pre-built HermesC if available in current React Native release Reviewed By: cortinico Differential Revision: D36024615 fbshipit-source-id: 476569f73309f9bd142f28cb02d1f7d57b6cbc6a
This commit is contained in:
@@ -18,6 +18,12 @@ const HERMES_DIR = path.join(SDKS_DIR, 'hermes');
|
||||
const HERMES_TAG_FILE_PATH = path.join(SDKS_DIR, '.hermesversion');
|
||||
const HERMES_TARBALL_BASE_URL = 'https://github.com/facebook/hermes/tarball/';
|
||||
const HERMES_TARBALL_DOWNLOAD_DIR = path.join(SDKS_DIR, 'download');
|
||||
const MACOS_BIN_DIR = path.join(SDKS_DIR, 'hermesc', 'osx-bin');
|
||||
const MACOS_HERMESC_PATH = path.join(MACOS_BIN_DIR, 'hermesc');
|
||||
const MACOS_IMPORT_HERMESC_PATH = path.join(
|
||||
MACOS_BIN_DIR,
|
||||
'ImportHermesc.cmake',
|
||||
);
|
||||
|
||||
function prepareFileSystem() {
|
||||
if (!fs.existsSync(SDKS_DIR)) {
|
||||
@@ -135,11 +141,31 @@ function copyBuildScripts() {
|
||||
);
|
||||
}
|
||||
|
||||
function shouldUsePrebuiltHermesC(os) {
|
||||
if (os === 'macos') {
|
||||
return fs.existsSync(MACOS_HERMESC_PATH);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function configureMakeForPrebuiltHermesC() {
|
||||
const IMPORT_HERMESC_TEMPLATE = `add_executable(native-hermesc IMPORTED)
|
||||
set_target_properties(native-hermesc PROPERTIES
|
||||
IMPORTED_LOCATION "${MACOS_HERMESC_PATH}"
|
||||
)`;
|
||||
|
||||
fs.mkdirSync(MACOS_BIN_DIR, {recursive: true});
|
||||
fs.writeFileSync(MACOS_IMPORT_HERMESC_PATH, IMPORT_HERMESC_TEMPLATE);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
configureMakeForPrebuiltHermesC,
|
||||
copyBuildScripts,
|
||||
downloadHermesTarball,
|
||||
expandHermesTarball,
|
||||
getHermesTagSHA,
|
||||
readHermesTag,
|
||||
setHermesTag,
|
||||
shouldUsePrebuiltHermesC,
|
||||
};
|
||||
|
||||
@@ -14,11 +14,18 @@
|
||||
* iOS build pipeline on macOS.
|
||||
*/
|
||||
const {
|
||||
configureMakeForPrebuiltHermesC,
|
||||
copyBuildScripts,
|
||||
downloadHermesTarball,
|
||||
expandHermesTarball,
|
||||
shouldUsePrebuiltHermesC,
|
||||
} = require('./hermes-utils');
|
||||
|
||||
downloadHermesTarball();
|
||||
expandHermesTarball();
|
||||
copyBuildScripts();
|
||||
|
||||
if (shouldUsePrebuiltHermesC('macos')) {
|
||||
console.log('[Hermes] Using pre-built HermesC');
|
||||
configureMakeForPrebuiltHermesC();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user