Skip to content

Commit d71d0db

Browse files
hramosfacebook-github-bot
authored andcommitted
hermes-utils: Strip debug symbols during tarball creation (#35162)
Summary: Pull Request resolved: #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
1 parent dbb9252 commit d71d0db

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

scripts/hermes/create-tarball.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ let argv = yargs
4040
.option('o', {
4141
alias: 'outputDir',
4242
describe: 'Location where the tarball will be saved to.',
43+
})
44+
.option('exclude-debug-symbols', {
45+
describe: 'Whether dSYMs should be excluded from the tarball.',
46+
type: 'boolean',
47+
default: true,
4348
}).argv;
4449

4550
async function main() {
4651
const hermesDir = argv.inputDir;
4752
const buildType = argv.buildType;
4853
const releaseVersion = argv.releaseVersion;
54+
const excludeDebugSymbols = argv.excludeDebugSymbols;
4955
let tarballOutputDir = argv.outputDir;
5056

5157
if (!tarballOutputDir) {
@@ -65,6 +71,7 @@ async function main() {
6571
buildType,
6672
releaseVersion,
6773
tarballOutputDir,
74+
excludeDebugSymbols,
6875
);
6976
console.log(tarballOutputPath);
7077
return tarballOutputPath;

scripts/hermes/hermes-utils.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -212,33 +212,28 @@ function createHermesPrebuiltArtifactsTarball(
212212
buildType,
213213
releaseVersion,
214214
tarballOutputDir,
215+
excludeDebugSymbols,
215216
) {
216-
if (!hermesDir) {
217-
hermesDir = HERMES_DIR;
218-
}
219-
if (!fs.existsSync(hermesDir)) {
220-
throw new Error(`Path to Hermes does not exist at ${hermesDir}`);
221-
}
222-
if (!fs.existsSync(path.join(hermesDir, 'destroot'))) {
223-
throw new Error(
224-
`destroot not found at ${path.join(
225-
hermesDir,
226-
'destroot',
227-
)}. Are you sure Hermes has been built?`,
228-
);
229-
}
217+
validateHermesFrameworksExist(path.join(hermesDir, 'destroot'));
218+
230219
if (!fs.existsSync(tarballOutputDir)) {
231220
fs.mkdirSync(tarballOutputDir, {recursive: true});
232221
}
233222

234223
let tarballTempDir;
235-
236224
try {
237225
tarballTempDir = fs.mkdtempSync(
238226
path.join(os.tmpdir(), 'hermes-engine-destroot-'),
239227
);
240228

241-
execSync(`cp -R ./destroot ${tarballTempDir}`, {cwd: hermesDir});
229+
let args = ['-a'];
230+
if (excludeDebugSymbols) {
231+
args.push('--exclude=dSYMs/');
232+
args.push('--exclude=*.dSYM/');
233+
}
234+
execSync(`rsync ${args.join(' ')} ./destroot ${tarballTempDir}`, {
235+
cwd: hermesDir,
236+
});
242237
if (fs.existsSync(path.join(hermesDir, 'LICENSE'))) {
243238
execSync(`cp LICENSE ${tarballTempDir}`, {cwd: hermesDir});
244239
}
@@ -267,6 +262,27 @@ function createHermesPrebuiltArtifactsTarball(
267262
return tarballOutputPath;
268263
}
269264

265+
function validateHermesFrameworksExist(destrootDir) {
266+
if (
267+
!fs.existsSync(
268+
path.join(destrootDir, 'Library/Frameworks/macosx/hermes.framework'),
269+
)
270+
) {
271+
throw new Error(
272+
'Error: Hermes macOS Framework not found. Are you sure Hermes has been built?',
273+
);
274+
}
275+
if (
276+
!fs.existsSync(
277+
path.join(destrootDir, 'Library/Frameworks/universal/hermes.xcframework'),
278+
)
279+
) {
280+
throw new Error(
281+
'Error: Hermes iOS XCFramework not found. Are you sure Hermes has been built?',
282+
);
283+
}
284+
}
285+
270286
module.exports = {
271287
configureMakeForPrebuiltHermesC,
272288
copyBuildScripts,

0 commit comments

Comments
 (0)