hermes-utils: Strip debug symbols during tarball creation (#35162)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35162

The dSYMs for Apple will not be distributed as part of the prebuilts tarball. They can still be included in the tarball by passing a `-d` flag to the create-tarball script.

Changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D40813679

fbshipit-source-id: 26dee8251684c5ecad649ccd27ce688cfe88ec8f
This commit is contained in:
Héctor Ramos
2022-11-01 16:02:21 -07:00
committed by Facebook GitHub Bot
parent dbb9252d28
commit d71d0db51d
2 changed files with 39 additions and 16 deletions
+7
View File
@@ -40,12 +40,18 @@ let argv = yargs
.option('o', {
alias: 'outputDir',
describe: 'Location where the tarball will be saved to.',
})
.option('exclude-debug-symbols', {
describe: 'Whether dSYMs should be excluded from the tarball.',
type: 'boolean',
default: true,
}).argv;
async function main() {
const hermesDir = argv.inputDir;
const buildType = argv.buildType;
const releaseVersion = argv.releaseVersion;
const excludeDebugSymbols = argv.excludeDebugSymbols;
let tarballOutputDir = argv.outputDir;
if (!tarballOutputDir) {
@@ -65,6 +71,7 @@ async function main() {
buildType,
releaseVersion,
tarballOutputDir,
excludeDebugSymbols,
);
console.log(tarballOutputPath);
return tarballOutputPath;
+32 -16
View File
@@ -212,33 +212,28 @@ function createHermesPrebuiltArtifactsTarball(
buildType,
releaseVersion,
tarballOutputDir,
excludeDebugSymbols,
) {
if (!hermesDir) {
hermesDir = HERMES_DIR;
}
if (!fs.existsSync(hermesDir)) {
throw new Error(`Path to Hermes does not exist at ${hermesDir}`);
}
if (!fs.existsSync(path.join(hermesDir, 'destroot'))) {
throw new Error(
`destroot not found at ${path.join(
hermesDir,
'destroot',
)}. Are you sure Hermes has been built?`,
);
}
validateHermesFrameworksExist(path.join(hermesDir, 'destroot'));
if (!fs.existsSync(tarballOutputDir)) {
fs.mkdirSync(tarballOutputDir, {recursive: true});
}
let tarballTempDir;
try {
tarballTempDir = fs.mkdtempSync(
path.join(os.tmpdir(), 'hermes-engine-destroot-'),
);
execSync(`cp -R ./destroot ${tarballTempDir}`, {cwd: hermesDir});
let args = ['-a'];
if (excludeDebugSymbols) {
args.push('--exclude=dSYMs/');
args.push('--exclude=*.dSYM/');
}
execSync(`rsync ${args.join(' ')} ./destroot ${tarballTempDir}`, {
cwd: hermesDir,
});
if (fs.existsSync(path.join(hermesDir, 'LICENSE'))) {
execSync(`cp LICENSE ${tarballTempDir}`, {cwd: hermesDir});
}
@@ -267,6 +262,27 @@ function createHermesPrebuiltArtifactsTarball(
return tarballOutputPath;
}
function validateHermesFrameworksExist(destrootDir) {
if (
!fs.existsSync(
path.join(destrootDir, 'Library/Frameworks/macosx/hermes.framework'),
)
) {
throw new Error(
'Error: Hermes macOS Framework not found. Are you sure Hermes has been built?',
);
}
if (
!fs.existsSync(
path.join(destrootDir, 'Library/Frameworks/universal/hermes.xcframework'),
)
) {
throw new Error(
'Error: Hermes iOS XCFramework not found. Are you sure Hermes has been built?',
);
}
}
module.exports = {
configureMakeForPrebuiltHermesC,
copyBuildScripts,