Skip to content

Commit 7d62e76

Browse files
Add build-local.sh and stage_for_s3.bash scripts from v22.21.1
Updated build-local.sh for v24: - Added --v8-disable-maglev flag to configure (required for fibers) - Updated comments to reference Node24 Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
1 parent f2d58cb commit 7d62e76

2 files changed

Lines changed: 192 additions & 0 deletions

File tree

build-local.sh

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Build Node.js with fibers and native packages locally
5+
# Combines: Dockerfile.Node24, Dockerfile.Fibers, Dockerfile.Packages
6+
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
OUTPUT_DIR="${SCRIPT_DIR}/local-build-output"
9+
NODE_INSTALL_DIR="${OUTPUT_DIR}/node"
10+
FIBERS_DIR="${OUTPUT_DIR}/node-fibers"
11+
PACKAGES_DIR="${OUTPUT_DIR}/packages"
12+
13+
# Number of parallel jobs for make
14+
JOBS=${JOBS:-$(sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4)}
15+
16+
echo "=== Local Node.js + Fibers Build Script ==="
17+
echo "Output directory: ${OUTPUT_DIR}"
18+
echo "Parallel jobs: ${JOBS}"
19+
echo ""
20+
21+
# Clean previous output
22+
rm -rf "${OUTPUT_DIR}"
23+
mkdir -p "${OUTPUT_DIR}"
24+
25+
# ============================================
26+
# Stage 1: Build Node.js (Dockerfile.Node24)
27+
# ============================================
28+
echo "=== Stage 1: Building Node.js ==="
29+
30+
cd "${SCRIPT_DIR}"
31+
32+
# Configure if needed
33+
if [ ! -f config.gypi ] || [ ! -f config.mk ]; then
34+
echo "Configuring Node.js with pointer compression and maglev disabled..."
35+
./configure --experimental-enable-pointer-compression --v8-disable-maglev
36+
fi
37+
38+
# Build Node.js
39+
echo "Building Node.js (this may take a while)..."
40+
make -j${JOBS}
41+
42+
# Install to local directory
43+
echo "Installing Node.js to ${NODE_INSTALL_DIR}..."
44+
make install DESTDIR="${NODE_INSTALL_DIR}" PREFIX=""
45+
46+
# Verify installation
47+
NODE_BIN="${NODE_INSTALL_DIR}/bin/node"
48+
NPM_BIN="${NODE_INSTALL_DIR}/bin/npm"
49+
50+
echo "Verifying Node.js installation..."
51+
"${NODE_BIN}" --version
52+
"${NODE_BIN}" -p "process.arch"
53+
echo "Node module version: $("${NODE_BIN}" -p "process.versions.modules")"
54+
55+
# IMPORTANT: Put our custom Node first in PATH so npm/node-gyp use it for native builds
56+
export PATH="${NODE_INSTALL_DIR}/bin:${PATH}"
57+
echo "Using node from: $(which node)"
58+
59+
# ============================================
60+
# Stage 2: Build node-fibers (Dockerfile.Fibers)
61+
# ============================================
62+
echo ""
63+
echo "=== Stage 2: Building node-fibers ==="
64+
65+
mkdir -p "${FIBERS_DIR}"
66+
cd "${FIBERS_DIR}"
67+
68+
# Clone node-fibers if not already present
69+
if [ ! -d "node-fibers" ]; then
70+
echo "Cloning node-fibers..."
71+
git clone --branch jackstrohm_node20_fibers --depth 1 https://github.com/asana/node-fibers.git node-fibers
72+
fi
73+
74+
cd node-fibers
75+
76+
echo "Building node-fibers..."
77+
"${NPM_BIN}" install --nodedir="${NODE_INSTALL_DIR}"
78+
79+
echo "Running node-fibers tests (failures allowed)..."
80+
"${NPM_BIN}" test || true
81+
82+
# Remove repl as in Dockerfile
83+
rm -f bin/repl
84+
85+
echo "node-fibers built successfully"
86+
87+
# ============================================
88+
# Stage 3: Build native packages (Dockerfile.Packages)
89+
# ============================================
90+
echo ""
91+
echo "=== Stage 3: Building native packages ==="
92+
93+
mkdir -p "${PACKAGES_DIR}"
94+
cd "${PACKAGES_DIR}"
95+
96+
# Initialize a package.json if needed
97+
if [ ! -f package.json ]; then
98+
echo '{"name": "native-packages", "private": true}' > package.json
99+
fi
100+
101+
echo "Installing bcrypt@5.1.0..."
102+
"${NPM_BIN}" install --nodedir="${NODE_INSTALL_DIR}" bcrypt@5.1.0
103+
104+
echo "Installing cld@2.9.1..."
105+
"${NPM_BIN}" install --nodedir="${NODE_INSTALL_DIR}" cld@2.9.1
106+
107+
echo "Installing unix-dgram@2.0.6..."
108+
"${NPM_BIN}" install --nodedir="${NODE_INSTALL_DIR}" unix-dgram@2.0.6
109+
110+
# ============================================
111+
# Summary
112+
# ============================================
113+
echo ""
114+
echo "=== Build Complete ==="
115+
echo ""
116+
echo "Output directory structure:"
117+
echo " ${OUTPUT_DIR}/"
118+
echo " ├── node/ # Node.js installation"
119+
echo " │ ├── bin/node"
120+
echo " │ ├── bin/npm"
121+
echo " │ └── ..."
122+
echo " ├── node-fibers/ # node-fibers addon"
123+
echo " │ └── node-fibers/"
124+
echo " └── packages/ # Native packages (bcrypt, cld, unix-dgram)"
125+
echo " └── node_modules/"
126+
echo ""
127+
echo "To use this Node.js:"
128+
echo " export PATH=\"${NODE_INSTALL_DIR}/bin:\$PATH\""
129+
echo " node --version"
130+
echo ""
131+
echo "To test fibers:"
132+
echo " cd ${FIBERS_DIR}/node-fibers && ${NODE_BIN} test.js"

stage_for_s3.bash

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
mkdir stage
6+
cd stage || exit
7+
8+
TIMESTAMP=$(date '+%Y%m%d.%H%M')
9+
10+
echo "Current timestamp is $TIMESTAMP"
11+
12+
# Download node tarballs from the latest release
13+
gh release download -R Asana/node -p "*.xz"
14+
15+
# Generate unique identifier from timestamp and hash of downloaded files
16+
SHORT_HASH=$(cat *.xz | sha1sum | cut -c1-4)
17+
echo "HASH: $SHORT_HASH"
18+
UNIQUE="pc-${TIMESTAMP}-${SHORT_HASH}"
19+
20+
for file in *.tar.xz; do
21+
if [[ "$file" == *-LATEST.tar.xz ]]; then
22+
base="${file%-LATEST.tar.xz}"
23+
new_name="${base}-${UNIQUE}.tar.xz"
24+
25+
echo "Renaming: $file -> $new_name"
26+
mv "$file" "$new_name"
27+
28+
if [[ "$new_name" =~ node-v([0-9.]+)-(darwin|linux)-(arm64|x64).*\.tar\.xz$ ]]; then
29+
version="${BASH_REMATCH[1]}"
30+
os="${BASH_REMATCH[2]}"
31+
arch="${BASH_REMATCH[3]}"
32+
target_dir="node-v${version}-${os}-${arch}"
33+
34+
echo "Target Dir: $target_dir"
35+
mkdir "$target_dir"
36+
tar -xJf "$new_name" -C "$target_dir"
37+
38+
# Flatten directory structure if needed (handle both usr/local and direct layouts)
39+
if [ -d "$target_dir/usr/local" ]; then
40+
mv $target_dir/usr/local/* "$target_dir"
41+
rm -rf "$target_dir/usr"
42+
fi
43+
44+
tar -cJf "$new_name" "$target_dir"
45+
46+
rm -rf "$target_dir"
47+
48+
echo "Done: Archive now contains:"
49+
tar -tf "$new_name" | head
50+
51+
else
52+
echo "Warning: Skipped $new_name due to unexpected filename format."
53+
fi
54+
fi
55+
done
56+
57+
cd ..
58+
mv stage "node-${UNIQUE}"
59+
60+
echo "Files are in node-${UNIQUE}, please upload to s3"

0 commit comments

Comments
 (0)