Build server release for Mac AARCH64

Reviewed By: lblasa

Differential Revision: D46144878

fbshipit-source-id: 1aa2982fc99e5dc6cdfbe4d9fcf87f7fc55a1abe
This commit is contained in:
Pascal Hartig
2023-05-24 10:48:00 -07:00
committed by Facebook GitHub Bot
parent 9b448b2864
commit 558316153c

View File

@@ -40,6 +40,7 @@ enum BuildPlatform {
LINUX = 'linux',
WINDOWS = 'windows',
MAC_X64 = 'mac-x64',
MAC_AARCH64 = 'mac-aarch64',
}
const LINUX_STARTUP_SCRIPT = `#!/bin/sh
@@ -433,21 +434,23 @@ async function buildServerRelease() {
if (argv.linux) {
platforms.push(BuildPlatform.LINUX);
}
// TODO: In the future, also cover aarch64 here.
if (argv.mac) {
platforms.push(BuildPlatform.MAC_X64);
platforms.push(BuildPlatform.MAC_AARCH64);
}
if (argv.win) {
platforms.push(BuildPlatform.WINDOWS);
}
platforms.forEach(
bundleServerReleaseForPlatform.bind(null, dir, versionNumber),
);
for (const platform of platforms) {
await bundleServerReleaseForPlatform(dir, versionNumber, platform);
}
}
function nodeArchFromBuildPlatform(_platform: BuildPlatform): string {
// TODO: Change this as we support aarch64.
function nodeArchFromBuildPlatform(platform: BuildPlatform): string {
if (platform === BuildPlatform.MAC_AARCH64) {
return 'arm64';
}
return 'x64';
}
@@ -456,6 +459,7 @@ function nodePlatformFromBuildPlatform(platform: BuildPlatform): string {
case BuildPlatform.LINUX:
return 'linux';
case BuildPlatform.MAC_X64:
case BuildPlatform.MAC_AARCH64:
return 'macos';
case BuildPlatform.WINDOWS:
return 'win32';
@@ -465,11 +469,13 @@ function nodePlatformFromBuildPlatform(platform: BuildPlatform): string {
}
async function installNodeBinary(outputPath: string, platform: BuildPlatform) {
console.log(`⚙️ Downloading node version for ${platform} using pkg-fetch`);
const path = await pkgFetch({
arch: nodeArchFromBuildPlatform(platform),
platform: nodePlatformFromBuildPlatform(platform),
nodeRange: SUPPORTED_NODE_PLATFORM,
});
console.log(`⚙️ Copying node binary from ${path} to ${outputPath}`);
await fs.copyFile(path, outputPath);
// Set +x on the binary as copyFile doesn't maintain the bit.
await fs.chmod(outputPath, 0o755);
@@ -539,7 +545,10 @@ async function bundleServerReleaseForPlatform(
// On the mac, we need to set up a resource bundle which expects paths
// to be in different places from Linux/Windows bundles.
if (platform === BuildPlatform.MAC_X64) {
if (
platform === BuildPlatform.MAC_X64 ||
platform === BuildPlatform.MAC_AARCH64
) {
outputPaths = await setUpMacBundle(outputDir, versionNumber);
} else if (platform === BuildPlatform.LINUX) {
await setUpLinuxBundle(outputDir);