Skip to content

Commit 4fad965

Browse files
hramosfacebook-github-bot
authored andcommitted
Hermes scripts: rename tarball methods to distinguish between source code and prebuilt artifacts
Summary: There are two tarballs: the source code for Hermes that is downloaded from GitHub, and the hermes-runtime-darwin-{}-v{}.tar.gz tarball with prebuilt artifacts that is built in CI. Renamed some methods to make it clearer which tarball they work with. Changelog: [internal] Reviewed By: cipolleschi, dmytrorykun Differential Revision: D40812290 fbshipit-source-id: 68ffef9005cb96dd2fb847c64a45460005535fd7
1 parent 76c7cca commit 4fad965

File tree

5 files changed

+46
-39
lines changed

5 files changed

+46
-39
lines changed

scripts/__tests__/hermes-utils-test.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const {
1313
configureMakeForPrebuiltHermesC,
1414
copyBuildScripts,
1515
copyPodSpec,
16-
downloadHermesTarball,
17-
expandHermesTarball,
18-
getHermesTarballName,
16+
downloadHermesSourceTarball,
17+
expandHermesSourceTarball,
18+
getHermesPrebuiltArtifactsTarballName,
1919
getHermesTagSHA,
2020
readHermesTag,
2121
setHermesTag,
@@ -155,29 +155,29 @@ describe('hermes-utils', () => {
155155
expect(readHermesTag()).toEqual(hermesTag);
156156
});
157157
});
158-
describe('getHermesTarballName', () => {
158+
describe('getHermesPrebuiltArtifactsTarballName', () => {
159159
it('should return Hermes tarball name', () => {
160-
expect(getHermesTarballName('Debug', '1000.0.0')).toEqual(
161-
'hermes-runtime-darwin-debug-v1000.0.0.tar.gz',
162-
);
160+
expect(
161+
getHermesPrebuiltArtifactsTarballName('Debug', '1000.0.0'),
162+
).toEqual('hermes-runtime-darwin-debug-v1000.0.0.tar.gz');
163163
});
164164
it('should throw if build type is undefined', () => {
165165
expect(() => {
166-
getHermesTarballName();
166+
getHermesPrebuiltArtifactsTarballName();
167167
}).toThrow('Did not specify build type.');
168168
});
169169
it('should throw if release version is undefined', () => {
170170
expect(() => {
171-
getHermesTarballName('Release');
171+
getHermesPrebuiltArtifactsTarballName('Release');
172172
}).toThrow('Did not specify release version.');
173173
});
174174
it('should return debug Hermes tarball name for RN 0.70.0', () => {
175-
expect(getHermesTarballName('Debug', '0.70.0')).toEqual(
175+
expect(getHermesPrebuiltArtifactsTarballName('Debug', '0.70.0')).toEqual(
176176
'hermes-runtime-darwin-debug-v0.70.0.tar.gz',
177177
);
178178
});
179179
it('should return a wildcard Hermes tarball name for any RN version', () => {
180-
expect(getHermesTarballName('Debug', '*')).toEqual(
180+
expect(getHermesPrebuiltArtifactsTarballName('Debug', '*')).toEqual(
181181
'hermes-runtime-darwin-debug-v*.tar.gz',
182182
);
183183
});
@@ -188,10 +188,10 @@ describe('hermes-utils', () => {
188188
expect(execCalls.git).toBe(true);
189189
});
190190
});
191-
describe('downloadHermesTarball', () => {
192-
it('should download Hermes tarball to download dir', () => {
191+
describe('downloadHermesSourceTarball', () => {
192+
it('should download Hermes source tarball to download dir', () => {
193193
fs.writeFileSync(path.join(SDKS_DIR, '.hermesversion'), hermesTag);
194-
downloadHermesTarball();
194+
downloadHermesSourceTarball();
195195
expect(execCalls.curl).toBe(true);
196196
expect(
197197
fs.readFileSync(
@@ -210,25 +210,25 @@ describe('hermes-utils', () => {
210210
tarballContents,
211211
);
212212

213-
downloadHermesTarball();
213+
downloadHermesSourceTarball();
214214
expect(execCalls.curl).toBeUndefined();
215215
});
216216
});
217-
describe('expandHermesTarball', () => {
218-
it('should expand Hermes tarball to Hermes source dir', () => {
217+
describe('expandHermesSourceTarball', () => {
218+
it('should expand Hermes source tarball to Hermes source dir', () => {
219219
fs.mkdirSync(path.join(SDKS_DIR, 'download'), {recursive: true});
220220
fs.writeFileSync(
221221
path.join(SDKS_DIR, 'download', `hermes-${hermesTagSha}.tgz`),
222222
tarballContents,
223223
);
224224
expect(fs.existsSync(path.join(SDKS_DIR, 'hermes'))).toBeFalsy();
225-
expandHermesTarball();
225+
expandHermesSourceTarball();
226226
expect(execCalls.tar).toBe(true);
227227
expect(fs.existsSync(path.join(SDKS_DIR, 'hermes'))).toBe(true);
228228
});
229-
it('should fail if Hermes tarball does not exist', () => {
229+
it('should fail if Hermes source tarball does not exist', () => {
230230
expect(() => {
231-
expandHermesTarball();
231+
expandHermesSourceTarball();
232232
}).toThrow('[Hermes] Could not locate Hermes tarball.');
233233
expect(execCalls.tar).toBeUndefined();
234234
});

scripts/hermes/create-tarball.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const path = require('path');
1818
* Must be invoked after Hermes has been built.
1919
*/
2020
const yargs = require('yargs');
21-
const {createHermesTarball} = require('./hermes-utils');
21+
const {createHermesPrebuiltArtifactsTarball} = require('./hermes-utils');
2222

2323
let argv = yargs
2424
.option('i', {
@@ -60,7 +60,7 @@ async function main() {
6060
}
6161
}
6262

63-
const tarballOutputPath = createHermesTarball(
63+
const tarballOutputPath = createHermesPrebuiltArtifactsTarball(
6464
hermesDir,
6565
buildType,
6666
releaseVersion,

scripts/hermes/get-tarball-name.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Hermes tarball for the given build type and release version.
1515
*/
1616
const yargs = require('yargs');
17-
const {getHermesTarballName} = require('./hermes-utils');
17+
const {getHermesPrebuiltArtifactsTarballName} = require('./hermes-utils');
1818

1919
let argv = yargs
2020
.option('b', {
@@ -31,7 +31,10 @@ let argv = yargs
3131
}).argv;
3232

3333
async function main() {
34-
const tarballName = getHermesTarballName(argv.buildType, argv.releaseVersion);
34+
const tarballName = getHermesPrebuiltArtifactsTarballName(
35+
argv.buildType,
36+
argv.releaseVersion,
37+
);
3538
console.log(tarballName);
3639
return tarballName;
3740
}

scripts/hermes/hermes-utils.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const {execSync} = require('child_process');
1717
const SDKS_DIR = path.normalize(path.join(__dirname, '..', '..', 'sdks'));
1818
const HERMES_DIR = path.join(SDKS_DIR, 'hermes');
1919
const HERMES_TAG_FILE_PATH = path.join(SDKS_DIR, '.hermesversion');
20-
const HERMES_TARBALL_BASE_URL = 'https://github.com/facebook/hermes/tarball/';
20+
const HERMES_SOURCE_TARBALL_BASE_URL =
21+
'https://github.com/facebook/hermes/tarball/';
2122
const HERMES_TARBALL_DOWNLOAD_DIR = path.join(SDKS_DIR, 'download');
2223
const MACOS_BIN_DIR = path.join(SDKS_DIR, 'hermesc', 'osx-bin');
2324
const MACOS_HERMESC_PATH = path.join(MACOS_BIN_DIR, 'hermesc');
@@ -71,11 +72,11 @@ function getHermesTarballDownloadPath(hermesTag) {
7172
return path.join(HERMES_TARBALL_DOWNLOAD_DIR, `hermes-${hermesTagSHA}.tgz`);
7273
}
7374

74-
function downloadHermesTarball() {
75+
function downloadHermesSourceTarball() {
7576
const hermesTag = readHermesTag();
7677
const hermesTagSHA = getHermesTagSHA(hermesTag);
7778
const hermesTarballDownloadPath = getHermesTarballDownloadPath(hermesTag);
78-
let hermesTarballUrl = HERMES_TARBALL_BASE_URL + hermesTag;
79+
let hermesTarballUrl = HERMES_SOURCE_TARBALL_BASE_URL + hermesTag;
7980

8081
if (fs.existsSync(hermesTarballDownloadPath)) {
8182
return;
@@ -95,7 +96,7 @@ function downloadHermesTarball() {
9596
}
9697
}
9798

98-
function expandHermesTarball() {
99+
function expandHermesSourceTarball() {
99100
const hermesTag = readHermesTag();
100101
const hermesTagSHA = getHermesTagSHA(hermesTag);
101102
const hermesTarballDownloadPath = getHermesTarballDownloadPath(hermesTag);
@@ -196,7 +197,7 @@ set_target_properties(native-hermesc PROPERTIES
196197
}
197198
}
198199

199-
function getHermesTarballName(buildType, releaseVersion) {
200+
function getHermesPrebuiltArtifactsTarballName(buildType, releaseVersion) {
200201
if (!buildType) {
201202
throw Error('Did not specify build type.');
202203
}
@@ -206,7 +207,7 @@ function getHermesTarballName(buildType, releaseVersion) {
206207
return `hermes-runtime-darwin-${buildType.toLowerCase()}-v${releaseVersion}.tar.gz`;
207208
}
208209

209-
function createHermesTarball(
210+
function createHermesPrebuiltArtifactsTarball(
210211
hermesDir,
211212
buildType,
212213
releaseVersion,
@@ -245,7 +246,10 @@ function createHermesTarball(
245246
throw new Error(`Failed to copy destroot to tempdir: ${error}`);
246247
}
247248

248-
const tarballFilename = getHermesTarballName(buildType, releaseVersion);
249+
const tarballFilename = getHermesPrebuiltArtifactsTarballName(
250+
buildType,
251+
releaseVersion,
252+
);
249253
const tarballOutputPath = path.join(tarballOutputDir, tarballFilename);
250254

251255
try {
@@ -267,11 +271,11 @@ module.exports = {
267271
configureMakeForPrebuiltHermesC,
268272
copyBuildScripts,
269273
copyPodSpec,
270-
createHermesTarball,
271-
downloadHermesTarball,
272-
expandHermesTarball,
274+
createHermesPrebuiltArtifactsTarball,
275+
downloadHermesSourceTarball,
276+
expandHermesSourceTarball,
273277
getHermesTagSHA,
274-
getHermesTarballName,
278+
getHermesPrebuiltArtifactsTarballName,
275279
readHermesTag,
276280
setHermesTag,
277281
shouldBuildHermesFromSource,

scripts/hermes/prepare-hermes-for-build.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const {
1717
configureMakeForPrebuiltHermesC,
1818
copyBuildScripts,
1919
copyPodSpec,
20-
downloadHermesTarball,
21-
expandHermesTarball,
20+
downloadHermesSourceTarball,
21+
expandHermesSourceTarball,
2222
shouldUsePrebuiltHermesC,
2323
shouldBuildHermesFromSource,
2424
} = require('./hermes-utils');
@@ -28,8 +28,8 @@ async function main(isInCI) {
2828
copyPodSpec();
2929
return;
3030
}
31-
downloadHermesTarball();
32-
expandHermesTarball();
31+
downloadHermesSourceTarball();
32+
expandHermesSourceTarball();
3333
copyPodSpec();
3434
copyBuildScripts();
3535

0 commit comments

Comments
 (0)