[docker] Prepare for macOS releases

This commit is contained in:
Jarred Sumner
2022-07-24 22:21:07 -07:00
parent 3ae3cdaa64
commit dd0dafbeec
4 changed files with 89 additions and 16 deletions

View File

@@ -71,6 +71,78 @@ jobs:
with:
name: ${{ matrix.label }}
path: ${{runner.temp}}/release/bun.o
macOS:
name: macOS
runs-on: ${{ matrix.runner }}
# needs: macos-object-files
timeout-minutes: 90
strategy:
matrix:
include:
- cpu: sandybridge
arch: x86_64
label: bun-darwin-x64-baseline
obj: bun-obj-darwin-x64-baseline
runner: macos-11
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/latest/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: skylake
arch: x86_64
label: bun-darwin-x64
obj: bun-obj-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/latest/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: apple_m1
arch: aarch64
label: bun-darwin-aarch64
obj: bun-obj-darwin-aarch64
artifact: bun-obj-darwin-aarch64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/latest/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: git -c submodule."src/bun.js/WebKit".update=none submodule update --init --recursive --depth=1 --progress -j $(nproc)
- name: Install dependencies
run: |
brew install llvm@13 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild go
echo "export PATH=$(brew --prefix coreutils)/libexec/gnubin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@13
- name: Download WebKit
run: |
curl -L ${{ matrix.webkit_url }} | tar -xz -C ${{ runner.temp }}/bun-webkit --strip-components=1
- name: Compile dependencies
run: |
make vendor-without-check
- name: Compile C++
run: |
make -j $(nproc) jsc-bindings-mac
# - name: Download Artifact
# uses: actions/download-artifact@v3
# with:
# name: ${{ matrix.artifact }}
# path: ${{ runner.temp }}/release
- name: Link
run: make bun-link-lld-release
- name: dSYM
run: |
make bun-link-lld-release-dsym
- name: Copy release
run: |
mkdir -p $BUN_DEPLOY_DIR
make release-bin-generate-copy
- name: Upload release
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.label }}
path: $BUN_DEPLOY_DIR
linux-x64:
name: Linux x64 (${{ matrix.cpu }})
runs-on: linux-amd64
@@ -212,6 +284,7 @@ jobs:
needs:
- linux-x64
- linux-aarch64
- macOS
steps:
- uses: actions/download-artifact@v3
with:

View File

@@ -393,7 +393,7 @@ ARG BUN_BASE_VERSION=0.1
RUN cd $BUN_DIR && mkdir -p src/bun.js/bindings-obj && rm -rf $HOME/.cache zig-cache && make prerelease && \
mkdir -p $BUN_RELEASE_DIR && \
OUTPUT_DIR=/tmp $ZIG_PATH/zig build obj -Drelease-fast -Dtarget="${TRIPLET}" -Dcpu="${CPU_TARGET}" && \
cp /tmp/bun.o /tmp/bun.${BUN_BASE_VERSION}.$(cat ${BUN_DIR}/build-id).o
cp /tmp/bun.o /tmp/bun-${BUN_BASE_VERSION}.$(cat ${BUN_DIR}/build-id).o
FROM scratch as build_release_obj

View File

@@ -55,6 +55,7 @@ WEBKIT_RELEASE_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Release
WEBKIT_DEBUG_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Debug
WEBKIT_RELEASE_DIR_LTO ?= $(WEBKIT_DIR)/WebKitBuild/ReleaseLTO
NPM_CLIENT ?= $(shell which bun || which npm)
ZIG ?= $(shell which zig || echo -e "error: Missing zig. Please make sure zig is in PATH. Or set ZIG=/path/to-zig-executable")
@@ -129,8 +130,6 @@ OPTIMIZATION_LEVEL=-O3 $(MARCH_NATIVE)
CFLAGS = $(MACOS_MIN_FLAG) $(MARCH_NATIVE) $(BITCODE_OR_SECTIONS) $(OPTIMIZATION_LEVEL) -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden
BUN_CFLAGS = $(MACOS_MIN_FLAG) $(MARCH_NATIVE) $(EMBED_OR_EMIT_BITCODE) $(OPTIMIZATION_LEVEL) -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden
BUN_TMP_DIR := /tmp/make-bun
BUN_DEPLOY_DIR = /tmp/bun-v$(PACKAGE_JSON_VERSION)/$(PACKAGE_NAME)
DEFAULT_USE_BMALLOC := 1
@@ -198,6 +197,7 @@ endif
BUN_DEPLOY_DIR ?= /tmp/bun-$(PACKAGE_JSON_VERSION)
MACOSX_DEPLOYMENT_TARGET=$(MIN_MACOS_VERSION)
MACOS_MIN_FLAG=
@@ -847,10 +847,10 @@ release-bin-entitlements:
# ditto lets us generate it similarly to right clicking "Compress" in Finder
.PHONY: release-bin-generate-zip
release-bin-generate-zip:
dot_clean -vnm /tmp/bun-$(PACKAGE_JSON_VERSION)/bun-$(TRIPLET)
cd /tmp/bun-$(PACKAGE_JSON_VERSION)/bun-$(TRIPLET) && \
dot_clean -vnm $(BUN_DEPLOY_DIR)/bun-$(TRIPLET)
cd $(BUN_DEPLOY_DIR)/bun-$(TRIPLET) && \
codesign --entitlements $(realpath entitlements.plist) --options runtime --force --timestamp --sign "$(CODESIGN_IDENTITY)" -vvvv --deep --strict bun
ditto -ck --rsrc --sequesterRsrc --keepParent /tmp/bun-$(PACKAGE_JSON_VERSION)/bun-$(TRIPLET) $(BUN_DEPLOY_ZIP)
ditto -ck --rsrc --sequesterRsrc --keepParent $(BUN_DEPLOY_DIR)/bun-$(TRIPLET) $(BUN_DEPLOY_ZIP)
.PHONY: release-bin-codesign
release-bin-codesign:
@@ -860,13 +860,13 @@ else
.PHONY: release-bin-generate-zip
release-bin-generate-zip:
cd /tmp/bun-$(PACKAGE_JSON_VERSION)/ && zip -r bun-$(TRIPLET).zip bun-$(TRIPLET)
cd $(BUN_DEPLOY_DIR)/ && zip -r bun-$(TRIPLET).zip bun-$(TRIPLET)
endif
BUN_DEPLOY_ZIP = /tmp/bun-$(PACKAGE_JSON_VERSION)/bun-$(TRIPLET).zip
BUN_DEPLOY_DSYM = /tmp/bun-$(PACKAGE_JSON_VERSION)/bun-$(TRIPLET).dSYM.tar.gz
BUN_DEPLOY_ZIP = $(BUN_DEPLOY_DIR)/bun-$(TRIPLET).zip
BUN_DEPLOY_DSYM = $(BUN_DEPLOY_DIR)/bun-$(TRIPLET).dSYM.tar.gz
ifeq ($(OS_NAME),darwin)
@@ -884,9 +884,9 @@ endif
.PHONY: release-bin-generate-copy
release-bin-generate-copy:
rm -rf /tmp/bun-$(PACKAGE_JSON_VERSION)/bun-$(TRIPLET) $(BUN_DEPLOY_ZIP)
mkdir -p /tmp/bun-$(PACKAGE_JSON_VERSION)/bun-$(TRIPLET)
cp $(BUN_RELEASE_BIN) /tmp/bun-$(PACKAGE_JSON_VERSION)/bun-$(TRIPLET)/bun
rm -rf $(BUN_DEPLOY_DIR)/bun-$(TRIPLET) $(BUN_DEPLOY_ZIP)
mkdir -p $(BUN_DEPLOY_DIR)/bun-$(TRIPLET)
cp $(BUN_RELEASE_BIN) $(BUN_DEPLOY_DIR)/bun-$(TRIPLET)/bun
.PHONY: release-bin-generate
release-bin-generate: release-bin-generate-copy release-bin-generate-zip release-bin-generate-copy-dsym
@@ -1312,7 +1312,7 @@ bun-link-lld-release-no-jsc:
bun-relink-copy:
mkdir -p $(PACKAGE_DIR)
cp /tmp/bun-$(PACKAGE_JSON_VERSION).o $(BUN_RELEASE_BIN).o
cp $(BUN_DEPLOY_DIR).o $(BUN_RELEASE_BIN).o
bun-link-lld-release:
$(CXX) $(BUN_LLD_FLAGS) $(SYMBOLS) \
@@ -1324,7 +1324,7 @@ bun-link-lld-release:
cp $(BUN_RELEASE_BIN) $(BUN_RELEASE_BIN)-profile
bun-release-copy-obj:
cp $(BUN_RELEASE_BIN).o /tmp/bun-$(PACKAGE_JSON_VERSION).o
cp $(BUN_RELEASE_BIN).o $(BUN_DEPLOY_DIR).o
cp $(BUN_RELEASE_BIN).o /tmp/bun-current.o
bun-link-lld-release-no-lto:
@@ -1348,7 +1348,7 @@ endif
ifeq ($(OS_NAME),linux)
bun-link-lld-release-dsym: bun-release-copy-obj
mv $(BUN_RELEASE_BIN).o /tmp/bun-$(PACKAGE_JSON_VERSION).o
mv $(BUN_RELEASE_BIN).o $(BUN_DEPLOY_DIR).o
-$(STRIP) -s $(BUN_RELEASE_BIN) --wildcard -K _napi\*
copy-to-bun-release-dir-dsym:

View File

@@ -338,7 +338,7 @@ pub fn build(b: *std.build.Builder) !void {
} else if (arch.isAARCH64() and target.isDarwin()) {
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.apple_m1 };
} else if (arch.isAARCH64() and target.isLinux()) {
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.apple_m1 };
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.generic };
}
{