Skip to content

Commit f7d6f16

Browse files
committed
Build ARM64 server releases
1 parent d459dbc commit f7d6f16

File tree

2 files changed

+41
-16
lines changed

2 files changed

+41
-16
lines changed

build-release.sh

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ set -e
1010
# ------------------------------------------------------------------------
1111

1212
TARGET_PLATFORM=$1
13+
TARGET_ARCH=$2
1314

14-
echo "CONFIGURING FOR $TARGET_PLATFORM"
15+
echo "CONFIGURING FOR $TARGET_PLATFORM $TARGET_ARCH"
1516

1617
if [ -z "$TARGET_PLATFORM" ]; then
1718
echo 'A target platform (linux/win32/darwin) is required'
1819
exit 1
1920
fi
2021

21-
TARGET_ARCH=`node -e 'console.log(process.arch)'`
22+
if [ -z "$TARGET_ARCH" ]; then
23+
echo 'A target platform (x64/arm/arm64) is required'
24+
exit 1
25+
fi
26+
2227

2328
export PATH=./node_modules/.bin:$PATH
2429

@@ -27,6 +32,10 @@ export npm_config_platform=$TARGET_PLATFORM
2732
# Pick the target platform for node-pre-gyp:
2833
export npm_config_target_platform=$TARGET_PLATFORM
2934

35+
# Same for architecture:
36+
export npm_config_arch=$TARGET_ARCH
37+
export npm_config_target_arch=$TARGET_ARCH
38+
3039
# Disable node-gyp-build for win-version-info only. Without this, it's
3140
# rebuilt for Linux, even given $TARGET_PLATFORM=win32, and then breaks
3241
# at runtime even though there are valid win32 prebuilds available.
@@ -45,7 +54,7 @@ rm -rf ./tmp || true
4554
# ------------------------------------------------------------------------
4655

4756
echo
48-
echo "BUILDING FOR $TARGET_PLATFORM"
57+
echo "BUILDING FOR $TARGET_PLATFORM $TARGET_ARCH"
4958
echo
5059

5160
oclif-dev pack --targets=$TARGET
@@ -62,22 +71,35 @@ echo
6271
# Whitelist (as a regex) for packages that may include binaries for other platforms
6372
PACKAGE_WHITELIST=''
6473

74+
case "$TARGET_ARCH" in
75+
x64)
76+
EXPECTED_ARCH_STRING='x86[_-]64|80386'
77+
;;
78+
arm64)
79+
EXPECTED_ARCH_STRING='arm64'
80+
;;
81+
*)
82+
echo "Unknown arch $TARGET_ARCH"
83+
exit 1
84+
;;
85+
esac
86+
6587
case "$TARGET_PLATFORM" in
6688
linux)
67-
EXPECTED_BIN_STRING="ELF"
89+
EXPECTED_PLATFORM_STRING='ELF'
6890
# Registry-js builds raw on non-Windows, but never used
6991
# Win-version info includes prebuilds for Windows on all platforms
70-
PACKAGE_WHITELIST="registry-js|win-version-info/prebuilds"
92+
PACKAGE_WHITELIST='registry-js|win-version-info/prebuilds'
7193
;;
7294
win32)
73-
EXPECTED_BIN_STRING="MS Windows"
74-
PACKAGE_WHITELIST=""
95+
EXPECTED_PLATFORM_STRING='MS Windows'
96+
PACKAGE_WHITELIST=''
7597
;;
7698
darwin)
77-
EXPECTED_BIN_STRING="Mach-O"
99+
EXPECTED_PLATFORM_STRING='Mach-O'
78100
# Registry-js builds raw on non-Windows, but never used
79101
# Win-version info includes prebuilds for Windows on all platforms
80-
PACKAGE_WHITELIST="registry-js|win-version-info/prebuilds"
102+
PACKAGE_WHITELIST='registry-js|win-version-info/prebuilds'
81103
;;
82104
*)
83105
echo "Unknown platform $TARGET_PLATFORM"
@@ -86,7 +108,7 @@ case "$TARGET_PLATFORM" in
86108
esac
87109

88110
echo "CHECKING FOR BAD CONFIG"
89-
echo "EXPECTING: $EXPECTED_BIN_STRING"
111+
echo "EXPECTING: $EXPECTED_PLATFORM_STRING and $EXPECTED_ARCH_STRING"
90112
echo "WHITELIST: $PACKAGE_WHITELIST"
91113

92114
# Find all *.node files in the build that `file` doesn't describe with the above
@@ -98,7 +120,7 @@ NATIVE_BINARIES=$(
98120
)
99121
echo "NATIVE BINS: $NATIVE_BINARIES"
100122

101-
BAD_BINS=$(echo "$NATIVE_BINARIES" | grep -v "$EXPECTED_BIN_STRING" || true)
123+
BAD_BINS=$(echo "$NATIVE_BINARIES" | grep -vE "$EXPECTED_PLATFORM_STRING" | grep -vE "$EXPECTED_ARCH_STRING" || true)
102124

103125
if [[ ! -z "$PACKAGE_WHITELIST" ]]; then
104126
BAD_BINS=$(echo "$BAD_BINS" | grep -E -v "$PACKAGE_WHITELIST" || true)
@@ -108,7 +130,7 @@ if [ `echo "$BAD_BINS" | wc -w` -ne 0 ]; then
108130
echo
109131
echo "***** BUILD FAILED *****"
110132
echo
111-
echo "Invalid build! $TARGET_PLATFORM build has binaries for the wrong platform."
133+
echo "Invalid build! $TARGET build has binaries for the wrong platform."
112134
echo "Bad binaries are:"
113135
echo "$BAD_BINS"
114136
echo

pack.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,20 @@ const packageApp = async () => {
8282
console.log('Building for Linux');
8383
await fs.mkdir(path.join(OUTPUT_DIR, 'nss'));
8484
await fs.copy(path.join(__dirname, 'nss', 'linux'), path.join(OUTPUT_DIR, 'nss', 'linux'));
85-
await spawn(buildScript, ['linux'], { cwd: OUTPUT_DIR, stdio: 'inherit' });
85+
await spawn(buildScript, ['linux', 'x64'], { cwd: OUTPUT_DIR, stdio: 'inherit' });
8686

87-
console.log('Building for Darwin');
87+
console.log('Building for Darwin x64');
8888
await fs.remove(path.join(OUTPUT_DIR, 'nss', 'linux'));
8989
await fs.copy(path.join(__dirname, 'nss', 'darwin'), path.join(OUTPUT_DIR, 'nss', 'darwin'));
90-
await spawn(buildScript, ['darwin'], { cwd: OUTPUT_DIR, stdio: 'inherit' });
90+
await spawn(buildScript, ['darwin', 'x64'], { cwd: OUTPUT_DIR, stdio: 'inherit' });
91+
92+
console.log('Building for Darwin arm64');
93+
await spawn(buildScript, ['darwin', 'arm64'], { cwd: OUTPUT_DIR, stdio: 'inherit' });
9194

9295
console.log('Building for Win32');
9396
await fs.remove(path.join(OUTPUT_DIR, 'nss', 'darwin'));
9497
await fs.copy(path.join(__dirname, 'nss', 'win32'), path.join(OUTPUT_DIR, 'nss', 'win32'));
95-
await spawn(buildScript, ['win32'], { cwd: OUTPUT_DIR, stdio: 'inherit' });
98+
await spawn(buildScript, ['win32', 'x64'], { cwd: OUTPUT_DIR, stdio: 'inherit' });
9699

97100
// Oclif builds a nodeless platform-agnostic bundle too (although in our case, nothing is
98101
// really platform agnostic). Not necessary, probably won't work - drop it.

0 commit comments

Comments
 (0)