mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Convert build scripts to CMake (#13427)
This commit is contained in:
@@ -6,14 +6,7 @@
|
||||
#
|
||||
# Changes to this file will be automatically uploaded on the next run
|
||||
# for a particular commit.
|
||||
#
|
||||
# Future tests machines to be added:
|
||||
# - macOS 12
|
||||
# - Windows Server 2016 & 2019
|
||||
# - Amazon Linux 2 & 2023
|
||||
# - CentOS / RHEL / Fedora / other Linux distros
|
||||
# - Docker containers
|
||||
# - Rasberry Pi?
|
||||
|
||||
steps:
|
||||
# macOS aarch64
|
||||
- key: "darwin-aarch64"
|
||||
@@ -26,16 +19,7 @@ steps:
|
||||
os: "darwin"
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-deps.sh"
|
||||
|
||||
- key: "darwin-aarch64-build-zig"
|
||||
label: ":darwin: aarch64 - build-zig"
|
||||
agents:
|
||||
queue: "build-darwin"
|
||||
os: "darwin"
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-zig.sh darwin aarch64"
|
||||
- "bun run build:ci --target dependencies"
|
||||
|
||||
- key: "darwin-aarch64-build-cpp"
|
||||
label: ":darwin: aarch64 - build-cpp"
|
||||
@@ -43,21 +27,32 @@ steps:
|
||||
queue: "build-darwin"
|
||||
os: "darwin"
|
||||
arch: "aarch64"
|
||||
env:
|
||||
BUN_CPP_ONLY: "ON"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-cpp.sh"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "darwin-aarch64-build-zig"
|
||||
label: ":darwin: aarch64 - build-zig"
|
||||
agents:
|
||||
queue: "build-zig"
|
||||
command:
|
||||
- "bun run build:ci --target bun-zig --toolchain darwin-aarch64"
|
||||
|
||||
- key: "darwin-aarch64-build-bun"
|
||||
label: ":darwin: aarch64 - build-bun"
|
||||
depends_on:
|
||||
- "darwin-aarch64-build-deps"
|
||||
- "darwin-aarch64-build-zig"
|
||||
- "darwin-aarch64-build-cpp"
|
||||
agents:
|
||||
queue: "build-darwin"
|
||||
os: "darwin"
|
||||
arch: "aarch64"
|
||||
depends_on:
|
||||
- "darwin-aarch64-build-deps"
|
||||
- "darwin-aarch64-build-cpp"
|
||||
- "darwin-aarch64-build-zig"
|
||||
env:
|
||||
BUN_LINK_ONLY: "ON"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-bun.sh"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "darwin-aarch64-test-macos-14"
|
||||
label: ":darwin: 14 aarch64 - test-bun"
|
||||
@@ -126,16 +121,7 @@ steps:
|
||||
os: "darwin"
|
||||
arch: "x64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-deps.sh"
|
||||
|
||||
- key: "darwin-x64-build-zig"
|
||||
label: ":darwin: x64 - build-zig"
|
||||
agents:
|
||||
queue: "build-darwin"
|
||||
os: "darwin"
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-zig.sh darwin x64"
|
||||
- "bun run build:ci --target dependencies"
|
||||
|
||||
- key: "darwin-x64-build-cpp"
|
||||
label: ":darwin: x64 - build-cpp"
|
||||
@@ -143,26 +129,37 @@ steps:
|
||||
queue: "build-darwin"
|
||||
os: "darwin"
|
||||
arch: "x64"
|
||||
env:
|
||||
BUN_CPP_ONLY: "ON"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-cpp.sh"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "darwin-x64-build-zig"
|
||||
label: ":darwin: x64 - build-zig"
|
||||
agents:
|
||||
queue: "build-zig"
|
||||
command:
|
||||
- "bun run build:ci --target bun-zig --toolchain darwin-x64"
|
||||
|
||||
- key: "darwin-x64-build-bun"
|
||||
label: ":darwin: x64 - build-bun"
|
||||
depends_on:
|
||||
- "darwin-x64-build-deps"
|
||||
- "darwin-x64-build-zig"
|
||||
- "darwin-x64-build-cpp"
|
||||
agents:
|
||||
queue: "build-darwin"
|
||||
os: "darwin"
|
||||
arch: "x64"
|
||||
depends_on:
|
||||
- "darwin-x64-build-deps"
|
||||
- "darwin-x64-build-cpp"
|
||||
- "darwin-x64-build-zig"
|
||||
env:
|
||||
BUN_LINK_ONLY: "ON"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-bun.sh"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "darwin-x64-test-macos-14"
|
||||
label: ":darwin: 14 x64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 2
|
||||
parallelism: 3
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
@@ -190,7 +187,7 @@ steps:
|
||||
- key: "darwin-x64-test-macos-13"
|
||||
label: ":darwin: 13 x64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 2
|
||||
parallelism: 3
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
@@ -215,137 +212,6 @@ steps:
|
||||
command:
|
||||
- "./scripts/runner.node.mjs --step darwin-x64-build-bun"
|
||||
|
||||
# Linux aarch64
|
||||
- key: "linux-aarch64"
|
||||
group: ":linux: aarch64"
|
||||
steps:
|
||||
- key: "linux-aarch64-build-deps"
|
||||
label: ":linux: aarch64 - build-deps"
|
||||
agents:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-deps.sh"
|
||||
|
||||
- key: "linux-aarch64-build-zig"
|
||||
label: ":linux: aarch64 - build-zig"
|
||||
agents:
|
||||
queue: "build-darwin"
|
||||
os: "darwin"
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-zig.sh linux aarch64"
|
||||
|
||||
- key: "linux-aarch64-build-cpp"
|
||||
label: ":linux: aarch64 - build-cpp"
|
||||
agents:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-cpp.sh"
|
||||
|
||||
- key: "linux-aarch64-build-bun"
|
||||
label: ":linux: aarch64 - build-bun"
|
||||
depends_on:
|
||||
- "linux-aarch64-build-deps"
|
||||
- "linux-aarch64-build-zig"
|
||||
- "linux-aarch64-build-cpp"
|
||||
agents:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-bun.sh"
|
||||
|
||||
- key: "linux-aarch64-test-debian-12"
|
||||
label: ":debian: 12 aarch64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 5
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 1
|
||||
limit: 1
|
||||
- exit_status: -1
|
||||
limit: 3
|
||||
- exit_status: 255
|
||||
limit: 3
|
||||
- signal_reason: agent_stop
|
||||
limit: 3
|
||||
- signal: SIGTERM
|
||||
limit: 3
|
||||
depends_on:
|
||||
- "linux-aarch64-build-bun"
|
||||
agents:
|
||||
robobun: "true"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
distro: "debian"
|
||||
release: "12"
|
||||
command:
|
||||
- "./scripts/runner.node.mjs --step linux-aarch64-build-bun"
|
||||
|
||||
- key: "linux-aarch64-test-ubuntu-2204"
|
||||
label: ":ubuntu: 22.04 aarch64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 5
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 1
|
||||
limit: 1
|
||||
- exit_status: -1
|
||||
limit: 3
|
||||
- exit_status: 255
|
||||
limit: 3
|
||||
- signal_reason: agent_stop
|
||||
limit: 3
|
||||
- signal: SIGTERM
|
||||
limit: 3
|
||||
depends_on:
|
||||
- "linux-aarch64-build-bun"
|
||||
agents:
|
||||
robobun: "true"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
distro: "ubuntu"
|
||||
release: "22.04"
|
||||
command:
|
||||
- "./scripts/runner.node.mjs --step linux-aarch64-build-bun"
|
||||
|
||||
- key: "linux-aarch64-test-ubuntu-2004"
|
||||
label: ":ubuntu: 20.04 aarch64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 5
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 1
|
||||
limit: 1
|
||||
- exit_status: -1
|
||||
limit: 3
|
||||
- exit_status: 255
|
||||
limit: 3
|
||||
- signal_reason: agent_stop
|
||||
limit: 3
|
||||
- signal: SIGTERM
|
||||
limit: 3
|
||||
depends_on:
|
||||
- "linux-aarch64-build-bun"
|
||||
agents:
|
||||
robobun: "true"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
distro: "ubuntu"
|
||||
release: "20.04"
|
||||
command:
|
||||
- "./scripts/runner.node.mjs --step linux-aarch64-build-bun"
|
||||
|
||||
# Linux x64
|
||||
- key: "linux-x64"
|
||||
group: ":linux: x64"
|
||||
@@ -357,16 +223,7 @@ steps:
|
||||
os: "linux"
|
||||
arch: "x64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-deps.sh"
|
||||
|
||||
- key: "linux-x64-build-zig"
|
||||
label: ":linux: x64 - build-zig"
|
||||
agents:
|
||||
queue: "build-darwin"
|
||||
os: "darwin"
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-zig.sh linux x64"
|
||||
- "bun run build:ci --target dependencies"
|
||||
|
||||
- key: "linux-x64-build-cpp"
|
||||
label: ":linux: x64 - build-cpp"
|
||||
@@ -374,26 +231,37 @@ steps:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "x64"
|
||||
env:
|
||||
BUN_CPP_ONLY: "ON"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-cpp.sh"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "linux-x64-build-zig"
|
||||
label: ":linux: x64 - build-zig"
|
||||
agents:
|
||||
queue: "build-zig"
|
||||
command:
|
||||
- "bun run build:ci --target bun-zig --toolchain linux-x64"
|
||||
|
||||
- key: "linux-x64-build-bun"
|
||||
label: ":linux: x64 - build-bun"
|
||||
depends_on:
|
||||
- "linux-x64-build-deps"
|
||||
- "linux-x64-build-zig"
|
||||
- "linux-x64-build-cpp"
|
||||
agents:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "x64"
|
||||
depends_on:
|
||||
- "linux-x64-build-deps"
|
||||
- "linux-x64-build-cpp"
|
||||
- "linux-x64-build-zig"
|
||||
env:
|
||||
BUN_LINK_ONLY: "ON"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-bun.sh"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "linux-x64-test-debian-12"
|
||||
label: ":debian: 12 x64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 5
|
||||
parallelism: 10
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
@@ -422,7 +290,7 @@ steps:
|
||||
- key: "linux-x64-test-ubuntu-2204"
|
||||
label: ":ubuntu: 22.04 x64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 5
|
||||
parallelism: 10
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
@@ -451,7 +319,7 @@ steps:
|
||||
- key: "linux-x64-test-ubuntu-2004"
|
||||
label: ":ubuntu: 20.04 x64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 5
|
||||
parallelism: 10
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
@@ -487,17 +355,10 @@ steps:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "x64"
|
||||
env:
|
||||
ENABLE_BASELINE: "ON"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-deps.sh"
|
||||
|
||||
- key: "linux-x64-baseline-build-zig"
|
||||
label: ":linux: x64-baseline - build-zig"
|
||||
agents:
|
||||
queue: "build-darwin"
|
||||
os: "darwin"
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-zig.sh linux x64"
|
||||
- "bun run build:ci --target dependencies"
|
||||
|
||||
- key: "linux-x64-baseline-build-cpp"
|
||||
label: ":linux: x64-baseline - build-cpp"
|
||||
@@ -505,26 +366,41 @@ steps:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "x64"
|
||||
env:
|
||||
ENABLE_BASELINE: "ON"
|
||||
BUN_CPP_ONLY: "ON"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-cpp.sh"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "linux-x64-baseline-build-zig"
|
||||
label: ":linux: x64-baseline - build-zig"
|
||||
agents:
|
||||
queue: "build-zig"
|
||||
env:
|
||||
ENABLE_BASELINE: "ON"
|
||||
command:
|
||||
- "bun run build:ci --target bun-zig --toolchain linux-x64-baseline"
|
||||
|
||||
- key: "linux-x64-baseline-build-bun"
|
||||
label: ":linux: x64-baseline - build-bun"
|
||||
depends_on:
|
||||
- "linux-x64-baseline-build-deps"
|
||||
- "linux-x64-baseline-build-zig"
|
||||
- "linux-x64-baseline-build-cpp"
|
||||
agents:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "x64"
|
||||
depends_on:
|
||||
- "linux-x64-baseline-build-deps"
|
||||
- "linux-x64-baseline-build-cpp"
|
||||
- "linux-x64-baseline-build-zig"
|
||||
env:
|
||||
ENABLE_BASELINE: "ON"
|
||||
BUN_LINK_ONLY: "ON"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-bun.sh"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "linux-x64-baseline-test-debian-12"
|
||||
label: ":debian: 12 x64-baseline - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 5
|
||||
parallelism: 10
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
@@ -553,7 +429,7 @@ steps:
|
||||
- key: "linux-x64-baseline-test-ubuntu-2204"
|
||||
label: ":ubuntu: 22.04 x64-baseline - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 5
|
||||
parallelism: 10
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
@@ -582,7 +458,7 @@ steps:
|
||||
- key: "linux-x64-baseline-test-ubuntu-2004"
|
||||
label: ":ubuntu: 20.04 x64-baseline - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 5
|
||||
parallelism: 10
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
@@ -608,6 +484,139 @@ steps:
|
||||
command:
|
||||
- "./scripts/runner.node.mjs --step linux-x64-baseline-build-bun"
|
||||
|
||||
# Linux aarch64
|
||||
- key: "linux-aarch64"
|
||||
group: ":linux: aarch64"
|
||||
steps:
|
||||
- key: "linux-aarch64-build-deps"
|
||||
label: ":linux: aarch64 - build-deps"
|
||||
agents:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "bun run build:ci --target dependencies"
|
||||
|
||||
- key: "linux-aarch64-build-cpp"
|
||||
label: ":linux: aarch64 - build-cpp"
|
||||
agents:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
env:
|
||||
BUN_CPP_ONLY: "ON"
|
||||
command:
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "linux-aarch64-build-zig"
|
||||
label: ":linux: aarch64 - build-zig"
|
||||
agents:
|
||||
queue: "build-zig"
|
||||
command:
|
||||
- "bun run build:ci --target bun-zig --toolchain linux-aarch64"
|
||||
|
||||
- key: "linux-aarch64-build-bun"
|
||||
label: ":linux: aarch64 - build-bun"
|
||||
agents:
|
||||
queue: "build-linux"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
depends_on:
|
||||
- "linux-aarch64-build-deps"
|
||||
- "linux-aarch64-build-cpp"
|
||||
- "linux-aarch64-build-zig"
|
||||
env:
|
||||
BUN_LINK_ONLY: "ON"
|
||||
command:
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "linux-aarch64-test-debian-12"
|
||||
label: ":debian: 12 aarch64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 10
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 1
|
||||
limit: 1
|
||||
- exit_status: -1
|
||||
limit: 3
|
||||
- exit_status: 255
|
||||
limit: 3
|
||||
- signal_reason: agent_stop
|
||||
limit: 3
|
||||
- signal: SIGTERM
|
||||
limit: 3
|
||||
depends_on:
|
||||
- "linux-aarch64-build-bun"
|
||||
agents:
|
||||
robobun: "true"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
distro: "debian"
|
||||
release: "12"
|
||||
command:
|
||||
- "./scripts/runner.node.mjs --step linux-aarch64-build-bun"
|
||||
|
||||
- key: "linux-aarch64-test-ubuntu-2204"
|
||||
label: ":ubuntu: 22.04 aarch64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 10
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 1
|
||||
limit: 1
|
||||
- exit_status: -1
|
||||
limit: 3
|
||||
- exit_status: 255
|
||||
limit: 3
|
||||
- signal_reason: agent_stop
|
||||
limit: 3
|
||||
- signal: SIGTERM
|
||||
limit: 3
|
||||
depends_on:
|
||||
- "linux-aarch64-build-bun"
|
||||
agents:
|
||||
robobun: "true"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
distro: "ubuntu"
|
||||
release: "22.04"
|
||||
command:
|
||||
- "./scripts/runner.node.mjs --step linux-aarch64-build-bun"
|
||||
|
||||
- key: "linux-aarch64-test-ubuntu-2004"
|
||||
label: ":ubuntu: 20.04 aarch64 - test-bun"
|
||||
if: "build.branch != 'main'"
|
||||
parallelism: 10
|
||||
soft_fail:
|
||||
- exit_status: 2
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 1
|
||||
limit: 1
|
||||
- exit_status: -1
|
||||
limit: 3
|
||||
- exit_status: 255
|
||||
limit: 3
|
||||
- signal_reason: agent_stop
|
||||
limit: 3
|
||||
- signal: SIGTERM
|
||||
limit: 3
|
||||
depends_on:
|
||||
- "linux-aarch64-build-bun"
|
||||
agents:
|
||||
robobun: "true"
|
||||
os: "linux"
|
||||
arch: "aarch64"
|
||||
distro: "ubuntu"
|
||||
release: "20.04"
|
||||
command:
|
||||
- "./scripts/runner.node.mjs --step linux-aarch64-build-bun"
|
||||
|
||||
# Windows x64
|
||||
- key: "windows-x64"
|
||||
group: ":windows: x64"
|
||||
@@ -618,21 +627,12 @@ steps:
|
||||
queue: "build-windows"
|
||||
os: "windows"
|
||||
arch: "x64"
|
||||
artifact_paths:
|
||||
- "build\\bun-deps\\*.lib"
|
||||
env:
|
||||
CCACHE_DISABLE: "1"
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 255
|
||||
limit: 5
|
||||
command:
|
||||
- ".\\scripts\\all-dependencies.ps1"
|
||||
|
||||
- key: "windows-x64-build-zig"
|
||||
label: ":windows: x64 - build-zig"
|
||||
agents:
|
||||
queue: "build-darwin"
|
||||
os: "darwin" # cross-compile on Linux or Darwin
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-zig.sh windows x64"
|
||||
- "bun run build:ci --target dependencies"
|
||||
|
||||
- key: "windows-x64-build-cpp"
|
||||
label: ":windows: x64 - build-cpp"
|
||||
@@ -640,33 +640,40 @@ steps:
|
||||
queue: "build-windows"
|
||||
os: "windows"
|
||||
arch: "x64"
|
||||
artifact_paths:
|
||||
# HACK: See scripts/build-bun-cpp.ps1
|
||||
# - "build\\bun-cpp-objects.a"
|
||||
- "build\\bun-cpp-objects.a.*"
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 255
|
||||
limit: 5
|
||||
env:
|
||||
CCACHE_DISABLE: "1"
|
||||
BUN_CPP_ONLY: "ON"
|
||||
command:
|
||||
- ".\\scripts\\build-bun-cpp.ps1"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "windows-x64-build-zig"
|
||||
label: ":windows: x64 - build-zig"
|
||||
agents:
|
||||
queue: "build-zig"
|
||||
command:
|
||||
- "bun run build:ci --target bun-zig --toolchain windows-x64"
|
||||
|
||||
- key: "windows-x64-build-bun"
|
||||
label: ":windows: x64 - build-bun"
|
||||
depends_on:
|
||||
- "windows-x64-build-deps"
|
||||
- "windows-x64-build-zig"
|
||||
- "windows-x64-build-cpp"
|
||||
agents:
|
||||
queue: "build-windows"
|
||||
os: "windows"
|
||||
arch: "x64"
|
||||
artifact_paths:
|
||||
- "bun-windows-x64.zip"
|
||||
- "bun-windows-x64-profile.zip"
|
||||
- "features.json"
|
||||
depends_on:
|
||||
- "windows-x64-build-deps"
|
||||
- "windows-x64-build-cpp"
|
||||
- "windows-x64-build-zig"
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 255
|
||||
limit: 5
|
||||
env:
|
||||
CCACHE_DISABLE: "1"
|
||||
BUN_LINK_ONLY: "ON"
|
||||
command:
|
||||
- ".\\scripts\\buildkite-link-bun.ps1"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "windows-x64-test-bun"
|
||||
label: ":windows: x64 - test-bun"
|
||||
@@ -703,22 +710,14 @@ steps:
|
||||
queue: "build-windows"
|
||||
os: "windows"
|
||||
arch: "x64"
|
||||
artifact_paths:
|
||||
- "build\\bun-deps\\*.lib"
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 255
|
||||
limit: 5
|
||||
env:
|
||||
CCACHE_DISABLE: "1"
|
||||
USE_BASELINE_BUILD: "1"
|
||||
ENABLE_BASELINE: "ON"
|
||||
command:
|
||||
- ".\\scripts\\all-dependencies.ps1"
|
||||
|
||||
- key: "windows-x64-baseline-build-zig"
|
||||
label: ":windows: x64-baseline - build-zig"
|
||||
agents:
|
||||
queue: "build-darwin"
|
||||
os: "darwin" # cross-compile on Linux or Darwin
|
||||
arch: "aarch64"
|
||||
command:
|
||||
- "./.buildkite/scripts/build-zig.sh windows x64"
|
||||
- "bun run build:ci --target dependencies"
|
||||
|
||||
- key: "windows-x64-baseline-build-cpp"
|
||||
label: ":windows: x64-baseline - build-cpp"
|
||||
@@ -726,35 +725,44 @@ steps:
|
||||
queue: "build-windows"
|
||||
os: "windows"
|
||||
arch: "x64"
|
||||
artifact_paths:
|
||||
# HACK: See scripts/build-bun-cpp.ps1
|
||||
# - "build\\bun-cpp-objects.a"
|
||||
- "build\\bun-cpp-objects.a.*"
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 255
|
||||
limit: 5
|
||||
env:
|
||||
CCACHE_DISABLE: "1"
|
||||
USE_BASELINE_BUILD: "1"
|
||||
ENABLE_BASELINE: "ON"
|
||||
BUN_CPP_ONLY: "ON"
|
||||
command:
|
||||
- ".\\scripts\\build-bun-cpp.ps1"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "windows-x64-baseline-build-zig"
|
||||
label: ":windows: x64-baseline - build-zig"
|
||||
agents:
|
||||
queue: "build-zig"
|
||||
env:
|
||||
ENABLE_BASELINE: "ON"
|
||||
command:
|
||||
- "bun run build:ci --target bun-zig --toolchain windows-x64-baseline"
|
||||
|
||||
- key: "windows-x64-baseline-build-bun"
|
||||
label: ":windows: x64-baseline - build-bun"
|
||||
depends_on:
|
||||
- "windows-x64-baseline-build-deps"
|
||||
- "windows-x64-baseline-build-zig"
|
||||
- "windows-x64-baseline-build-cpp"
|
||||
agents:
|
||||
queue: "build-windows"
|
||||
os: "windows"
|
||||
arch: "x64"
|
||||
artifact_paths:
|
||||
- "bun-windows-x64-baseline.zip"
|
||||
- "bun-windows-x64-baseline-profile.zip"
|
||||
- "features.json"
|
||||
depends_on:
|
||||
- "windows-x64-baseline-build-deps"
|
||||
- "windows-x64-baseline-build-cpp"
|
||||
- "windows-x64-baseline-build-zig"
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: 255
|
||||
limit: 5
|
||||
env:
|
||||
CCACHE_DISABLE: "1"
|
||||
USE_BASELINE_BUILD: "1"
|
||||
ENABLE_BASELINE: "ON"
|
||||
BUN_LINK_ONLY: "ON"
|
||||
command:
|
||||
- ".\\scripts\\buildkite-link-bun.ps1 -Baseline $$True"
|
||||
- "bun run build:ci --target bun"
|
||||
|
||||
- key: "windows-x64-baseline-test-bun"
|
||||
label: ":windows: x64-baseline - test-bun"
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
source "$(dirname "$0")/env.sh"
|
||||
|
||||
function run_command() {
|
||||
set -x
|
||||
"$@"
|
||||
{ set +x; } 2>/dev/null
|
||||
}
|
||||
|
||||
cwd="$(pwd)"
|
||||
|
||||
mkdir -p build
|
||||
source "$(dirname "$0")/download-artifact.sh" "build/bun-deps/**" --step "$BUILDKITE_GROUP_KEY-build-deps"
|
||||
source "$(dirname "$0")/download-artifact.sh" "build/bun-zig.o" --step "$BUILDKITE_GROUP_KEY-build-zig"
|
||||
source "$(dirname "$0")/download-artifact.sh" "build/bun-cpp-objects.a" --step "$BUILDKITE_GROUP_KEY-build-cpp" --split
|
||||
cd build
|
||||
|
||||
run_command cmake .. "${CMAKE_FLAGS[@]}" \
|
||||
-GNinja \
|
||||
-DBUN_LINK_ONLY="1" \
|
||||
-DNO_CONFIGURE_DEPENDS="1" \
|
||||
-DBUN_ZIG_OBJ_DIR="$cwd/build" \
|
||||
-DBUN_CPP_ARCHIVE="$cwd/build/bun-cpp-objects.a" \
|
||||
-DBUN_DEPS_OUT_DIR="$cwd/build/bun-deps" \
|
||||
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
|
||||
-DCPU_TARGET="$CPU_TARGET" \
|
||||
-DUSE_LTO="$USE_LTO" \
|
||||
-DUSE_DEBUG_JSC="$USE_DEBUG_JSC" \
|
||||
-DCANARY="$CANARY" \
|
||||
-DGIT_SHA="$GIT_SHA"
|
||||
run_command ninja -v -j "$CPUS"
|
||||
run_command ls
|
||||
|
||||
tag="bun-$BUILDKITE_GROUP_KEY"
|
||||
if [ "$USE_LTO" == "OFF" ]; then
|
||||
# Remove OS check when LTO is enabled on macOS again
|
||||
if [[ "$tag" == *"darwin"* ]]; then
|
||||
tag="$tag-nolto"
|
||||
fi
|
||||
fi
|
||||
|
||||
for name in bun bun-profile; do
|
||||
dir="$tag"
|
||||
if [ "$name" == "bun-profile" ]; then
|
||||
dir="$tag-profile"
|
||||
fi
|
||||
run_command chmod +x "$name"
|
||||
run_command "./$name" --revision
|
||||
run_command mkdir -p "$dir"
|
||||
run_command mv "$name" "$dir/$name"
|
||||
run_command zip -r "$dir.zip" "$dir"
|
||||
source "$cwd/.buildkite/scripts/upload-artifact.sh" "$dir.zip"
|
||||
# temporary disable this so CI can run
|
||||
# this is failing because $name is now in $dir/$name and if changed to $dir/$name we get ENOENT reading "bun:internal-for-testing"
|
||||
# if [ "$name" == "bun-profile" ]; then
|
||||
# export BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING="1"
|
||||
# run_command "./$name" -e "require('fs').writeFileSync('./features.json', JSON.stringify(require('bun:internal-for-testing').crash_handler.getFeatureData()))"
|
||||
# source "$cwd/.buildkite/scripts/upload-artifact.sh" "features.json"
|
||||
# fi
|
||||
done
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
export FORCE_UPDATE_SUBMODULES=1
|
||||
|
||||
# env.sh calls update_submodules.sh
|
||||
source "$(dirname "$0")/env.sh"
|
||||
|
||||
{ set +x; } 2>/dev/null
|
||||
|
||||
function run_command() {
|
||||
set -x
|
||||
"$@"
|
||||
{ set +x; } 2>/dev/null
|
||||
}
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
mkdir -p tmp_modules tmp_functions js codegen
|
||||
|
||||
run_command cmake .. "${CMAKE_FLAGS[@]}" \
|
||||
-GNinja \
|
||||
-DBUN_CPP_ONLY="1" \
|
||||
-DNO_CONFIGURE_DEPENDS="1" \
|
||||
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
|
||||
-DCPU_TARGET="$CPU_TARGET" \
|
||||
-DUSE_LTO="$USE_LTO" \
|
||||
-DUSE_DEBUG_JSC="$USE_DEBUG_JSC" \
|
||||
-DCANARY="$CANARY" \
|
||||
-DGIT_SHA="$GIT_SHA"
|
||||
|
||||
chmod +x compile-cpp-only.sh
|
||||
source compile-cpp-only.sh -v -j "$CPUS"
|
||||
{ set +x; } 2>/dev/null
|
||||
|
||||
cd ..
|
||||
source "$(dirname "$0")/upload-artifact.sh" "build/bun-cpp-objects.a" --split
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
source "$(dirname "$0")/env.sh"
|
||||
source "$(realpath $(dirname "$0")/../../scripts/all-dependencies.sh)"
|
||||
|
||||
artifacts=(
|
||||
libcrypto.a libssl.a libdecrepit.a
|
||||
libcares.a
|
||||
libarchive.a
|
||||
liblolhtml.a
|
||||
libmimalloc.a libmimalloc.o
|
||||
libtcc.a
|
||||
libz.a
|
||||
libzstd.a
|
||||
libdeflate.a
|
||||
liblshpack.a
|
||||
)
|
||||
|
||||
for artifact in "${artifacts[@]}"; do
|
||||
source "$(dirname "$0")/upload-artifact.sh" "build/bun-deps/$artifact"
|
||||
done
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
source "$(dirname "$0")/env.sh"
|
||||
|
||||
function assert_bun() {
|
||||
if ! command -v bun &>/dev/null; then
|
||||
echo "error: bun is not installed" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function assert_make() {
|
||||
if ! command -v make &>/dev/null; then
|
||||
echo "error: make is not installed" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function run_command() {
|
||||
set -x
|
||||
"$@"
|
||||
{ set +x; } 2>/dev/null
|
||||
}
|
||||
|
||||
function build_node_fallbacks() {
|
||||
local cwd="src/node-fallbacks"
|
||||
run_command bun install --cwd "$cwd" --frozen-lockfile
|
||||
run_command bun run --cwd "$cwd" build
|
||||
}
|
||||
|
||||
function build_old_js() {
|
||||
run_command bun install --frozen-lockfile
|
||||
run_command make runtime_js fallback_decoder bun_error
|
||||
}
|
||||
|
||||
assert_bun
|
||||
assert_make
|
||||
build_node_fallbacks
|
||||
build_old_js
|
||||
@@ -1,101 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
export CMAKE_FLAGS=""
|
||||
source "$(dirname "$0")/env.sh"
|
||||
|
||||
if [[ -n "$CMAKE_FLAGS" ]]; then
|
||||
echo "CMAKE_FLAGS should not be empty"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function assert_target() {
|
||||
local arch="${2-$(uname -m)}"
|
||||
case "$(echo "$arch" | tr '[:upper:]' '[:lower:]')" in
|
||||
x64 | x86_64 | amd64)
|
||||
export ZIG_ARCH="x86_64"
|
||||
if [[ "$BUILDKITE_STEP_KEY" == *"baseline"* ]]; then
|
||||
export ZIG_CPU_TARGET="nehalem"
|
||||
else
|
||||
export ZIG_CPU_TARGET="haswell"
|
||||
fi
|
||||
;;
|
||||
aarch64 | arm64)
|
||||
export ZIG_ARCH="aarch64"
|
||||
export ZIG_CPU_TARGET="native"
|
||||
;;
|
||||
*)
|
||||
echo "error: Unsupported architecture: $arch" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
local os="${1-$(uname -s)}"
|
||||
case "$(echo "$os" | tr '[:upper:]' '[:lower:]')" in
|
||||
linux)
|
||||
export ZIG_OS="linux"
|
||||
export ZIG_TARGET="$ZIG_ARCH-linux-gnu"
|
||||
;;
|
||||
darwin)
|
||||
export ZIG_OS="macos"
|
||||
export ZIG_TARGET="$ZIG_ARCH-macos-none"
|
||||
;;
|
||||
windows)
|
||||
export ZIG_OS="windows"
|
||||
export ZIG_TARGET="$ZIG_ARCH-windows-msvc"
|
||||
;;
|
||||
*)
|
||||
echo "error: Unsupported operating system: $os" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function run_command() {
|
||||
set -x
|
||||
"$@"
|
||||
{ set +x; } 2>/dev/null
|
||||
}
|
||||
|
||||
assert_target "$@"
|
||||
|
||||
# Since the zig build depends on files from the zig submodule,
|
||||
# make sure to update the submodule before building.
|
||||
run_command git submodule update --init --recursive --progress --depth=1 --checkout src/deps/zig
|
||||
|
||||
# TODO: Move these to be part of the CMake build
|
||||
source "$(dirname "$0")/build-old-js.sh"
|
||||
|
||||
cwd="$(pwd)"
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
# in buildkite this script to compile for windows is run on a macos machine
|
||||
# so the cmake windows detection for this logic is not ran
|
||||
ZIG_OPTIMIZE="ReleaseFast"
|
||||
if [[ "$ZIG_OS" == "windows" ]]; then
|
||||
ZIG_OPTIMIZE="ReleaseSafe"
|
||||
fi
|
||||
|
||||
run_command cmake .. "${CMAKE_FLAGS[@]}" \
|
||||
-GNinja \
|
||||
-DNO_CONFIGURE_DEPENDS="1" \
|
||||
-DNO_CODEGEN="0" \
|
||||
-DWEBKIT_DIR="omit" \
|
||||
-DBUN_ZIG_OBJ_DIR="$cwd/build" \
|
||||
-DZIG_LIB_DIR="$cwd/src/deps/zig/lib" \
|
||||
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
|
||||
-DARCH="$ZIG_ARCH" \
|
||||
-DCPU_TARGET="$ZIG_CPU_TARGET" \
|
||||
-DZIG_TARGET="$ZIG_TARGET" \
|
||||
-DUSE_LTO="$USE_LTO" \
|
||||
-DUSE_DEBUG_JSC="$USE_DEBUG_JSC" \
|
||||
-DCANARY="$CANARY" \
|
||||
-DZIG_OPTIMIZE="$ZIG_OPTIMIZE" \
|
||||
-DGIT_SHA="$GIT_SHA"
|
||||
|
||||
export ONLY_ZIG="1"
|
||||
run_command ninja "$cwd/build/bun-zig.o" -v -j "$CPUS"
|
||||
|
||||
cd ..
|
||||
source "$(dirname "$0")/upload-artifact.sh" "build/bun-zig.o"
|
||||
@@ -1,47 +0,0 @@
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string[]] $Paths,
|
||||
[switch] $Split
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Assert-Buildkite-Agent() {
|
||||
if (-not (Get-Command "buildkite-agent" -ErrorAction SilentlyContinue)) {
|
||||
Write-Error "Cannot find buildkite-agent, please install it: https://buildkite.com/docs/agent/v3/install"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Assert-Join-File() {
|
||||
if (-not (Get-Command "Join-File" -ErrorAction SilentlyContinue)) {
|
||||
Write-Error "Cannot find Join-File, please install it: https://www.powershellgallery.com/packages/FileSplitter/1.3"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Download-Buildkite-Artifact() {
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $Path,
|
||||
)
|
||||
if ($Split) {
|
||||
& buildkite-agent artifact download "$Path.*" --debug --debug-http
|
||||
Join-File -Path "$(Resolve-Path .)\$Path" -Verbose -DeletePartFiles
|
||||
} else {
|
||||
& buildkite-agent artifact download "$Path" --debug --debug-http
|
||||
}
|
||||
if (-not (Test-Path $Path)) {
|
||||
Write-Error "Could not find artifact: $Path"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Assert-Buildkite-Agent
|
||||
if ($Split) {
|
||||
Assert-Join-File
|
||||
}
|
||||
|
||||
foreach ($Path in $Paths) {
|
||||
Download-Buildkite-Artifact $Path
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function assert_buildkite_agent() {
|
||||
if ! command -v buildkite-agent &>/dev/null; then
|
||||
echo "error: Cannot find buildkite-agent, please install it:"
|
||||
echo "https://buildkite.com/docs/agent/v3/install"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function download_buildkite_artifact() {
|
||||
# Check if at least one argument is provided
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "error: No path provided for artifact download"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local path="$1"
|
||||
shift
|
||||
local split="0"
|
||||
local args=()
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--split)
|
||||
split="1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
args+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$split" == "1" ]; then
|
||||
run_command buildkite-agent artifact download "$path.*" . "${args[@]:-}"
|
||||
run_command cat "$path".?? >"$path"
|
||||
run_command rm -f "$path".??
|
||||
else
|
||||
run_command buildkite-agent artifact download "$path" . "${args[@]:-}"
|
||||
fi
|
||||
|
||||
if [[ "$path" != *"*"* ]] && [ ! -f "$path" ]; then
|
||||
echo "error: Could not find artifact: $path"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function run_command() {
|
||||
set -x
|
||||
"$@"
|
||||
{ set +x; } 2>/dev/null
|
||||
}
|
||||
|
||||
assert_buildkite_agent
|
||||
download_buildkite_artifact "$@"
|
||||
@@ -1,146 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BUILDKITE_REPO=${BUILDKITE_REPO:-}
|
||||
BUILDKITE_CLEAN_CHECKOUT=${BUILDKITE_CLEAN_CHECKOUT:-}
|
||||
BUILDKITE_BRANCH=${BUILDKITE_BRANCH:-}
|
||||
CCACHE_DIR=${CCACHE_DIR:-}
|
||||
SCCACHE_DIR=${SCCACHE_DIR:-}
|
||||
ZIG_LOCAL_CACHE_DIR=${ZIG_LOCAL_CACHE_DIR:-}
|
||||
ZIG_GLOBAL_CACHE_DIR=${ZIG_GLOBAL_CACHE_DIR:-}
|
||||
BUN_DEPS_CACHE_DIR=${BUN_DEPS_CACHE_DIR:-}
|
||||
BUN_DEPS_CACHE_DIR=${BUN_DEPS_CACHE_DIR:-}
|
||||
BUILDKITE_STEP_KEY=${BUILDKITE_STEP_KEY:-}
|
||||
|
||||
ROOT_DIR="$(realpath "$(dirname "$0")/../../")"
|
||||
|
||||
# Fail if we cannot find the root directory
|
||||
if [ ! -d "$ROOT_DIR" ]; then
|
||||
echo "error: Cannot find root directory: '$ROOT_DIR'" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function assert_os() {
|
||||
local os="$(uname -s)"
|
||||
case "$os" in
|
||||
Linux)
|
||||
echo "linux"
|
||||
;;
|
||||
Darwin)
|
||||
echo "darwin"
|
||||
;;
|
||||
*)
|
||||
echo "error: Unsupported operating system: $os" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function assert_arch() {
|
||||
local arch="$(uname -m)"
|
||||
case "$arch" in
|
||||
aarch64 | arm64)
|
||||
echo "aarch64"
|
||||
;;
|
||||
x86_64 | amd64)
|
||||
echo "x64"
|
||||
;;
|
||||
*)
|
||||
echo "error: Unknown architecture: $arch" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function assert_build() {
|
||||
if [ -z "$BUILDKITE_REPO" ]; then
|
||||
echo "error: Cannot find repository for this build"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$BUILDKITE_COMMIT" ]; then
|
||||
echo "error: Cannot find commit for this build"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$BUILDKITE_STEP_KEY" ]; then
|
||||
echo "error: Cannot find step key for this build"
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$BUILDKITE_GROUP_KEY" ] && [[ "$BUILDKITE_STEP_KEY" != "$BUILDKITE_GROUP_KEY"* ]]; then
|
||||
echo "error: Build step '$BUILDKITE_STEP_KEY' does not start with group key '$BUILDKITE_GROUP_KEY'"
|
||||
exit 1
|
||||
fi
|
||||
# Skip os and arch checks for Zig, since it's cross-compiled on macOS
|
||||
if [[ "$BUILDKITE_STEP_KEY" != *"zig"* ]]; then
|
||||
local os="$(assert_os)"
|
||||
if [[ "$BUILDKITE_STEP_KEY" != *"$os"* ]]; then
|
||||
echo "error: Build step '$BUILDKITE_STEP_KEY' does not match operating system '$os'"
|
||||
exit 1
|
||||
fi
|
||||
local arch="$(assert_arch)"
|
||||
if [[ "$BUILDKITE_STEP_KEY" != *"$arch"* ]]; then
|
||||
echo "error: Build step '$BUILDKITE_STEP_KEY' does not match architecture '$arch'"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function assert_buildkite_agent() {
|
||||
if (! command -v buildkite-agent &>/dev/null); then
|
||||
echo "error: Cannot find buildkite-agent, please install it:"
|
||||
echo "https://buildkite.com/docs/agent/v3/install"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function export_environment() {
|
||||
source "${ROOT_DIR}/scripts/env.sh"
|
||||
source "${ROOT_DIR}/scripts/update-submodules.sh"
|
||||
|
||||
{ set +x; } 2>/dev/null
|
||||
export GIT_SHA="$BUILDKITE_COMMIT"
|
||||
if [ "$BUILDKITE_CLEAN_CHECKOUT" == "true" ] || [ "$BUILDKITE_BRANCH" == "main" ]; then
|
||||
local tmpdir="$(mktemp -d 2>/dev/null || mktemp -d -t 'new')"
|
||||
export CCACHE_DIR="$tmpdir/.cache/ccache"
|
||||
export SCCACHE_DIR="$tmpdir/.cache/sccache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$tmpdir/.cache/zig-cache"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$tmpdir/.cache/zig-cache"
|
||||
export BUN_DEPS_CACHE_DIR="$tmpdir/.cache/bun-deps"
|
||||
export CCACHE_RECACHE="1"
|
||||
else
|
||||
export CCACHE_DIR="$HOME/.cache/ccache/$BUILDKITE_STEP_KEY"
|
||||
export SCCACHE_DIR="$HOME/.cache/sccache/$BUILDKITE_STEP_KEY"
|
||||
export ZIG_LOCAL_CACHE_DIR="$HOME/.cache/zig-cache/$BUILDKITE_STEP_KEY"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$HOME/.cache/zig-cache/$BUILDKITE_STEP_KEY"
|
||||
export BUN_DEPS_CACHE_DIR="$HOME/.cache/bun-deps/$BUILDKITE_STEP_KEY"
|
||||
fi
|
||||
if [ "$(assert_os)" == "linux" ]; then
|
||||
export USE_LTO="ON"
|
||||
fi
|
||||
if [ "$(assert_arch)" == "aarch64" ]; then
|
||||
export CPU_TARGET="native"
|
||||
elif [[ "$BUILDKITE_STEP_KEY" == *"baseline"* ]]; then
|
||||
export CPU_TARGET="nehalem"
|
||||
else
|
||||
export CPU_TARGET="haswell"
|
||||
fi
|
||||
if $(buildkite-agent meta-data exists release &>/dev/null); then
|
||||
export CMAKE_BUILD_TYPE="$(buildkite-agent meta-data get release)"
|
||||
else
|
||||
export CMAKE_BUILD_TYPE="Release"
|
||||
fi
|
||||
if $(buildkite-agent meta-data exists canary &>/dev/null); then
|
||||
export CANARY="$(buildkite-agent meta-data get canary)"
|
||||
else
|
||||
export CANARY="1"
|
||||
fi
|
||||
if $(buildkite-agent meta-data exists assertions &>/dev/null); then
|
||||
export USE_DEBUG_JSC="$(buildkite-agent meta-data get assertions)"
|
||||
else
|
||||
export USE_DEBUG_JSC="OFF"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_build
|
||||
assert_buildkite_agent
|
||||
export_environment
|
||||
@@ -1,47 +0,0 @@
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string[]] $Paths,
|
||||
[switch] $Split
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Assert-Buildkite-Agent() {
|
||||
if (-not (Get-Command "buildkite-agent" -ErrorAction SilentlyContinue)) {
|
||||
Write-Error "Cannot find buildkite-agent, please install it: https://buildkite.com/docs/agent/v3/install"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Assert-Split-File() {
|
||||
if (-not (Get-Command "Split-File" -ErrorAction SilentlyContinue)) {
|
||||
Write-Error "Cannot find Split-File, please install it: https://www.powershellgallery.com/packages/FileSplitter/1.3"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Upload-Buildkite-Artifact() {
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $Path,
|
||||
)
|
||||
if (-not (Test-Path $Path)) {
|
||||
Write-Error "Could not find artifact: $Path"
|
||||
exit 1
|
||||
}
|
||||
if ($Split) {
|
||||
Remove-Item -Path "$Path.*" -Force
|
||||
Split-File -Path (Resolve-Path $Path) -PartSizeBytes "50MB" -Verbose
|
||||
$Path = "$Path.*"
|
||||
}
|
||||
& buildkite-agent artifact upload "$Path" --debug --debug-http
|
||||
}
|
||||
|
||||
Assert-Buildkite-Agent
|
||||
if ($Split) {
|
||||
Assert-Split-File
|
||||
}
|
||||
|
||||
foreach ($Path in $Paths) {
|
||||
Upload-Buildkite-Artifact $Path
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function assert_buildkite_agent() {
|
||||
if ! command -v buildkite-agent &>/dev/null; then
|
||||
echo "error: Cannot find buildkite-agent, please install it:"
|
||||
echo "https://buildkite.com/docs/agent/v3/install"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function assert_split() {
|
||||
if ! command -v split &>/dev/null; then
|
||||
echo "error: Cannot find split, please install it:"
|
||||
echo "https://www.gnu.org/software/coreutils/split"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function upload_buildkite_artifact() {
|
||||
if [ -z "${1:-}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local path="$1"
|
||||
shift
|
||||
local split="0"
|
||||
local args=() # Initialize args as an empty array
|
||||
while true; do
|
||||
if [ -z "${1:-}" ]; then
|
||||
break
|
||||
fi
|
||||
case "$1" in
|
||||
--split)
|
||||
split="1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
args+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ ! -f "$path" ]; then
|
||||
echo "error: Could not find artifact: $path"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$split" == "1" ]; then
|
||||
run_command rm -f "$path."*
|
||||
run_command split -b 50MB -d "$path" "$path."
|
||||
if [ "${args[@]:-}" != "" ]; then
|
||||
run_command buildkite-agent artifact upload "$path.*" "${args[@]}"
|
||||
else
|
||||
run_command buildkite-agent artifact upload "$path.*"
|
||||
fi
|
||||
elif [ "${args[@]:-}" != "" ]; then
|
||||
run_command buildkite-agent artifact upload "$path" "${args[@]:-}"
|
||||
else
|
||||
run_command buildkite-agent artifact upload "$path"
|
||||
fi
|
||||
}
|
||||
|
||||
function run_command() {
|
||||
set -x
|
||||
"$@"
|
||||
{ set +x; } 2>/dev/null
|
||||
}
|
||||
|
||||
assert_buildkite_agent
|
||||
upload_buildkite_artifact "$@"
|
||||
9
.clang-tidy
Normal file
9
.clang-tidy
Normal file
@@ -0,0 +1,9 @@
|
||||
WarningsAsErrors: "*"
|
||||
FormatStyle: webkit
|
||||
Checks: >
|
||||
-*,
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-optin.core.EnumCastOutOfRange
|
||||
-clang-analyzer-webkit.UncountedLambdaCapturesChecker
|
||||
-clang-analyzer-optin.core.EnumCastOutOfRange
|
||||
-clang-analyzer-webkit.RefCntblBaseVirtualDtor
|
||||
12
.github/workflows/lint-cpp.yml
vendored
12
.github/workflows/lint-cpp.yml
vendored
@@ -13,12 +13,12 @@ on:
|
||||
run-id:
|
||||
type: string
|
||||
description: The workflow ID to download artifacts (skips the build step)
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/lint-cpp.yml"
|
||||
- "**/*.cpp"
|
||||
- "src/deps/**/*"
|
||||
- "CMakeLists.txt"
|
||||
# pull_request:
|
||||
# paths:
|
||||
# - ".github/workflows/lint-cpp.yml"
|
||||
# - "**/*.cpp"
|
||||
# - "src/deps/**/*"
|
||||
# - "CMakeLists.txt"
|
||||
|
||||
jobs:
|
||||
lint-cpp:
|
||||
|
||||
17
.gitignore
vendored
17
.gitignore
vendored
@@ -146,3 +146,20 @@ zig-out
|
||||
test/node.js/upstream
|
||||
.zig-cache
|
||||
scripts/env.local
|
||||
|
||||
# Dependencies
|
||||
/src/bun.js/WebKit
|
||||
/src/deps/boringssl
|
||||
/src/deps/brotli
|
||||
/src/deps/c*ares
|
||||
/src/deps/lol*html
|
||||
/src/deps/libarchive
|
||||
/src/deps/libdeflate
|
||||
/src/deps/libuv
|
||||
/src/deps/ls*hpack
|
||||
/src/deps/mimalloc
|
||||
/src/deps/picohttpparser
|
||||
/src/deps/tinycc
|
||||
/src/deps/zstd
|
||||
/src/deps/zlib
|
||||
/src/deps/zig
|
||||
|
||||
88
.gitmodules
vendored
88
.gitmodules
vendored
@@ -1,88 +0,0 @@
|
||||
[submodule "src/javascript/jsc/WebKit"]
|
||||
path = src/bun.js/WebKit
|
||||
url = https://github.com/oven-sh/WebKit.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
update = none
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/picohttpparser"]
|
||||
path = src/deps/picohttpparser
|
||||
url = https://github.com/h2o/picohttpparser.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/mimalloc"]
|
||||
path = src/deps/mimalloc
|
||||
url = https://github.com/Jarred-Sumner/mimalloc.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/zlib"]
|
||||
path = src/deps/zlib
|
||||
url = https://github.com/cloudflare/zlib.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/libarchive"]
|
||||
path = src/deps/libarchive
|
||||
url = https://github.com/libarchive/libarchive.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/boringssl"]
|
||||
path = src/deps/boringssl
|
||||
url = https://github.com/oven-sh/boringssl.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/lol-html"]
|
||||
path = src/deps/lol-html
|
||||
url = https://github.com/cloudflare/lol-html
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/tinycc"]
|
||||
path = src/deps/tinycc
|
||||
url = https://github.com/Jarred-Sumner/tinycc.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/c-ares"]
|
||||
path = src/deps/c-ares
|
||||
url = https://github.com/c-ares/c-ares.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/zstd"]
|
||||
path = src/deps/zstd
|
||||
url = https://github.com/facebook/zstd.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/ls-hpack"]
|
||||
path = src/deps/ls-hpack
|
||||
url = https://github.com/litespeedtech/ls-hpack.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "zig"]
|
||||
path = src/deps/zig
|
||||
url = https://github.com/oven-sh/zig
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/libdeflate"]
|
||||
path = src/deps/libdeflate
|
||||
url = https://github.com/ebiggers/libdeflate
|
||||
ignore = "dirty"
|
||||
1663
CMakeLists.txt
1663
CMakeLists.txt
File diff suppressed because it is too large
Load Diff
645
Dockerfile
645
Dockerfile
@@ -1,645 +0,0 @@
|
||||
# This Dockerfile is used by CI workflows to build Bun. It is not intended as a development
|
||||
# environment, or to be used as a base image for other projects.
|
||||
#
|
||||
# You likely want this image instead: https://hub.docker.com/r/oven/bun
|
||||
#
|
||||
# TODO: move this file to reduce confusion
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ARG GITHUB_WORKSPACE=/build
|
||||
ARG WEBKIT_DIR=${GITHUB_WORKSPACE}/bun-webkit
|
||||
ARG BUN_RELEASE_DIR=${GITHUB_WORKSPACE}/bun-release
|
||||
ARG BUN_DEPS_OUT_DIR=${GITHUB_WORKSPACE}/bun-deps
|
||||
ARG BUN_DIR=${GITHUB_WORKSPACE}/bun
|
||||
ARG CPU_TARGET=native
|
||||
ARG ARCH=x86_64
|
||||
ARG BUILD_MACHINE_ARCH=x86_64
|
||||
ARG BUILDARCH=amd64
|
||||
ARG TRIPLET=${ARCH}-linux-gnu
|
||||
ARG GIT_SHA=""
|
||||
ARG BUN_VERSION="bun-v1.1.4"
|
||||
ARG BUN_DOWNLOAD_URL_BASE="https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/${BUN_VERSION}"
|
||||
ARG CANARY=0
|
||||
ARG ASSERTIONS=OFF
|
||||
ARG ZIG_OPTIMIZE=ReleaseFast
|
||||
ARG CMAKE_BUILD_TYPE=Release
|
||||
|
||||
ARG NODE_VERSION="20"
|
||||
ARG LLVM_VERSION="16"
|
||||
|
||||
ARG ZIG_VERSION="0.13.0"
|
||||
ARG ZIG_VERSION_SHORT="0.13.0"
|
||||
|
||||
ARG SCCACHE_BUCKET
|
||||
ARG SCCACHE_REGION
|
||||
ARG SCCACHE_S3_USE_SSL
|
||||
ARG SCCACHE_ENDPOINT
|
||||
ARG AWS_ACCESS_KEY_ID
|
||||
ARG AWS_SECRET_ACCESS_KEY
|
||||
|
||||
FROM bitnami/minideb:bullseye as bun-base
|
||||
|
||||
ARG BUN_DOWNLOAD_URL_BASE
|
||||
ARG DEBIAN_FRONTEND
|
||||
ARG BUN_VERSION
|
||||
ARG NODE_VERSION
|
||||
ARG LLVM_VERSION
|
||||
ARG BUILD_MACHINE_ARCH
|
||||
ARG BUN_DIR
|
||||
ARG BUN_DEPS_OUT_DIR
|
||||
ARG CPU_TARGET
|
||||
|
||||
ENV CI 1
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
ENV BUILDARCH=${BUILDARCH}
|
||||
ENV BUN_DEPS_OUT_DIR=${BUN_DEPS_OUT_DIR}
|
||||
ENV USE_LTO 1
|
||||
|
||||
ENV LC_CTYPE=en_US.UTF-8
|
||||
ENV LC_ALL=en_US.UTF-8
|
||||
|
||||
ENV SCCACHE_BUCKET=${SCCACHE_BUCKET}
|
||||
ENV SCCACHE_REGION=${SCCACHE_REGION}
|
||||
ENV SCCACHE_S3_USE_SSL=${SCCACHE_S3_USE_SSL}
|
||||
ENV SCCACHE_ENDPOINT=${SCCACHE_ENDPOINT}
|
||||
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
|
||||
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
|
||||
|
||||
RUN install_packages \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
&& echo "deb https://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-${LLVM_VERSION} main" > /etc/apt/sources.list.d/llvm.list \
|
||||
&& echo "deb-src https://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-${LLVM_VERSION} main" >> /etc/apt/sources.list.d/llvm.list \
|
||||
&& curl -fsSL "https://apt.llvm.org/llvm-snapshot.gpg.key" | apt-key add - \
|
||||
&& echo "deb https://deb.nodesource.com/node_${NODE_VERSION}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
|
||||
&& curl -fsSL "https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key" | apt-key add - \
|
||||
&& echo "deb https://apt.kitware.com/ubuntu/ focal main" > /etc/apt/sources.list.d/kitware.list \
|
||||
&& curl -fsSL "https://apt.kitware.com/keys/kitware-archive-latest.asc" | apt-key add - \
|
||||
&& install_packages \
|
||||
wget \
|
||||
bash \
|
||||
software-properties-common \
|
||||
build-essential \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
pkg-config \
|
||||
clang-${LLVM_VERSION} \
|
||||
lld-${LLVM_VERSION} \
|
||||
lldb-${LLVM_VERSION} \
|
||||
clangd-${LLVM_VERSION} \
|
||||
libc++-${LLVM_VERSION}-dev \
|
||||
libc++abi-${LLVM_VERSION}-dev \
|
||||
llvm-${LLVM_VERSION}-runtime \
|
||||
llvm-${LLVM_VERSION}-dev \
|
||||
make \
|
||||
cmake \
|
||||
ninja-build \
|
||||
file \
|
||||
libc-dev \
|
||||
libxml2 \
|
||||
libxml2-dev \
|
||||
xz-utils \
|
||||
git \
|
||||
tar \
|
||||
rsync \
|
||||
gzip \
|
||||
unzip \
|
||||
perl \
|
||||
python3 \
|
||||
ruby \
|
||||
ruby-dev \
|
||||
golang \
|
||||
nodejs && \
|
||||
for f in /usr/lib/llvm-${LLVM_VERSION}/bin/*; do ln -sf "$f" /usr/bin; done \
|
||||
&& ln -sf /usr/bin/clang-${LLVM_VERSION} /usr/bin/clang \
|
||||
&& ln -sf /usr/bin/clang++-${LLVM_VERSION} /usr/bin/clang++ \
|
||||
&& ln -sf /usr/bin/lld-${LLVM_VERSION} /usr/bin/lld \
|
||||
&& ln -sf /usr/bin/lldb-${LLVM_VERSION} /usr/bin/lldb \
|
||||
&& ln -sf /usr/bin/clangd-${LLVM_VERSION} /usr/bin/clangd \
|
||||
&& ln -sf /usr/bin/llvm-ar-${LLVM_VERSION} /usr/bin/llvm-ar \
|
||||
&& ln -sf /usr/bin/ld.lld /usr/bin/ld \
|
||||
&& ln -sf /usr/bin/llvm-ranlib-${LLVM_VERSION} /usr/bin/ranlib \
|
||||
&& ln -sf /usr/bin/clang /usr/bin/cc \
|
||||
&& ln -sf /usr/bin/clang /usr/bin/c89 \
|
||||
&& ln -sf /usr/bin/clang /usr/bin/c99 \
|
||||
&& ln -sf /usr/bin/clang++ /usr/bin/c++ \
|
||||
&& ln -sf /usr/bin/clang++ /usr/bin/g++ \
|
||||
&& ln -sf /usr/bin/llvm-ar /usr/bin/ar \
|
||||
&& ln -sf /usr/bin/clang /usr/bin/gcc \
|
||||
&& arch="$(dpkg --print-architecture)" \
|
||||
&& case "${arch##*-}" in \
|
||||
amd64) variant="x64";; \
|
||||
arm64) variant="aarch64";; \
|
||||
*) echo "unsupported architecture: $arch"; exit 1 ;; \
|
||||
esac \
|
||||
&& wget "${BUN_DOWNLOAD_URL_BASE}/bun-linux-${variant}.zip" \
|
||||
&& unzip bun-linux-${variant}.zip \
|
||||
&& mv bun-linux-${variant}/bun /usr/bin/bun \
|
||||
&& ln -s /usr/bin/bun /usr/bin/bunx \
|
||||
&& rm -rf bun-linux-${variant} bun-linux-${variant}.zip \
|
||||
&& mkdir -p ${BUN_DIR} ${BUN_DEPS_OUT_DIR}
|
||||
|
||||
# && if [ -n "${SCCACHE_BUCKET}" ]; then \
|
||||
# echo "Setting up sccache" \
|
||||
# && wget https://github.com/mozilla/sccache/releases/download/v0.5.4/sccache-v0.5.4-${BUILD_MACHINE_ARCH}-unknown-linux-musl.tar.gz \
|
||||
# && tar xf sccache-v0.5.4-${BUILD_MACHINE_ARCH}-unknown-linux-musl.tar.gz \
|
||||
# && mv sccache-v0.5.4-${BUILD_MACHINE_ARCH}-unknown-linux-musl/sccache /usr/bin/sccache \
|
||||
# && rm -rf sccache-v0.5.4-${BUILD_MACHINE_ARCH}-unknown-linux-musl.tar.gz sccache-v0.5.4-${BUILD_MACHINE_ARCH}-unknown-linux-musl \
|
||||
|
||||
FROM bun-base as bun-base-with-zig
|
||||
|
||||
ARG ZIG_VERSION
|
||||
ARG ZIG_VERSION_SHORT
|
||||
ARG BUILD_MACHINE_ARCH
|
||||
ARG ZIG_FOLDERNAME=zig-linux-${BUILD_MACHINE_ARCH}-${ZIG_VERSION}
|
||||
ARG ZIG_FILENAME=${ZIG_FOLDERNAME}.tar.xz
|
||||
ARG ZIG_URL="https://ziglang.org/builds/${ZIG_FILENAME}"
|
||||
ARG ZIG_LOCAL_CACHE_DIR=/zig-cache
|
||||
ENV ZIG_LOCAL_CACHE_DIR=${ZIG_LOCAL_CACHE_DIR}
|
||||
|
||||
WORKDIR $GITHUB_WORKSPACE
|
||||
|
||||
ADD $ZIG_URL .
|
||||
RUN tar xf ${ZIG_FILENAME} \
|
||||
&& mv ${ZIG_FOLDERNAME}/lib /usr/lib/zig \
|
||||
&& mv ${ZIG_FOLDERNAME}/zig /usr/bin/zig \
|
||||
&& rm -rf ${ZIG_FILENAME} ${ZIG_FOLDERNAME}
|
||||
|
||||
FROM bun-base as c-ares
|
||||
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
COPY src/deps/c-ares ${BUN_DIR}/src/deps/c-ares
|
||||
COPY scripts ${BUN_DIR}/scripts
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
cd $BUN_DIR \
|
||||
&& bash ./scripts/build-cares.sh \
|
||||
&& rm -rf ${BUN_DIR}/src/deps/c-ares ${BUN_DIR}/Makefile ${BUN_DIR}/scripts
|
||||
|
||||
FROM bun-base as lolhtml
|
||||
|
||||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
COPY src/deps/lol-html ${BUN_DIR}/src/deps/lol-html
|
||||
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
export PATH=$PATH:$HOME/.cargo/bin \
|
||||
&& cd ${BUN_DIR} \
|
||||
&& make lolhtml \
|
||||
&& rm -rf src/deps/lol-html Makefile
|
||||
|
||||
FROM bun-base as mimalloc
|
||||
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
ARG ASSERTIONS
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
COPY src/deps/mimalloc ${BUN_DIR}/src/deps/mimalloc
|
||||
COPY scripts ${BUN_DIR}/scripts
|
||||
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
cd ${BUN_DIR} \
|
||||
&& bash ./scripts/build-mimalloc.sh \
|
||||
&& rm -rf src/deps/mimalloc Makefile
|
||||
|
||||
FROM bun-base as mimalloc-debug
|
||||
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
ARG ASSERTIONS
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
COPY src/deps/mimalloc ${BUN_DIR}/src/deps/mimalloc
|
||||
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
cd ${BUN_DIR} \
|
||||
&& make mimalloc-debug \
|
||||
&& rm -rf src/deps/mimalloc Makefile
|
||||
|
||||
FROM bun-base as zlib
|
||||
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
COPY CMakeLists.txt ${BUN_DIR}/CMakeLists.txt
|
||||
COPY scripts ${BUN_DIR}/scripts
|
||||
COPY src/deps/zlib ${BUN_DIR}/src/deps/zlib
|
||||
COPY package.json bun.lockb Makefile .gitmodules ${BUN_DIR}/
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
cd $BUN_DIR \
|
||||
&& bash ./scripts/build-zlib.sh && rm -rf src/deps/zlib scripts
|
||||
|
||||
|
||||
FROM bun-base as libdeflate
|
||||
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
COPY CMakeLists.txt ${BUN_DIR}/CMakeLists.txt
|
||||
COPY scripts ${BUN_DIR}/scripts
|
||||
COPY src/deps/libdeflate ${BUN_DIR}/src/deps/libdeflate
|
||||
COPY package.json bun.lockb Makefile .gitmodules ${BUN_DIR}/
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
cd $BUN_DIR \
|
||||
&& bash ./scripts/build-libdeflate.sh && rm -rf src/deps/libdeflate scripts
|
||||
|
||||
|
||||
FROM bun-base as libarchive
|
||||
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
RUN install_packages autoconf automake libtool pkg-config
|
||||
|
||||
COPY scripts ${BUN_DIR}/scripts
|
||||
COPY src/deps/libarchive ${BUN_DIR}/src/deps/libarchive
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
cd $BUN_DIR \
|
||||
&& bash ./scripts/build-libarchive.sh && rm -rf src/deps/libarchive .scripts
|
||||
|
||||
FROM bun-base as tinycc
|
||||
|
||||
ARG BUN_DEPS_OUT_DIR
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
RUN install_packages libtcc-dev && cp /usr/lib/$(uname -m)-linux-gnu/libtcc.a ${BUN_DEPS_OUT_DIR}
|
||||
|
||||
FROM bun-base as boringssl
|
||||
|
||||
RUN install_packages golang
|
||||
|
||||
ARG BUN_DIR
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
COPY scripts ${BUN_DIR}/scripts
|
||||
COPY src/deps/boringssl ${BUN_DIR}/src/deps/boringssl
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
cd ${BUN_DIR} \
|
||||
&& bash ./scripts/build-boringssl.sh \
|
||||
&& rm -rf src/deps/boringssl Makefile
|
||||
|
||||
|
||||
FROM bun-base as zstd
|
||||
|
||||
ARG BUN_DIR
|
||||
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
COPY src/deps/zstd ${BUN_DIR}/src/deps/zstd
|
||||
COPY scripts ${BUN_DIR}/scripts
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
cd $BUN_DIR \
|
||||
&& bash ./scripts/build-zstd.sh \
|
||||
&& rm -rf src/deps/zstd scripts
|
||||
|
||||
FROM bun-base as ls-hpack
|
||||
|
||||
ARG BUN_DIR
|
||||
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
COPY Makefile ${BUN_DIR}/Makefile
|
||||
COPY src/deps/ls-hpack ${BUN_DIR}/src/deps/ls-hpack
|
||||
COPY scripts ${BUN_DIR}/scripts
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
cd $BUN_DIR \
|
||||
&& bash ./scripts/build-lshpack.sh \
|
||||
&& rm -rf src/deps/ls-hpack scripts
|
||||
|
||||
FROM bun-base-with-zig as bun-identifier-cache
|
||||
|
||||
ARG DEBIAN_FRONTEND
|
||||
ARG GITHUB_WORKSPACE
|
||||
ARG CPU_TARGET
|
||||
ARG BUN_DIR
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
COPY src/js_lexer/identifier_data.zig ${BUN_DIR}/src/js_lexer/identifier_data.zig
|
||||
COPY src/js_lexer/identifier_cache.zig ${BUN_DIR}/src/js_lexer/identifier_cache.zig
|
||||
|
||||
RUN --mount=type=cache,target=${ZIG_LOCAL_CACHE_DIR} \
|
||||
cd $BUN_DIR \
|
||||
&& zig run src/js_lexer/identifier_data.zig
|
||||
|
||||
FROM bun-base as bun-node-fallbacks
|
||||
|
||||
ARG BUN_DIR
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
COPY src/node-fallbacks ${BUN_DIR}/src/node-fallbacks
|
||||
|
||||
RUN cd $BUN_DIR/src/node-fallbacks \
|
||||
&& bun install --frozen-lockfile \
|
||||
&& bun run build \
|
||||
&& rm -rf src/node-fallbacks/node_modules
|
||||
|
||||
FROM bun-base as bun-webkit
|
||||
|
||||
ARG BUILDARCH
|
||||
ARG ASSERTIONS
|
||||
|
||||
COPY CMakeLists.txt ${BUN_DIR}/CMakeLists.txt
|
||||
|
||||
RUN mkdir ${BUN_DIR}/bun-webkit \
|
||||
&& WEBKIT_TAG=$(grep 'set(WEBKIT_TAG' "${BUN_DIR}/CMakeLists.txt" | awk '{print $2}' | cut -f 1 -d ')') \
|
||||
&& WEBKIT_SUFFIX=$(if [ "${ASSERTIONS}" = "ON" ]; then echo "debug"; else echo "lto"; fi) \
|
||||
&& WEBKIT_URL="https://github.com/oven-sh/WebKit/releases/download/autobuild-${WEBKIT_TAG}/bun-webkit-linux-${BUILDARCH}-${WEBKIT_SUFFIX}.tar.gz" \
|
||||
&& echo "Downloading ${WEBKIT_URL}" \
|
||||
&& curl -fsSL "${WEBKIT_URL}" | tar -xz -C ${BUN_DIR}/bun-webkit --strip-components=1
|
||||
|
||||
FROM bun-base as bun-cpp-objects
|
||||
|
||||
ARG CANARY
|
||||
ARG ASSERTIONS
|
||||
|
||||
COPY --from=bun-webkit ${BUN_DIR}/bun-webkit ${BUN_DIR}/bun-webkit
|
||||
|
||||
COPY packages ${BUN_DIR}/packages
|
||||
COPY src ${BUN_DIR}/src
|
||||
COPY CMakeLists.txt ${BUN_DIR}/CMakeLists.txt
|
||||
COPY src/deps/boringssl/include ${BUN_DIR}/src/deps/boringssl/include
|
||||
|
||||
# for uWebSockets
|
||||
COPY src/deps/libdeflate ${BUN_DIR}/src/deps/libdeflate
|
||||
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} mkdir ${BUN_DIR}/build \
|
||||
&& cd ${BUN_DIR}/build \
|
||||
&& mkdir -p tmp_modules tmp_functions js codegen \
|
||||
&& cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DUSE_LTO=ON -DUSE_DEBUG_JSC=${ASSERTIONS} -DBUN_CPP_ONLY=1 -DWEBKIT_DIR=/build/bun/bun-webkit -DCANARY=${CANARY} -DZIG_COMPILER=system \
|
||||
&& bash compile-cpp-only.sh -v
|
||||
|
||||
FROM bun-base-with-zig as bun-codegen-for-zig
|
||||
|
||||
COPY package.json bun.lockb Makefile .gitmodules ${BUN_DIR}/
|
||||
COPY src/runtime ${BUN_DIR}/src/runtime
|
||||
COPY src/runtime.js src/runtime.bun.js ${BUN_DIR}/src/
|
||||
COPY packages/bun-error ${BUN_DIR}/packages/bun-error
|
||||
COPY packages/bun-types ${BUN_DIR}/packages/bun-types
|
||||
COPY src/fallback.ts ${BUN_DIR}/src/fallback.ts
|
||||
COPY src/api ${BUN_DIR}/src/api
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
# TODO: move away from Makefile entirely
|
||||
RUN --mount=type=cache,target=${ZIG_LOCAL_CACHE_DIR} \
|
||||
bun install --frozen-lockfile \
|
||||
&& make runtime_js fallback_decoder bun_error \
|
||||
&& rm -rf src/runtime src/fallback.ts node_modules bun.lockb package.json Makefile
|
||||
|
||||
FROM bun-base-with-zig as bun-compile-zig-obj
|
||||
|
||||
ARG ZIG_PATH
|
||||
ARG TRIPLET
|
||||
ARG GIT_SHA
|
||||
ARG CPU_TARGET
|
||||
ARG CANARY=0
|
||||
ARG ASSERTIONS=OFF
|
||||
ARG ZIG_OPTIMIZE=ReleaseFast
|
||||
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
|
||||
COPY *.zig package.json CMakeLists.txt ${BUN_DIR}/
|
||||
COPY completions ${BUN_DIR}/completions
|
||||
COPY packages ${BUN_DIR}/packages
|
||||
COPY src ${BUN_DIR}/src
|
||||
|
||||
COPY --from=bun-identifier-cache ${BUN_DIR}/src/js_lexer/*.blob ${BUN_DIR}/src/js_lexer/
|
||||
COPY --from=bun-node-fallbacks ${BUN_DIR}/src/node-fallbacks/out ${BUN_DIR}/src/node-fallbacks/out
|
||||
COPY --from=bun-codegen-for-zig ${BUN_DIR}/src/*.out.js ${BUN_DIR}/src/*.out.refresh.js ${BUN_DIR}/src/
|
||||
COPY --from=bun-codegen-for-zig ${BUN_DIR}/packages/bun-error/dist ${BUN_DIR}/packages/bun-error/dist
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
--mount=type=cache,target=${ZIG_LOCAL_CACHE_DIR} \
|
||||
mkdir -p build \
|
||||
&& bun run $BUN_DIR/src/codegen/bundle-modules.ts --debug=OFF $BUN_DIR/build \
|
||||
&& cd build \
|
||||
&& cmake .. \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DUSE_LTO=ON \
|
||||
-DZIG_OPTIMIZE="${ZIG_OPTIMIZE}" \
|
||||
-DCPU_TARGET="${CPU_TARGET}" \
|
||||
-DZIG_TARGET="${TRIPLET}" \
|
||||
-DWEBKIT_DIR="omit" \
|
||||
-DNO_CONFIGURE_DEPENDS=1 \
|
||||
-DNO_CODEGEN=1 \
|
||||
-DBUN_ZIG_OBJ_DIR="/tmp" \
|
||||
-DCANARY="${CANARY}" \
|
||||
-DZIG_COMPILER=system \
|
||||
-DZIG_LIB_DIR=$BUN_DIR/src/deps/zig/lib \
|
||||
&& ONLY_ZIG=1 ninja "/tmp/bun-zig.o" -v
|
||||
|
||||
FROM scratch as build_release_obj
|
||||
|
||||
ARG CPU_TARGET
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
|
||||
COPY --from=bun-compile-zig-obj /tmp/bun-zig.o /
|
||||
|
||||
FROM bun-base as bun-link
|
||||
|
||||
ARG CPU_TARGET
|
||||
ARG CANARY
|
||||
ARG ASSERTIONS
|
||||
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
ARG ZIG_LOCAL_CACHE_DIR=/zig-cache
|
||||
ENV ZIG_LOCAL_CACHE_DIR=${ZIG_LOCAL_CACHE_DIR}
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
RUN mkdir -p build bun-webkit
|
||||
|
||||
# lol
|
||||
COPY src/bun.js/bindings/sqlite/sqlite3.c ${BUN_DIR}/src/bun.js/bindings/sqlite/sqlite3.c
|
||||
COPY src/deps/brotli ${BUN_DIR}/src/deps/brotli
|
||||
|
||||
COPY src/symbols.dyn src/linker.lds ${BUN_DIR}/src/
|
||||
|
||||
COPY CMakeLists.txt ${BUN_DIR}/CMakeLists.txt
|
||||
COPY --from=zlib ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=libdeflate ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=libarchive ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=boringssl ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=lolhtml ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=mimalloc ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=zstd ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=tinycc ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=c-ares ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=ls-hpack ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=bun-compile-zig-obj /tmp/bun-zig.o ${BUN_DIR}/build/bun-zig.o
|
||||
COPY --from=bun-cpp-objects ${BUN_DIR}/build/*.a ${BUN_DIR}/build/
|
||||
COPY --from=bun-cpp-objects ${BUN_DIR}/build/*.o ${BUN_DIR}/build/
|
||||
COPY --from=bun-cpp-objects ${BUN_DIR}/bun-webkit/lib ${BUN_DIR}/bun-webkit/lib
|
||||
|
||||
WORKDIR $BUN_DIR/build
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
--mount=type=cache,target=${ZIG_LOCAL_CACHE_DIR} \
|
||||
cmake .. \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUN_LINK_ONLY=1 \
|
||||
-DBUN_ZIG_OBJ_DIR="${BUN_DIR}/build" \
|
||||
-DUSE_LTO=ON \
|
||||
-DUSE_DEBUG_JSC=${ASSERTIONS} \
|
||||
-DBUN_CPP_ARCHIVE="${BUN_DIR}/build/bun-cpp-objects.a" \
|
||||
-DWEBKIT_DIR="${BUN_DIR}/bun-webkit" \
|
||||
-DBUN_DEPS_OUT_DIR="${BUN_DEPS_OUT_DIR}" \
|
||||
-DCPU_TARGET="${CPU_TARGET}" \
|
||||
-DNO_CONFIGURE_DEPENDS=1 \
|
||||
-DCANARY="${CANARY}" \
|
||||
-DZIG_COMPILER=system \
|
||||
&& ninja -v \
|
||||
&& ./bun --revision \
|
||||
&& mkdir -p /build/out \
|
||||
&& mv bun bun-profile /build/out \
|
||||
&& rm -rf ${BUN_DIR} ${BUN_DEPS_OUT_DIR}
|
||||
|
||||
FROM scratch as artifact
|
||||
|
||||
COPY --from=bun-link /build/out /
|
||||
|
||||
FROM bun-base as bun-link-assertions
|
||||
|
||||
ARG CPU_TARGET
|
||||
ARG CANARY
|
||||
ARG ASSERTIONS
|
||||
|
||||
ENV CPU_TARGET=${CPU_TARGET}
|
||||
ARG CCACHE_DIR=/ccache
|
||||
ENV CCACHE_DIR=${CCACHE_DIR}
|
||||
ARG ZIG_LOCAL_CACHE_DIR=/zig-cache
|
||||
ENV ZIG_LOCAL_CACHE_DIR=${ZIG_LOCAL_CACHE_DIR}
|
||||
|
||||
WORKDIR $BUN_DIR
|
||||
|
||||
RUN mkdir -p build bun-webkit
|
||||
|
||||
# lol
|
||||
COPY src/bun.js/bindings/sqlite/sqlite3.c ${BUN_DIR}/src/bun.js/bindings/sqlite/sqlite3.c
|
||||
|
||||
COPY src/symbols.dyn src/linker.lds ${BUN_DIR}/src/
|
||||
|
||||
COPY CMakeLists.txt ${BUN_DIR}/CMakeLists.txt
|
||||
COPY --from=zlib ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=libarchive ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=boringssl ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=lolhtml ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=mimalloc-debug ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=zstd ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=tinycc ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=c-ares ${BUN_DEPS_OUT_DIR}/* ${BUN_DEPS_OUT_DIR}/
|
||||
COPY --from=bun-compile-zig-obj /tmp/bun-zig.o ${BUN_DIR}/build/bun-zig.o
|
||||
COPY --from=bun-cpp-objects ${BUN_DIR}/build/bun-cpp-objects.a ${BUN_DIR}/build/bun-cpp-objects.a
|
||||
COPY --from=bun-cpp-objects ${BUN_DIR}/bun-webkit/lib ${BUN_DIR}/bun-webkit/lib
|
||||
|
||||
WORKDIR $BUN_DIR/build
|
||||
|
||||
RUN --mount=type=cache,target=${CCACHE_DIR} \
|
||||
--mount=type=cache,target=${ZIG_LOCAL_CACHE_DIR} \
|
||||
cmake .. \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUN_LINK_ONLY=1 \
|
||||
-DBUN_ZIG_OBJ_DIR="${BUN_DIR}/build" \
|
||||
-DUSE_DEBUG_JSC=ON \
|
||||
-DBUN_CPP_ARCHIVE="${BUN_DIR}/build/bun-cpp-objects.a" \
|
||||
-DWEBKIT_DIR="${BUN_DIR}/bun-webkit" \
|
||||
-DBUN_DEPS_OUT_DIR="${BUN_DEPS_OUT_DIR}" \
|
||||
-DCPU_TARGET="${CPU_TARGET}" \
|
||||
-DNO_CONFIGURE_DEPENDS=1 \
|
||||
-DCANARY="${CANARY}" \
|
||||
-DZIG_COMPILER=system \
|
||||
-DUSE_LTO=ON \
|
||||
&& ninja -v \
|
||||
&& ./bun --revision \
|
||||
&& mkdir -p /build/out \
|
||||
&& mv bun bun-profile /build/out \
|
||||
&& rm -rf ${BUN_DIR} ${BUN_DEPS_OUT_DIR}
|
||||
|
||||
FROM scratch as artifact-assertions
|
||||
|
||||
COPY --from=bun-link-assertions /build/out /
|
||||
7
Makefile
7
Makefile
@@ -1,3 +1,10 @@
|
||||
# ------------------------------------------------------------
|
||||
# WARNING
|
||||
# ------------------------------------------------------------
|
||||
# This file is very old and will be removed soon!
|
||||
# You can build Bun using `cmake` or `bun run build`
|
||||
# ------------------------------------------------------------
|
||||
|
||||
SHELL := $(shell which bash) # Use bash syntax to be consistent
|
||||
|
||||
OS_NAME := $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
145
cmake/CompilerFlags.cmake
Normal file
145
cmake/CompilerFlags.cmake
Normal file
@@ -0,0 +1,145 @@
|
||||
include(Macros)
|
||||
|
||||
# clang: https://clang.llvm.org/docs/CommandGuide/clang.html
|
||||
# clang-cl: https://clang.llvm.org/docs/UsersManual.html#id11
|
||||
|
||||
# --- MSVC runtime ---
|
||||
|
||||
if(WIN32)
|
||||
if(DEBUG)
|
||||
add_compile_options(/MTd) # Use static debug run-time
|
||||
else()
|
||||
add_compile_options(/MT) # Use static run-time
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# --- Optimization level ---
|
||||
|
||||
if(DEBUG)
|
||||
if(WIN32)
|
||||
add_compile_options(/O0)
|
||||
else()
|
||||
add_compile_options(-O0)
|
||||
endif()
|
||||
elseif(ENABLE_SMOL)
|
||||
if(WIN32)
|
||||
add_compile_options(/Os)
|
||||
else()
|
||||
add_compile_options(-Os)
|
||||
endif()
|
||||
else()
|
||||
if(WIN32)
|
||||
# TODO: change to /0t (same as -O3) to match macOS and Linux?
|
||||
add_compile_options(/O2)
|
||||
else()
|
||||
add_compile_options(-O3)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# --- Debug symbols ---
|
||||
|
||||
if(WIN32)
|
||||
add_compile_options(
|
||||
/Z7 # Produce a .pdb file
|
||||
)
|
||||
else()
|
||||
add_compile_options(
|
||||
-ggdb # Produce a format that is compatable with GDB
|
||||
-gdwarf-4 # Produce DWARF v4 debug info
|
||||
)
|
||||
if(DEBUG)
|
||||
add_compile_options(-g3)
|
||||
else()
|
||||
add_compile_options(-g1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# TODO: consider other debug options
|
||||
# -fdebug-macro # Emit debug info for macros
|
||||
# -fstandalone-debug # Emit debug info for non-system libraries
|
||||
# -fno-eliminate-unused-debug-types # Don't eliminate unused debug symbols
|
||||
|
||||
# --- RTTI ---
|
||||
|
||||
if(WIN32)
|
||||
add_compile_options(/GR-)
|
||||
else()
|
||||
add_compile_options(-fno-rtti)
|
||||
endif()
|
||||
|
||||
# --- CPU target (-march, -mtune, -mcpu) ---
|
||||
|
||||
# Using -march=native can break older systems, instead use a specific CPU
|
||||
if(CPU STREQUAL "native")
|
||||
if(ARCH STREQUAL "aarch64")
|
||||
if(APPLE)
|
||||
add_compile_options(-mcpu=apple-m1)
|
||||
else()
|
||||
add_compile_options(-march=armv8-a+crc -mtune=ampere1)
|
||||
endif()
|
||||
endif()
|
||||
elseif(CPU)
|
||||
add_compile_options(-march=${CPU} -mtune=${CPU})
|
||||
else()
|
||||
message(FATAL_ERROR "No CPU specified, please set -DCPU=<string>")
|
||||
endif()
|
||||
|
||||
# --- Diagnostics ---
|
||||
|
||||
if(NOT WIN32)
|
||||
add_compile_options(-fdiagnostics-color=always)
|
||||
endif()
|
||||
|
||||
add_compile_options(-ferror-limit=${ERROR_LIMIT})
|
||||
|
||||
# --- Remapping ---
|
||||
|
||||
if(NOT WIN32)
|
||||
add_compile_options(
|
||||
-ffile-prefix-map=${CWD}=.
|
||||
-ffile-prefix-map=${BUILD_PATH}=build
|
||||
-ffile-prefix-map=${CACHE_PATH}=cache
|
||||
)
|
||||
endif()
|
||||
|
||||
# --- Features ---
|
||||
|
||||
# Valgrind cannot handle SSE4.2 instructions
|
||||
# This is needed for picohttpparser
|
||||
if(ENABLE_VALGRIND AND ARCH STREQUAL "x64")
|
||||
add_compile_definitions("__SSE4_2__=0")
|
||||
endif()
|
||||
|
||||
# --- Other ---
|
||||
|
||||
# Workaround for CMake and clang-cl bug.
|
||||
# https://github.com/ninja-build/ninja/issues/2280
|
||||
if(WIN32 AND NOT CMAKE_CL_SHOWINCLUDES_PREFIX)
|
||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file:")
|
||||
endif()
|
||||
|
||||
if(ENABLE_ASSERTIONS)
|
||||
if(APPLE)
|
||||
# add_compile_definitions("_LIBCXX_ENABLE_ASSERTIONS=1")
|
||||
# add_compile_definitions("_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_compile_definitions("_GLIBCXX_ASSERTIONS=1")
|
||||
endif()
|
||||
|
||||
add_compile_definitions("ASSERT_ENABLED=1")
|
||||
else()
|
||||
if(APPLE)
|
||||
# add_compile_definitions("_LIBCXX_ENABLE_ASSERTIONS=0")
|
||||
# add_compile_definitions("_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE")
|
||||
endif()
|
||||
|
||||
add_compile_definitions("NDEBUG=1")
|
||||
endif()
|
||||
|
||||
# WebKit uses -std=gnu++20 on non-macOS non-Windows.
|
||||
# If we do not set this, it will crash at startup on the first memory allocation.
|
||||
if(NOT WIN32 AND NOT APPLE)
|
||||
set(CMAKE_CXX_EXTENSIONS ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
||||
endif()
|
||||
|
||||
704
cmake/Macros.cmake
Normal file
704
cmake/Macros.cmake
Normal file
@@ -0,0 +1,704 @@
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(parse_semver value variable)
|
||||
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" match "${value}")
|
||||
|
||||
if(NOT match)
|
||||
message(FATAL_ERROR "Invalid semver: \"${value}\"")
|
||||
endif()
|
||||
|
||||
set(${variable}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" PARENT_SCOPE)
|
||||
set(${variable}_VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE)
|
||||
set(${variable}_VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE)
|
||||
set(${variable}_VERSION_PATCH "${CMAKE_MATCH_3}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# setx()
|
||||
# Description:
|
||||
# Sets a variable, similar to `set()`, but also prints the value.
|
||||
# Arguments:
|
||||
# variable string - The variable to set
|
||||
# value string - The value to set the variable to
|
||||
macro(setx)
|
||||
set(${ARGV})
|
||||
message(STATUS "Set ${ARGV0}: ${${ARGV0}}")
|
||||
endmacro()
|
||||
|
||||
# setenv()
|
||||
# Description:
|
||||
# Sets an environment variable during the build step, and writes it to a .env file.
|
||||
# Arguments:
|
||||
# variable string - The variable to set
|
||||
# value string - The value to set the variable to
|
||||
function(setenv variable value)
|
||||
set(ENV_PATH ${BUILD_PATH}/.env)
|
||||
if(value MATCHES "/|\\\\")
|
||||
file(TO_NATIVE_PATH ${value} value)
|
||||
endif()
|
||||
set(ENV_LINE "${variable}=${value}")
|
||||
|
||||
if(EXISTS ${ENV_PATH})
|
||||
file(STRINGS ${ENV_PATH} ENV_FILE ENCODING UTF-8)
|
||||
|
||||
foreach(line ${ENV_FILE})
|
||||
if(line MATCHES "^${variable}=")
|
||||
list(REMOVE_ITEM ENV_FILE ${line})
|
||||
set(ENV_MODIFIED ON)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(ENV_MODIFIED)
|
||||
list(APPEND ENV_FILE "${variable}=${value}")
|
||||
list(JOIN ENV_FILE "\n" ENV_FILE)
|
||||
file(WRITE ${ENV_PATH} ${ENV_FILE})
|
||||
else()
|
||||
file(APPEND ${ENV_PATH} "\n${variable}=${value}")
|
||||
endif()
|
||||
else()
|
||||
file(WRITE ${ENV_PATH} ${ENV_LINE})
|
||||
endif()
|
||||
|
||||
message(STATUS "Set ENV ${variable}: ${value}")
|
||||
endfunction()
|
||||
|
||||
# optionx()
|
||||
# Description:
|
||||
# Defines an option, similar to `option()`, but allows for bool, string, and regex types.
|
||||
# Arguments:
|
||||
# variable string - The variable to set
|
||||
# type string - The type of the variable
|
||||
# description string - The description of the variable
|
||||
# DEFAULT string - The default value of the variable
|
||||
# PREVIEW string - The preview value of the variable
|
||||
# REGEX string - The regex to match the value
|
||||
# REQUIRED bool - Whether the variable is required
|
||||
macro(optionx variable type description)
|
||||
set(options REQUIRED)
|
||||
set(oneValueArgs DEFAULT PREVIEW REGEX)
|
||||
set(multiValueArgs)
|
||||
cmake_parse_arguments(${variable} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT ${type} MATCHES "^(BOOL|STRING|FILEPATH|PATH|INTERNAL)$")
|
||||
set(${variable}_REGEX ${type})
|
||||
set(${variable}_TYPE STRING)
|
||||
else()
|
||||
set(${variable}_TYPE ${type})
|
||||
endif()
|
||||
|
||||
set(${variable} ${${variable}_DEFAULT} CACHE ${${variable}_TYPE} ${description})
|
||||
set(${variable}_SOURCE "argument")
|
||||
set(${variable}_PREVIEW -D${variable})
|
||||
|
||||
if(DEFINED ENV{${variable}})
|
||||
# if(DEFINED ${variable} AND NOT ${variable} STREQUAL $ENV{${variable}})
|
||||
# message(FATAL_ERROR "Invalid ${${variable}_SOURCE}: ${${variable}_PREVIEW}=\"${${variable}}\" conflicts with environment variable ${variable}=\"$ENV{${variable}}\"")
|
||||
# endif()
|
||||
|
||||
set(${variable} $ENV{${variable}} CACHE ${${variable}_TYPE} ${description} FORCE)
|
||||
set(${variable}_SOURCE "environment variable")
|
||||
set(${variable}_PREVIEW ${variable})
|
||||
endif()
|
||||
|
||||
if(NOT ${variable} AND ${${variable}_REQUIRED})
|
||||
message(FATAL_ERROR "Required ${${variable}_SOURCE} is missing: please set, ${${variable}_PREVIEW}=<${${variable}_REGEX}>")
|
||||
endif()
|
||||
|
||||
if(${type} STREQUAL "BOOL")
|
||||
if("${${variable}}" MATCHES "^(TRUE|true|ON|on|YES|yes|1)$")
|
||||
set(${variable} ON)
|
||||
elseif("${${variable}}" MATCHES "^(FALSE|false|OFF|off|NO|no|0)$")
|
||||
set(${variable} OFF)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid ${${variable}_SOURCE}: ${${variable}_PREVIEW}=\"${${variable}}\", please use ${${variable}_PREVIEW}=<ON|OFF>")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED ${variable}_REGEX AND NOT "^(${${variable}_REGEX})$" MATCHES "${${variable}}")
|
||||
message(FATAL_ERROR "Invalid ${${variable}_SOURCE}: ${${variable}_PREVIEW}=\"${${variable}}\", please use ${${variable}_PREVIEW}=<${${variable}_REGEX}>")
|
||||
endif()
|
||||
|
||||
message(STATUS "Set ${variable}: ${${variable}}")
|
||||
endmacro()
|
||||
|
||||
# check_command()
|
||||
# Description:
|
||||
# Checks if a command is available, used by `find_command()` as a validator.
|
||||
# Arguments:
|
||||
# FOUND bool - The variable to set to true if the version is found
|
||||
# CMD string - The executable to check the version of
|
||||
function(check_command FOUND CMD)
|
||||
set(${FOUND} OFF PARENT_SCOPE)
|
||||
|
||||
if(${CMD} MATCHES "zig")
|
||||
set(CHECK_COMMAND ${CMD} version)
|
||||
else()
|
||||
set(CHECK_COMMAND ${CMD} --version)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CHECK_COMMAND}
|
||||
RESULT_VARIABLE RESULT
|
||||
OUTPUT_VARIABLE OUTPUT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if(NOT RESULT EQUAL 0)
|
||||
message(DEBUG "${CHECK_COMMAND}, exited with code ${RESULT}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
parse_semver(${OUTPUT} CMD)
|
||||
parse_semver(${CHECK_COMMAND_VERSION} CHECK)
|
||||
|
||||
if(CHECK_COMMAND_VERSION MATCHES ">=")
|
||||
if(NOT CMD_VERSION VERSION_GREATER_EQUAL ${CHECK_VERSION})
|
||||
message(DEBUG "${CHECK_COMMAND}, actual: ${CMD_VERSION}, expected: ${CHECK_COMMAND_VERSION}")
|
||||
return()
|
||||
endif()
|
||||
elseif(CHECK_COMMAND_VERSION MATCHES ">")
|
||||
if(NOT CMD_VERSION VERSION_GREATER ${CHECK_VERSION})
|
||||
message(DEBUG "${CHECK_COMMAND}, actual: ${CMD_VERSION}, expected: ${CHECK_COMMAND_VERSION}")
|
||||
return()
|
||||
endif()
|
||||
else()
|
||||
if(NOT CMD_VERSION VERSION_EQUAL ${CHECK_VERSION})
|
||||
message(DEBUG "${CHECK_COMMAND}, actual: ${CMD_VERSION}, expected: =${CHECK_COMMAND_VERSION}")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(${FOUND} TRUE PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# find_command()
|
||||
# Description:
|
||||
# Finds a command, similar to `find_program()`, but allows for version checking.
|
||||
# Arguments:
|
||||
# VARIABLE string - The variable to set
|
||||
# COMMAND string[] - The names of the command to find
|
||||
# PATHS string[] - The paths to search for the command
|
||||
# REQUIRED bool - If false, the command is optional
|
||||
# VERSION string - The version of the command to find (e.g. "1.2.3" or ">1.2.3")
|
||||
function(find_command)
|
||||
set(options)
|
||||
set(args VARIABLE VERSION MIN_VERSION REQUIRED)
|
||||
set(multiArgs COMMAND PATHS)
|
||||
cmake_parse_arguments(CMD "${options}" "${args}" "${multiArgs}" ${ARGN})
|
||||
|
||||
if(NOT CMD_VARIABLE)
|
||||
message(FATAL_ERROR "find_command: VARIABLE is required")
|
||||
endif()
|
||||
|
||||
if(NOT CMD_COMMAND)
|
||||
message(FATAL_ERROR "find_command: COMMAND is required")
|
||||
endif()
|
||||
|
||||
if(CMD_VERSION)
|
||||
set(CHECK_COMMAND_VERSION ${CMD_VERSION}) # special global variable
|
||||
set(CMD_VALIDATOR VALIDATOR check_command)
|
||||
endif()
|
||||
|
||||
find_program(
|
||||
${CMD_VARIABLE}
|
||||
NAMES ${CMD_COMMAND}
|
||||
PATHS ${CMD_PATHS}
|
||||
${CMD_VALIDATOR}
|
||||
)
|
||||
|
||||
if(NOT CMD_REQUIRED STREQUAL "OFF" AND ${CMD_VARIABLE} MATCHES "NOTFOUND")
|
||||
if(CMD_VERSION)
|
||||
message(FATAL_ERROR "Command not found: \"${CMD_COMMAND}\" that matches version \"${CHECK_COMMAND_VERSION}\"")
|
||||
endif()
|
||||
message(FATAL_ERROR "Command not found: \"${CMD_COMMAND}\"")
|
||||
endif()
|
||||
|
||||
setx(${CMD_VARIABLE} ${${CMD_VARIABLE}})
|
||||
endfunction()
|
||||
|
||||
# register_command()
|
||||
# Description:
|
||||
# Registers a command, similar to `add_custom_command()`, but has more validation and features.
|
||||
# Arguments:
|
||||
# COMMAND string[] - The command to run
|
||||
# COMMENT string - The comment to display in the log
|
||||
# CWD string - The working directory to run the command in
|
||||
# ENVIRONMENT string[] - The environment variables to set (e.g. "DEBUG=1")
|
||||
# TARGETS string[] - The targets that this command depends on
|
||||
# SOURCES string[] - The files that this command depends on
|
||||
# OUTPUTS string[] - The files that this command produces
|
||||
# ARTIFACTS string[] - The files that this command produces, and uploads as an artifact in CI
|
||||
# ALWAYS_RUN bool - If true, the command will always run
|
||||
# TARGET string - The target to register the command with
|
||||
# TARGET_PHASE string - The target phase to register the command with (e.g. PRE_BUILD, PRE_LINK, POST_BUILD)
|
||||
# GROUP string - The group to register the command with (e.g. similar to JOB_POOL)
|
||||
function(register_command)
|
||||
set(options ALWAYS_RUN)
|
||||
set(args COMMENT CWD TARGET TARGET_PHASE GROUP)
|
||||
set(multiArgs COMMAND ENVIRONMENT TARGETS SOURCES OUTPUTS ARTIFACTS)
|
||||
cmake_parse_arguments(CMD "${options}" "${args}" "${multiArgs}" ${ARGN})
|
||||
|
||||
if(NOT CMD_COMMAND)
|
||||
message(FATAL_ERROR "register_command: COMMAND is required")
|
||||
endif()
|
||||
|
||||
if(NOT CMD_CWD)
|
||||
set(CMD_CWD ${CWD})
|
||||
endif()
|
||||
|
||||
if(CMD_ENVIRONMENT)
|
||||
set(CMD_COMMAND ${CMAKE_COMMAND} -E env ${CMD_ENVIRONMENT} ${CMD_COMMAND})
|
||||
endif()
|
||||
|
||||
if(NOT CMD_COMMENT)
|
||||
string(JOIN " " CMD_COMMENT ${CMD_COMMAND})
|
||||
endif()
|
||||
|
||||
set(CMD_COMMANDS COMMAND ${CMD_COMMAND})
|
||||
set(CMD_EFFECTIVE_DEPENDS)
|
||||
|
||||
list(GET CMD_COMMAND 0 CMD_EXECUTABLE)
|
||||
if(CMD_EXECUTABLE MATCHES "/|\\\\")
|
||||
list(APPEND CMD_EFFECTIVE_DEPENDS ${CMD_EXECUTABLE})
|
||||
endif()
|
||||
|
||||
foreach(target ${CMD_TARGETS})
|
||||
if(target MATCHES "/|\\\\")
|
||||
message(FATAL_ERROR "register_command: TARGETS contains \"${target}\", if it's a path add it to SOURCES instead")
|
||||
endif()
|
||||
if(NOT TARGET ${target})
|
||||
message(FATAL_ERROR "register_command: TARGETS contains \"${target}\", but it's not a target")
|
||||
endif()
|
||||
list(APPEND CMD_EFFECTIVE_DEPENDS ${target})
|
||||
endforeach()
|
||||
|
||||
foreach(source ${CMD_SOURCES})
|
||||
if(NOT source MATCHES "^(${CWD}|${BUILD_PATH})")
|
||||
message(FATAL_ERROR "register_command: SOURCES contains \"${source}\", if it's a path, make it absolute, otherwise add it to TARGETS instead")
|
||||
endif()
|
||||
list(APPEND CMD_EFFECTIVE_DEPENDS ${source})
|
||||
endforeach()
|
||||
|
||||
if(NOT CMD_EFFECTIVE_DEPENDS AND NOT CMD_ALWAYS_RUN)
|
||||
message(FATAL_ERROR "register_command: TARGETS or SOURCES is required")
|
||||
endif()
|
||||
|
||||
set(CMD_EFFECTIVE_OUTPUTS)
|
||||
|
||||
foreach(output ${CMD_OUTPUTS})
|
||||
if(NOT output MATCHES "^(${CWD}|${BUILD_PATH})")
|
||||
message(FATAL_ERROR "register_command: OUTPUTS contains \"${output}\", if it's a path, make it absolute")
|
||||
endif()
|
||||
list(APPEND CMD_EFFECTIVE_OUTPUTS ${output})
|
||||
endforeach()
|
||||
|
||||
foreach(artifact ${CMD_ARTIFACTS})
|
||||
if(NOT artifact MATCHES "^(${CWD}|${BUILD_PATH})")
|
||||
message(FATAL_ERROR "register_command: ARTIFACTS contains \"${artifact}\", if it's a path, make it absolute")
|
||||
endif()
|
||||
list(APPEND CMD_EFFECTIVE_OUTPUTS ${artifact})
|
||||
if(BUILDKITE)
|
||||
file(RELATIVE_PATH filename ${BUILD_PATH} ${artifact})
|
||||
list(APPEND CMD_COMMANDS COMMAND ${CMAKE_COMMAND} -E chdir ${BUILD_PATH} buildkite-agent artifact upload ${filename})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(output ${CMD_EFFECTIVE_OUTPUTS})
|
||||
get_source_file_property(generated ${output} GENERATED)
|
||||
if(generated)
|
||||
list(REMOVE_ITEM CMD_EFFECTIVE_OUTPUTS ${output})
|
||||
list(APPEND CMD_EFFECTIVE_OUTPUTS ${output}.always_run)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(CMD_ALWAYS_RUN)
|
||||
list(APPEND CMD_EFFECTIVE_OUTPUTS ${CMD_CWD}/.always_run)
|
||||
endif()
|
||||
|
||||
if(CMD_TARGET_PHASE)
|
||||
if(NOT CMD_TARGET)
|
||||
message(FATAL_ERROR "register_command: TARGET is required when TARGET_PHASE is set")
|
||||
endif()
|
||||
if(NOT TARGET ${CMD_TARGET})
|
||||
message(FATAL_ERROR "register_command: TARGET is not a valid target: ${CMD_TARGET}")
|
||||
endif()
|
||||
add_custom_command(
|
||||
TARGET ${CMD_TARGET} ${CMD_TARGET_PHASE}
|
||||
COMMENT ${CMD_COMMENT}
|
||||
WORKING_DIRECTORY ${CMD_CWD}
|
||||
VERBATIM ${CMD_COMMANDS}
|
||||
)
|
||||
set_property(TARGET ${CMD_TARGET} PROPERTY OUTPUT ${CMD_EFFECTIVE_OUTPUTS} APPEND)
|
||||
set_property(TARGET ${CMD_TARGET} PROPERTY DEPENDS ${CMD_EFFECTIVE_DEPENDS} APPEND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT CMD_EFFECTIVE_OUTPUTS)
|
||||
message(FATAL_ERROR "register_command: OUTPUTS or ARTIFACTS is required, or set ALWAYS_RUN")
|
||||
endif()
|
||||
|
||||
if(CMD_TARGET)
|
||||
if(TARGET ${CMD_TARGET})
|
||||
message(FATAL_ERROR "register_command: TARGET is already registered: ${CMD_TARGET}")
|
||||
endif()
|
||||
add_custom_target(${CMD_TARGET}
|
||||
COMMENT ${CMD_COMMENT}
|
||||
DEPENDS ${CMD_EFFECTIVE_OUTPUTS}
|
||||
JOB_POOL ${CMD_GROUP}
|
||||
)
|
||||
if(TARGET clone-${CMD_TARGET})
|
||||
add_dependencies(${CMD_TARGET} clone-${CMD_TARGET})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
VERBATIM ${CMD_COMMANDS}
|
||||
WORKING_DIRECTORY ${CMD_CWD}
|
||||
COMMENT ${CMD_COMMENT}
|
||||
DEPENDS ${CMD_EFFECTIVE_DEPENDS}
|
||||
OUTPUT ${CMD_EFFECTIVE_OUTPUTS}
|
||||
JOB_POOL ${CMD_GROUP}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# parse_package_json()
|
||||
# Description:
|
||||
# Parses a package.json file.
|
||||
# Arguments:
|
||||
# CWD string - The directory to look for the package.json file
|
||||
# VERSION_VARIABLE string - The variable to set to the package version
|
||||
# NODE_MODULES_VARIABLE string - The variable to set to list of node_modules sources
|
||||
function(parse_package_json)
|
||||
set(args CWD VERSION_VARIABLE NODE_MODULES_VARIABLE)
|
||||
cmake_parse_arguments(NPM "" "${args}" "" ${ARGN})
|
||||
|
||||
if(NOT NPM_CWD)
|
||||
set(NPM_CWD ${CWD})
|
||||
endif()
|
||||
|
||||
set(NPM_PACKAGE_JSON_PATH ${NPM_CWD}/package.json)
|
||||
|
||||
if(NOT EXISTS ${NPM_PACKAGE_JSON_PATH})
|
||||
message(FATAL_ERROR "parse_package_json: package.json not found: ${NPM_PACKAGE_JSON_PATH}")
|
||||
endif()
|
||||
|
||||
file(READ ${NPM_PACKAGE_JSON_PATH} NPM_PACKAGE_JSON)
|
||||
if(NOT NPM_PACKAGE_JSON)
|
||||
message(FATAL_ERROR "parse_package_json: failed to read package.json: ${NPM_PACKAGE_JSON_PATH}")
|
||||
endif()
|
||||
|
||||
if(NPM_VERSION_VARIABLE)
|
||||
string(JSON NPM_VERSION ERROR_VARIABLE error GET "${NPM_PACKAGE_JSON}" version)
|
||||
if(error)
|
||||
message(FATAL_ERROR "parse_package_json: failed to read 'version': ${error}")
|
||||
endif()
|
||||
set(${NPM_VERSION_VARIABLE} ${NPM_VERSION} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
if(NPM_NODE_MODULES_VARIABLE)
|
||||
set(NPM_NODE_MODULES)
|
||||
set(NPM_NODE_MODULES_PATH ${NPM_CWD}/node_modules)
|
||||
set(NPM_NODE_MODULES_PROPERTIES "devDependencies" "dependencies")
|
||||
|
||||
foreach(property ${NPM_NODE_MODULES_PROPERTIES})
|
||||
string(JSON NPM_${property} ERROR_VARIABLE error GET "${NPM_PACKAGE_JSON}" "${property}")
|
||||
if(error MATCHES "not found")
|
||||
continue()
|
||||
endif()
|
||||
if(error)
|
||||
message(FATAL_ERROR "parse_package_json: failed to read '${property}': ${error}")
|
||||
endif()
|
||||
|
||||
string(JSON NPM_${property}_LENGTH ERROR_VARIABLE error LENGTH "${NPM_${property}}")
|
||||
if(error)
|
||||
message(FATAL_ERROR "parse_package_json: failed to read '${property}' length: ${error}")
|
||||
endif()
|
||||
|
||||
math(EXPR NPM_${property}_MAX_INDEX "${NPM_${property}_LENGTH} - 1")
|
||||
foreach(i RANGE 0 ${NPM_${property}_MAX_INDEX})
|
||||
string(JSON NPM_${property}_${i} ERROR_VARIABLE error MEMBER "${NPM_${property}}" ${i})
|
||||
if(error)
|
||||
message(FATAL_ERROR "parse_package_json: failed to index '${property}' at ${i}: ${error}")
|
||||
endif()
|
||||
list(APPEND NPM_NODE_MODULES ${NPM_NODE_MODULES_PATH}/${NPM_${property}_${i}}/package.json)
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
set(${NPM_NODE_MODULES_VARIABLE} ${NPM_NODE_MODULES} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# register_bun_install()
|
||||
# Description:
|
||||
# Registers a command to run `bun install` in a directory.
|
||||
# Arguments:
|
||||
# CWD string - The directory to run `bun install`
|
||||
# NODE_MODULES_VARIABLE string - The variable to set to list of node_modules sources
|
||||
function(register_bun_install)
|
||||
set(args CWD NODE_MODULES_VARIABLE)
|
||||
cmake_parse_arguments(NPM "" "${args}" "" ${ARGN})
|
||||
|
||||
if(NOT NPM_CWD)
|
||||
set(NPM_CWD ${CWD})
|
||||
endif()
|
||||
|
||||
if(NPM_CWD STREQUAL ${CWD})
|
||||
set(NPM_COMMENT "bun install")
|
||||
else()
|
||||
set(NPM_COMMENT "bun install --cwd ${NPM_CWD}")
|
||||
endif()
|
||||
|
||||
parse_package_json(
|
||||
CWD
|
||||
${NPM_CWD}
|
||||
NODE_MODULES_VARIABLE
|
||||
NPM_NODE_MODULES
|
||||
)
|
||||
|
||||
if(NOT NPM_NODE_MODULES)
|
||||
message(FATAL_ERROR "register_bun_install: ${NPM_CWD}/package.json does not have dependencies?")
|
||||
endif()
|
||||
|
||||
register_command(
|
||||
COMMENT
|
||||
${NPM_COMMENT}
|
||||
CWD
|
||||
${NPM_CWD}
|
||||
COMMAND
|
||||
${BUN_EXECUTABLE}
|
||||
install
|
||||
--frozen-lockfile
|
||||
SOURCES
|
||||
${NPM_CWD}/package.json
|
||||
OUTPUTS
|
||||
${NPM_NODE_MODULES}
|
||||
)
|
||||
|
||||
set(${NPM_NODE_MODULES_VARIABLE} ${NPM_NODE_MODULES} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# register_repository()
|
||||
# Description:
|
||||
# Registers a git repository.
|
||||
# Arguments:
|
||||
# NAME string - The name of the repository
|
||||
# REPOSITORY string - The repository to clone
|
||||
# BRANCH string - The branch to clone
|
||||
# TAG string - The tag to clone
|
||||
# COMMIT string - The commit to clone
|
||||
# PATH string - The path to clone the repository to
|
||||
# OUTPUTS string - The outputs of the repository
|
||||
function(register_repository)
|
||||
set(args NAME REPOSITORY BRANCH TAG COMMIT PATH)
|
||||
set(multiArgs OUTPUTS)
|
||||
cmake_parse_arguments(GIT "" "${args}" "${multiArgs}" ${ARGN})
|
||||
|
||||
if(NOT GIT_REPOSITORY)
|
||||
message(FATAL_ERROR "git_clone: REPOSITORY is required")
|
||||
endif()
|
||||
|
||||
if(NOT GIT_BRANCH AND NOT GIT_TAG AND NOT GIT_COMMIT)
|
||||
message(FATAL_ERROR "git_clone: COMMIT, TAG, or BRANCH is required")
|
||||
endif()
|
||||
|
||||
if(NOT GIT_PATH)
|
||||
set(GIT_PATH ${CWD}/src/deps/${GIT_NAME})
|
||||
endif()
|
||||
|
||||
if(GIT_COMMIT)
|
||||
set(GIT_REF ${GIT_COMMIT})
|
||||
elseif(GIT_TAG)
|
||||
set(GIT_REF refs/tags/${GIT_TAG})
|
||||
else()
|
||||
set(GIT_REF refs/heads/${GIT_BRANCH})
|
||||
endif()
|
||||
|
||||
set(GIT_EFFECTIVE_OUTPUTS)
|
||||
foreach(output ${GIT_OUTPUTS})
|
||||
list(APPEND GIT_EFFECTIVE_OUTPUTS ${GIT_PATH}/${output})
|
||||
endforeach()
|
||||
|
||||
register_command(
|
||||
TARGET
|
||||
clone-${GIT_NAME}
|
||||
COMMENT
|
||||
"Cloning ${GIT_NAME}"
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-DGIT_PATH=${GIT_PATH}
|
||||
-DGIT_REPOSITORY=${GIT_REPOSITORY}
|
||||
-DGIT_REF=${GIT_REF}
|
||||
-DGIT_NAME=${GIT_NAME}
|
||||
-P ${CWD}/cmake/scripts/GitClone.cmake
|
||||
OUTPUTS
|
||||
${GIT_PATH}
|
||||
${GIT_EFFECTIVE_OUTPUTS}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# register_cmake_command()
|
||||
# Description:
|
||||
# Registers a command that builds an external CMake project.
|
||||
# Arguments:
|
||||
# TARGET string - The target to register the command with
|
||||
# ARGS string[] - The arguments to pass to CMake (e.g. -DKEY=VALUE)
|
||||
# CWD string - The directory where the CMake files are located
|
||||
# BUILD_PATH string - The path to build the project to
|
||||
# LIB_PATH string - The path to the libraries
|
||||
# TARGETS string[] - The targets to build from CMake
|
||||
# LIBRARIES string[] - The libraries that are built
|
||||
# INCLUDES string[] - The include paths
|
||||
function(register_cmake_command)
|
||||
set(args TARGET CWD BUILD_PATH LIB_PATH)
|
||||
set(multiArgs ARGS TARGETS LIBRARIES INCLUDES)
|
||||
# Use "MAKE" instead of "CMAKE" to prevent conflicts with CMake's own CMAKE_* variables
|
||||
cmake_parse_arguments(MAKE "" "${args}" "${multiArgs}" ${ARGN})
|
||||
|
||||
if(NOT MAKE_TARGET)
|
||||
message(FATAL_ERROR "register_cmake_command: TARGET is required")
|
||||
endif()
|
||||
|
||||
if(TARGET ${MAKE_TARGET})
|
||||
message(FATAL_ERROR "register_cmake_command: TARGET is already a target: ${MAKE_TARGET}")
|
||||
endif()
|
||||
|
||||
if(NOT MAKE_CWD)
|
||||
set(MAKE_CWD ${CWD}/src/deps/${MAKE_TARGET})
|
||||
endif()
|
||||
|
||||
if(NOT MAKE_BUILD_PATH)
|
||||
set(MAKE_BUILD_PATH ${BUILD_PATH}/${MAKE_TARGET})
|
||||
endif()
|
||||
|
||||
if(MAKE_LIB_PATH)
|
||||
set(MAKE_LIB_PATH ${MAKE_BUILD_PATH}/${MAKE_LIB_PATH})
|
||||
else()
|
||||
set(MAKE_LIB_PATH ${MAKE_BUILD_PATH})
|
||||
endif()
|
||||
|
||||
set(MAKE_EFFECTIVE_ARGS -B${MAKE_BUILD_PATH} ${CMAKE_ARGS})
|
||||
|
||||
set(setFlags GENERATOR BUILD_TYPE)
|
||||
set(appendFlags C_FLAGS CXX_FLAGS LINKER_FLAGS)
|
||||
set(specialFlags POSITION_INDEPENDENT_CODE)
|
||||
set(flags ${setFlags} ${appendFlags} ${specialFlags})
|
||||
|
||||
foreach(arg ${MAKE_ARGS})
|
||||
foreach(flag ${flags})
|
||||
if(arg MATCHES "-DCMAKE_${flag}=(.*)")
|
||||
if(DEFINED MAKE_${flag})
|
||||
message(FATAL_ERROR "register_cmake_command: CMAKE_${flag} was already set: \"${MAKE_${flag}}\"")
|
||||
endif()
|
||||
set(MAKE_${flag} ${CMAKE_MATCH_1})
|
||||
set(${arg}_USED ON)
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT ${arg}_USED)
|
||||
list(APPEND MAKE_EFFECTIVE_ARGS ${arg})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(flag ${setFlags})
|
||||
if(NOT DEFINED MAKE_${flag} AND DEFINED CMAKE_${flag})
|
||||
set(MAKE_${flag} ${CMAKE_${flag}})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(flag ${appendFlags})
|
||||
if(MAKE_${flag})
|
||||
set(MAKE_${flag} "${CMAKE_${flag}} ${MAKE_${flag}}")
|
||||
else()
|
||||
set(MAKE_${flag} ${CMAKE_${flag}})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(MAKE_POSITION_INDEPENDENT_CODE AND NOT WIN32)
|
||||
set(MAKE_C_FLAGS "${MAKE_C_FLAGS} -fPIC")
|
||||
set(MAKE_CXX_FLAGS "${MAKE_CXX_FLAGS} -fPIC")
|
||||
elseif(APPLE)
|
||||
set(MAKE_C_FLAGS "${MAKE_C_FLAGS} -fno-pic -fno-pie")
|
||||
set(MAKE_CXX_FLAGS "${MAKE_CXX_FLAGS} -fno-pic -fno-pie")
|
||||
endif()
|
||||
|
||||
set(effectiveFlags ${setFlags} ${appendFlags})
|
||||
foreach(flag ${effectiveFlags})
|
||||
list(APPEND MAKE_EFFECTIVE_ARGS -DCMAKE_${flag}=${MAKE_${flag}})
|
||||
endforeach()
|
||||
|
||||
register_command(
|
||||
COMMENT "Configuring ${MAKE_TARGET}"
|
||||
TARGET configure-${MAKE_TARGET}
|
||||
COMMAND ${CMAKE_COMMAND} ${MAKE_EFFECTIVE_ARGS}
|
||||
CWD ${MAKE_CWD}
|
||||
OUTPUTS ${MAKE_BUILD_PATH}/CMakeCache.txt
|
||||
)
|
||||
|
||||
if(TARGET clone-${MAKE_TARGET})
|
||||
add_dependencies(configure-${MAKE_TARGET} clone-${MAKE_TARGET})
|
||||
endif()
|
||||
|
||||
set(MAKE_BUILD_ARGS --build ${MAKE_BUILD_PATH} --config ${MAKE_BUILD_TYPE})
|
||||
|
||||
set(MAKE_EFFECTIVE_LIBRARIES)
|
||||
set(MAKE_ARTIFACTS)
|
||||
foreach(lib ${MAKE_LIBRARIES})
|
||||
if(lib MATCHES "^(WIN32|UNIX|APPLE)$")
|
||||
if(${lib})
|
||||
continue()
|
||||
else()
|
||||
list(POP_BACK MAKE_ARTIFACTS)
|
||||
endif()
|
||||
else()
|
||||
list(APPEND MAKE_EFFECTIVE_LIBRARIES ${lib})
|
||||
if(lib MATCHES "\\.")
|
||||
list(APPEND MAKE_ARTIFACTS ${MAKE_LIB_PATH}/${lib})
|
||||
else()
|
||||
list(APPEND MAKE_ARTIFACTS ${MAKE_LIB_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT MAKE_TARGETS)
|
||||
set(MAKE_TARGETS ${MAKE_EFFECTIVE_LIBRARIES})
|
||||
endif()
|
||||
|
||||
foreach(target ${MAKE_TARGETS})
|
||||
list(APPEND MAKE_BUILD_ARGS --target ${target})
|
||||
endforeach()
|
||||
|
||||
set(MAKE_EFFECTIVE_INCLUDES)
|
||||
foreach(include ${MAKE_INCLUDES})
|
||||
if(include STREQUAL ".")
|
||||
list(APPEND MAKE_EFFECTIVE_INCLUDES ${MAKE_CWD})
|
||||
else()
|
||||
list(APPEND MAKE_EFFECTIVE_INCLUDES ${MAKE_CWD}/${include})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
register_command(
|
||||
COMMENT "Building ${MAKE_TARGET}"
|
||||
TARGET ${MAKE_TARGET}
|
||||
TARGETS configure-${MAKE_TARGET}
|
||||
COMMAND ${CMAKE_COMMAND} ${MAKE_BUILD_ARGS}
|
||||
CWD ${MAKE_CWD}
|
||||
ARTIFACTS ${MAKE_ARTIFACTS}
|
||||
)
|
||||
|
||||
if(MAKE_EFFECTIVE_INCLUDES)
|
||||
target_include_directories(${bun} PRIVATE ${MAKE_EFFECTIVE_INCLUDES})
|
||||
if(TARGET clone-${MAKE_TARGET} AND NOT BUN_LINK_ONLY)
|
||||
add_dependencies(${bun} clone-${MAKE_TARGET})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# HACK: Workaround for duplicate symbols when linking mimalloc.o
|
||||
# >| duplicate symbol '_mi_page_queue_append(mi_heap_s*, mi_page_queue_s*, mi_page_queue_s*)' in:
|
||||
# >| mimalloc/CMakeFiles/mimalloc-obj.dir/src/static.c.o
|
||||
# >| ld: 287 duplicate symbols for architecture arm64
|
||||
if(NOT BUN_LINK_ONLY OR NOT MAKE_ARTIFACTS MATCHES "static.c.o")
|
||||
target_link_libraries(${bun} PRIVATE ${MAKE_ARTIFACTS})
|
||||
endif()
|
||||
|
||||
if(BUN_LINK_ONLY)
|
||||
target_sources(${bun} PRIVATE ${MAKE_ARTIFACTS})
|
||||
endif()
|
||||
endfunction()
|
||||
220
cmake/Options.cmake
Normal file
220
cmake/Options.cmake
Normal file
@@ -0,0 +1,220 @@
|
||||
include(Macros)
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME OR NOT CMAKE_SYSTEM_PROCESSOR)
|
||||
message(FATAL_ERROR "CMake included this file before project() was called")
|
||||
endif()
|
||||
|
||||
optionx(BUN_LINK_ONLY BOOL "If only the linking step should be built" DEFAULT OFF)
|
||||
optionx(BUN_CPP_ONLY BOOL "If only the C++ part of Bun should be built" DEFAULT OFF)
|
||||
|
||||
optionx(CI BOOL "If CI is enabled" DEFAULT OFF)
|
||||
optionx(BUILDKITE BOOL "If Buildkite is enabled" DEFAULT OFF)
|
||||
optionx(GITHUB_ACTIONS BOOL "If GitHub Actions is enabled" DEFAULT OFF)
|
||||
|
||||
if(BUILDKITE)
|
||||
optionx(BUILDKITE_COMMIT STRING "The commit hash")
|
||||
optionx(BUILDKITE_MESSAGE STRING "The commit message")
|
||||
endif()
|
||||
|
||||
optionx(CMAKE_BUILD_TYPE "Debug|Release|RelWithDebInfo|MinSizeRel" "The build type to use" REQUIRED)
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Release|RelWithDebInfo|MinSizeRel")
|
||||
setx(RELEASE ON)
|
||||
else()
|
||||
setx(RELEASE OFF)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo")
|
||||
setx(DEBUG ON)
|
||||
else()
|
||||
setx(DEBUG OFF)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "MinSizeRel")
|
||||
setx(ENABLE_SMOL ON)
|
||||
endif()
|
||||
|
||||
cmake_host_system_information(RESULT CORE_COUNT QUERY NUMBER_OF_LOGICAL_CORES)
|
||||
|
||||
optionx(CMAKE_BUILD_PARALLEL_LEVEL STRING "The number of parallel build jobs" DEFAULT ${CORE_COUNT})
|
||||
|
||||
if(APPLE)
|
||||
setx(OS "darwin")
|
||||
elseif(WIN32)
|
||||
setx(OS "windows")
|
||||
elseif(LINUX)
|
||||
setx(OS "linux")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported operating system: ${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|arm")
|
||||
setx(ARCH "aarch64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|x64|AMD64")
|
||||
setx(ARCH "x64")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
if(ARCH STREQUAL "x64")
|
||||
optionx(ENABLE_BASELINE BOOL "If baseline features should be used for older CPUs (e.g. disables AVX, AVX2)" DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
if(ARCH STREQUAL "aarch64")
|
||||
set(DEFAULT_CPU "native")
|
||||
elseif(ENABLE_BASELINE)
|
||||
set(DEFAULT_CPU "nehalem")
|
||||
else()
|
||||
set(DEFAULT_CPU "haswell")
|
||||
endif()
|
||||
|
||||
optionx(CPU STRING "The CPU to use for the compiler" DEFAULT ${DEFAULT_CPU})
|
||||
|
||||
optionx(ENABLE_LOGS BOOL "If debug logs should be enabled" DEFAULT ${DEBUG})
|
||||
optionx(ENABLE_ASSERTIONS BOOL "If debug assertions should be enabled" DEFAULT ${DEBUG})
|
||||
|
||||
if(BUILDKITE_MESSAGE AND BUILDKITE_MESSAGE MATCHES "\\[release build\\]")
|
||||
message(STATUS "Switched to release build, since commit message contains: \"[release build]\"")
|
||||
set(DEFAULT_CANARY OFF)
|
||||
else()
|
||||
set(DEFAULT_CANARY ON)
|
||||
endif()
|
||||
|
||||
optionx(ENABLE_CANARY BOOL "If canary features should be enabled" DEFAULT ${DEFAULT_CANARY})
|
||||
|
||||
if(ENABLE_CANARY AND BUILDKITE)
|
||||
execute_process(
|
||||
COMMAND buildkite-agent meta-data get "canary"
|
||||
OUTPUT_VARIABLE DEFAULT_CANARY_REVISION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
elseif(ENABLE_CANARY)
|
||||
set(DEFAULT_CANARY_REVISION "1")
|
||||
else()
|
||||
set(DEFAULT_CANARY_REVISION "0")
|
||||
endif()
|
||||
|
||||
optionx(CANARY_REVISION STRING "The canary revision of the build" DEFAULT ${DEFAULT_CANARY_REVISION})
|
||||
|
||||
if(RELEASE AND LINUX)
|
||||
set(DEFAULT_LTO ON)
|
||||
else()
|
||||
set(DEFAULT_LTO OFF)
|
||||
endif()
|
||||
|
||||
optionx(ENABLE_LTO BOOL "If LTO (link-time optimization) should be used" DEFAULT ${DEFAULT_LTO})
|
||||
|
||||
if(LINUX)
|
||||
optionx(ENABLE_VALGRIND BOOL "If Valgrind support should be enabled" DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
if(USE_VALGRIND AND NOT USE_BASELINE)
|
||||
message(WARNING "If valgrind is enabled, baseline must also be enabled")
|
||||
setx(USE_BASELINE ON)
|
||||
endif()
|
||||
|
||||
if(BUILDKITE_COMMIT)
|
||||
set(DEFAULT_REVISION ${BUILDKITE_COMMIT})
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND git rev-parse HEAD
|
||||
WORKING_DIRECTORY ${CWD}
|
||||
OUTPUT_VARIABLE DEFAULT_REVISION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
if(NOT DEFAULT_REVISION)
|
||||
set(DEFAULT_REVISION "unknown")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
optionx(REVISION STRING "The git revision of the build" DEFAULT ${DEFAULT_REVISION})
|
||||
|
||||
# Used in process.version, process.versions.node, napi, and elsewhere
|
||||
optionx(NODEJS_VERSION STRING "The version of Node.js to report" DEFAULT "22.6.0")
|
||||
|
||||
# Used in process.versions.modules and compared while loading V8 modules
|
||||
optionx(NODEJS_ABI_VERSION STRING "The ABI version of Node.js to report" DEFAULT "127")
|
||||
|
||||
if(APPLE)
|
||||
set(DEFAULT_STATIC_SQLITE OFF)
|
||||
else()
|
||||
set(DEFAULT_STATIC_SQLITE ON)
|
||||
endif()
|
||||
|
||||
optionx(USE_STATIC_SQLITE BOOL "If SQLite should be statically linked" DEFAULT ${DEFAULT_STATIC_SQLITE})
|
||||
|
||||
set(DEFAULT_STATIC_LIBATOMIC ON)
|
||||
|
||||
if(CMAKE_HOST_LINUX AND NOT WIN32 AND NOT APPLE)
|
||||
execute_process(
|
||||
COMMAND grep -w "NAME" /etc/os-release
|
||||
OUTPUT_VARIABLE LINUX_DISTRO
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
if(LINUX_DISTRO MATCHES "NAME=\"(Arch|Manjaro|Artix) Linux\"|NAME=\"openSUSE Tumbleweed\"")
|
||||
set(DEFAULT_STATIC_LIBATOMIC OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
optionx(USE_STATIC_LIBATOMIC BOOL "If libatomic should be statically linked" DEFAULT ${DEFAULT_STATIC_LIBATOMIC})
|
||||
|
||||
if(APPLE)
|
||||
set(DEFAULT_WEBKIT_ICU OFF)
|
||||
else()
|
||||
set(DEFAULT_WEBKIT_ICU ON)
|
||||
endif()
|
||||
|
||||
optionx(USE_WEBKIT_ICU BOOL "Use the ICU libraries from WebKit" DEFAULT ${DEFAULT_WEBKIT_ICU})
|
||||
|
||||
optionx(ERROR_LIMIT STRING "Maximum number of errors to show when compiling C++ code" DEFAULT "100")
|
||||
|
||||
# Set the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS for building dependencies.
|
||||
# This is a mess, since it doesn't use the CMake add_compile_options or target_compile_options commands.
|
||||
# In the future, make some macros so we can set this automatically.
|
||||
# e.g.
|
||||
# add_c_flags(-mtune=native) - applies to all dependencies
|
||||
# add_c_flags({target} -fno-rtti) - applies to a specific target
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|arm|ARM64")
|
||||
if(APPLE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=apple-m1")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=apple-m1")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a+crc -mtune=ampere1")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8-a+crc -mtune=ampere1")
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=${CPU}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=${CPU}")
|
||||
endif()
|
||||
|
||||
list(APPEND CMAKE_ARGS -DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND CMAKE_ARGS -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Z7 /MT /Ob2 /DNDEBUG /U_DLL")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Z7 /MT /Ob2 /DNDEBUG /U_DLL -Xclang -fno-c++-static-destructors")
|
||||
if(ENABLE_LTO)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=lld -flto -Xclang -emit-llvm-bc")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=lld -flto -Xclang -emit-llvm-bc")
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-asynchronous-unwind-tables -fno-unwind-tables")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-c++-static-destructors")
|
||||
if(ENABLE_LTO)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto=full")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=full -fwhole-program-vtables -fforce-emit-vtables")
|
||||
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -flto=full -fwhole-program-vtables -fforce-emit-vtables")
|
||||
endif()
|
||||
if(LINUX)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections -faddrsig")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections -faddrsig")
|
||||
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -Wl,-z,norelro")
|
||||
endif()
|
||||
if(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCXX_ENABLE_ASSERTIONS=0 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
11
cmake/Policies.cmake
Normal file
11
cmake/Policies.cmake
Normal file
@@ -0,0 +1,11 @@
|
||||
# Let the MSVC runtime be set using CMAKE_MSVC_RUNTIME_LIBRARY, instead of automatically.
|
||||
# Since CMake 3.15.
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
|
||||
# If INTERPROCEDURAL_OPTIMIZATION is enabled and not supported by the compiler, throw an error.
|
||||
# Since CMake 3.9.
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
|
||||
# Use CMAKE_{C,CXX}_STANDARD when evaluating try_compile().
|
||||
# Since CMake 3.8.
|
||||
cmake_policy(SET CMP0067 NEW)
|
||||
58
cmake/analysis/RunClangTidy.cmake
Normal file
58
cmake/analysis/RunClangTidy.cmake
Normal file
@@ -0,0 +1,58 @@
|
||||
# https://clang.llvm.org/extra/clang-tidy/
|
||||
|
||||
include(Macros)
|
||||
|
||||
find_command(
|
||||
VARIABLE
|
||||
CLANG_TIDY_PROGRAM
|
||||
COMMAND
|
||||
clang-tidy
|
||||
VERSION
|
||||
${LLVM_VERSION}
|
||||
REQUIRED
|
||||
OFF
|
||||
)
|
||||
|
||||
set(CLANG_TIDY_COMMAND ${CLANG_TIDY_PROGRAM} ${BUN_CPP_SOURCES}
|
||||
-p ${BUILD_PATH}
|
||||
--config-file=${CWD}/.clang-tidy
|
||||
--fix
|
||||
--fix-errors
|
||||
--fix-notes
|
||||
)
|
||||
|
||||
if(CMAKE_COLOR_DIAGNOSTICS)
|
||||
list(APPEND CLANG_TIDY_COMMAND --use-color)
|
||||
endif()
|
||||
|
||||
# Extra clang-tidy checks that are normally disabled due to noise.
|
||||
# e.g. JavaScriptCore/Lookup.h
|
||||
set(CLANG_TIDY_EXTRA_COMMAND ${CLANG_TIDY_PROGRAM}
|
||||
--checks=performance-*
|
||||
)
|
||||
|
||||
register_command(
|
||||
TARGET
|
||||
clang-tidy
|
||||
COMMENT
|
||||
"Running clang-tidy"
|
||||
COMMAND
|
||||
${CLANG_TIDY_COMMAND}
|
||||
CWD
|
||||
${BUILD_PATH}
|
||||
TARGETS
|
||||
${bun}
|
||||
)
|
||||
|
||||
register_command(
|
||||
TARGET
|
||||
clang-tidy-extra
|
||||
COMMENT
|
||||
"Running clang-tidy with extra checks"
|
||||
COMMAND
|
||||
${CLANG_TIDY_EXTRA_COMMAND}
|
||||
CWD
|
||||
${BUILD_PATH}
|
||||
TARGETS
|
||||
${bun}
|
||||
)
|
||||
35
cmake/analysis/RunCppCheck.cmake
Normal file
35
cmake/analysis/RunCppCheck.cmake
Normal file
@@ -0,0 +1,35 @@
|
||||
# https://cppcheck.sourceforge.io/
|
||||
|
||||
include(Macros)
|
||||
|
||||
find_command(
|
||||
VARIABLE
|
||||
CPPCHECK_EXECUTABLE
|
||||
COMMAND
|
||||
cppcheck
|
||||
REQUIRED
|
||||
OFF
|
||||
)
|
||||
|
||||
set(CPPCHECK_COMMAND ${CPPCHECK_EXECUTABLE}
|
||||
--cppcheck-build-dir=${BUILD_PATH}/cppcheck
|
||||
--project=${BUILD_PATH}/compile_commands.json
|
||||
--clang=${CMAKE_CXX_COMPILER}
|
||||
--std=c++${CMAKE_CXX_STANDARD}
|
||||
--report-progress
|
||||
--showtime=summary
|
||||
)
|
||||
|
||||
register_command(
|
||||
TARGET
|
||||
cppcheck
|
||||
COMMENT
|
||||
"Running cppcheck"
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E make_directory cppcheck
|
||||
&& ${CPPCHECK_COMMAND}
|
||||
CWD
|
||||
${BUILD_PATH}
|
||||
TARGETS
|
||||
${bun}
|
||||
)
|
||||
24
cmake/analysis/RunCppLint.cmake
Normal file
24
cmake/analysis/RunCppLint.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
include(Macros)
|
||||
|
||||
find_command(
|
||||
VARIABLE
|
||||
CPPLINT_PROGRAM
|
||||
COMMAND
|
||||
cpplint
|
||||
REQUIRED
|
||||
OFF
|
||||
)
|
||||
|
||||
register_command(
|
||||
TARGET
|
||||
cpplint
|
||||
COMMENT
|
||||
"Running cpplint"
|
||||
COMMAND
|
||||
${CPPLINT_PROGRAM}
|
||||
${BUN_CPP_SOURCES}
|
||||
CWD
|
||||
${BUILD_PATH}
|
||||
TARGETS
|
||||
${bun}
|
||||
)
|
||||
69
cmake/analysis/RunIWYU.cmake
Normal file
69
cmake/analysis/RunIWYU.cmake
Normal file
@@ -0,0 +1,69 @@
|
||||
# IWYU = "Include What You Use"
|
||||
# https://include-what-you-use.org/
|
||||
|
||||
include(Macros)
|
||||
|
||||
setx(IWYU_SOURCE_PATH ${CACHE_PATH}/iwyu-${LLVM_VERSION_MAJOR})
|
||||
setx(IWYU_BUILD_PATH ${IWYU_SOURCE_PATH}/build)
|
||||
setx(IWYU_PROGRAM ${IWYU_BUILD_PATH}/bin/include-what-you-use)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
iwyu
|
||||
REPOSITORY
|
||||
include-what-you-use/include-what-you-use
|
||||
BRANCH
|
||||
clang_${LLVM_VERSION_MAJOR}
|
||||
PATH
|
||||
${IWYU_SOURCE_PATH}
|
||||
)
|
||||
|
||||
register_command(
|
||||
TARGET
|
||||
build-iwyu
|
||||
COMMENT
|
||||
"Building iwyu"
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-B${IWYU_BUILD_PATH}
|
||||
-G${CMAKE_GENERATOR}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
|
||||
-DIWYU_LLVM_ROOT_PATH=${LLVM_PREFIX}
|
||||
&& ${CMAKE_COMMAND}
|
||||
--build ${IWYU_BUILD_PATH}
|
||||
CWD
|
||||
${IWYU_SOURCE_PATH}
|
||||
TARGETS
|
||||
clone-iwyu
|
||||
)
|
||||
|
||||
find_command(
|
||||
VARIABLE
|
||||
PYTHON_EXECUTABLE
|
||||
COMMAND
|
||||
python3
|
||||
python
|
||||
VERSION
|
||||
>=3.0.0
|
||||
REQUIRED
|
||||
OFF
|
||||
)
|
||||
|
||||
register_command(
|
||||
TARGET
|
||||
iwyu
|
||||
COMMENT
|
||||
"Running iwyu"
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-E env IWYU_BINARY=${IWYU_PROGRAM}
|
||||
${PYTHON_EXECUTABLE}
|
||||
${IWYU_SOURCE_PATH}/iwyu_tool.py
|
||||
-p ${BUILD_PATH}
|
||||
CWD
|
||||
${BUILD_PATH}
|
||||
TARGETS
|
||||
build-iwyu
|
||||
${bun}
|
||||
)
|
||||
73
cmake/scripts/GitClone.cmake
Normal file
73
cmake/scripts/GitClone.cmake
Normal file
@@ -0,0 +1,73 @@
|
||||
include(cmake/Macros.cmake)
|
||||
|
||||
if(NOT GIT_PATH OR NOT GIT_REPOSITORY OR NOT GIT_REF)
|
||||
message(FATAL_ERROR "git_clone: GIT_PATH, GIT_REPOSITORY, and GIT_REF are required")
|
||||
endif()
|
||||
|
||||
setx(GIT_PATH ${GIT_PATH})
|
||||
setx(GIT_REPOSITORY ${GIT_REPOSITORY})
|
||||
setx(GIT_REF ${GIT_REF})
|
||||
|
||||
string(REGEX MATCH "([^/]+)$" GIT_ORIGINAL_NAME ${GIT_REPOSITORY})
|
||||
|
||||
if(NOT GIT_NAME)
|
||||
setx(GIT_NAME ${GIT_ORIGINAL_NAME})
|
||||
endif()
|
||||
|
||||
set(GIT_REF_PATH ${GIT_PATH}/.ref)
|
||||
|
||||
if(EXISTS ${GIT_REF_PATH})
|
||||
file(READ ${GIT_REF_PATH} GIT_CACHED_REF)
|
||||
if(GIT_CACHED_REF STREQUAL GIT_REF)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
setx(GIT_DOWNLOAD_PATH ${GIT_PATH}.tar.gz)
|
||||
setx(GIT_DOWNLOAD_URL https://github.com/${GIT_REPOSITORY}/archive/${GIT_REF}.tar.gz)
|
||||
|
||||
foreach(i RANGE 10)
|
||||
set(GIT_DOWNLOAD_TMP_PATH ${GIT_PATH}.tmp.${i})
|
||||
file(DOWNLOAD
|
||||
${GIT_DOWNLOAD_URL}
|
||||
${GIT_DOWNLOAD_TMP_PATH}
|
||||
TIMEOUT 120
|
||||
STATUS GIT_DOWNLOAD_STATUS
|
||||
)
|
||||
if(GIT_DOWNLOAD_STATUS MATCHES "^0")
|
||||
file(RENAME ${GIT_DOWNLOAD_TMP_PATH} ${GIT_DOWNLOAD_PATH})
|
||||
break()
|
||||
endif()
|
||||
message(WARNING "git_clone: ${GIT_DOWNLOAD_STATUS}: ${GIT_DOWNLOAD_URL}")
|
||||
file(REMOVE ${GIT_DOWNLOAD_TMP_PATH})
|
||||
endforeach()
|
||||
|
||||
if(NOT EXISTS ${GIT_DOWNLOAD_PATH})
|
||||
message(FATAL_ERROR "git_clone: failed to download ${GIT_DOWNLOAD_URL}")
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE ${GIT_PATH})
|
||||
get_filename_component(GIT_PARENT_PATH ${GIT_PATH} DIRECTORY)
|
||||
file(ARCHIVE_EXTRACT INPUT ${GIT_DOWNLOAD_PATH} DESTINATION ${GIT_PARENT_PATH}/tmp-${GIT_ORIGINAL_NAME} TOUCH)
|
||||
file(GLOB GIT_TMP_PATH LIST_DIRECTORIES ON ${GIT_PARENT_PATH}/tmp-${GIT_ORIGINAL_NAME}/${GIT_ORIGINAL_NAME}-*)
|
||||
file(RENAME ${GIT_TMP_PATH} ${GIT_PATH})
|
||||
file(REMOVE_RECURSE ${GIT_PARENT_PATH}/tmp-${GIT_ORIGINAL_NAME})
|
||||
file(REMOVE ${GIT_DOWNLOAD_PATH})
|
||||
|
||||
file(GLOB_RECURSE GIT_PATCH_PATHS ${CMAKE_SOURCE_DIR}/patches/${GIT_NAME}/*)
|
||||
foreach(GIT_PATCH_PATH ${GIT_PATCH_PATHS})
|
||||
if(GIT_PATCH_PATH MATCHES "\\.patch$")
|
||||
execute_process(
|
||||
COMMAND git apply --ignore-whitespace --ignore-space-change --no-index --verbose ${GIT_PATCH_PATH}
|
||||
WORKING_DIRECTORY ${GIT_PATH}
|
||||
RESULT_VARIABLE GIT_PATCH_RESULT
|
||||
)
|
||||
if(NOT GIT_PATCH_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR "git_clone: failed to apply patch: ${GIT_PATCH_PATH}")
|
||||
endif()
|
||||
else()
|
||||
file(COPY ${GIT_PATCH_PATH} DESTINATION ${GIT_PATH})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(WRITE ${GIT_REF_PATH} ${GIT_REF})
|
||||
23
cmake/targets/BuildBoringSSL.cmake
Normal file
23
cmake/targets/BuildBoringSSL.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
boringssl
|
||||
REPOSITORY
|
||||
oven-sh/boringssl
|
||||
COMMIT
|
||||
29a2cd359458c9384694b75456026e4b57e3e567
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
boringssl
|
||||
LIBRARIES
|
||||
crypto
|
||||
ssl
|
||||
decrepit
|
||||
ARGS
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
INCLUDES
|
||||
include
|
||||
)
|
||||
26
cmake/targets/BuildBrotli.cmake
Normal file
26
cmake/targets/BuildBrotli.cmake
Normal file
@@ -0,0 +1,26 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
brotli
|
||||
REPOSITORY
|
||||
google/brotli
|
||||
TAG
|
||||
v1.1.0
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
brotli
|
||||
LIBRARIES
|
||||
brotlicommon
|
||||
brotlidec
|
||||
brotlienc
|
||||
ARGS
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
-DBROTLI_BUILD_TOOLS=OFF
|
||||
-DBROTLI_EMSCRIPTEN=OFF
|
||||
-DBROTLI_DISABLE_TESTS=ON
|
||||
INCLUDES
|
||||
c/include
|
||||
)
|
||||
1097
cmake/targets/BuildBun.cmake
Normal file
1097
cmake/targets/BuildBun.cmake
Normal file
File diff suppressed because it is too large
Load Diff
29
cmake/targets/BuildCares.cmake
Normal file
29
cmake/targets/BuildCares.cmake
Normal file
@@ -0,0 +1,29 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
cares
|
||||
REPOSITORY
|
||||
c-ares/c-ares
|
||||
COMMIT
|
||||
d1722e6e8acaf10eb73fa995798a9cd421d9f85e
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
cares
|
||||
TARGETS
|
||||
c-ares
|
||||
ARGS
|
||||
-DCARES_STATIC=ON
|
||||
-DCARES_STATIC_PIC=ON # FORCE_PIC was set to 1, but CARES_STATIC_PIC was set to OFF??
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||
-DCARES_SHARED=OFF
|
||||
-DCARES_BUILD_TOOLS=OFF # this was set to ON?
|
||||
LIB_PATH
|
||||
lib
|
||||
LIBRARIES
|
||||
cares
|
||||
INCLUDES
|
||||
include
|
||||
)
|
||||
55
cmake/targets/BuildLibArchive.cmake
Normal file
55
cmake/targets/BuildLibArchive.cmake
Normal file
@@ -0,0 +1,55 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
libarchive
|
||||
REPOSITORY
|
||||
libarchive/libarchive
|
||||
COMMIT
|
||||
898dc8319355b7e985f68a9819f182aaed61b53a
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
libarchive
|
||||
TARGETS
|
||||
archive_static
|
||||
ARGS
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
-DENABLE_INSTALL=OFF
|
||||
-DENABLE_TEST=OFF
|
||||
-DENABLE_WERROR=OFF
|
||||
-DENABLE_BZIP2=OFF
|
||||
-DENABLE_CAT=OFF
|
||||
-DENABLE_EXPAT=OFF
|
||||
-DENABLE_ICONV=OFF
|
||||
-DENABLE_LIBB2=OFF
|
||||
-DENABLE_LibGCC=OFF
|
||||
-DENABLE_LIBXML2=OFF
|
||||
-DENABLE_LZ4=OFF
|
||||
-DENABLE_LZMA=OFF
|
||||
-DENABLE_LZO=OFF
|
||||
-DENABLE_MBEDTLS=OFF
|
||||
-DENABLE_NETTLE=OFF
|
||||
-DENABLE_OPENSSL=OFF
|
||||
-DENABLE_PCRE2POSIX=OFF
|
||||
-DENABLE_PCREPOSIX=OFF
|
||||
-DENABLE_ZSTD=OFF
|
||||
# libarchive depends on zlib headers, otherwise it will
|
||||
# spawn a processes to compress instead of using the library.
|
||||
-DENABLE_ZLIB=OFF
|
||||
-DHAVE_ZLIB_H=ON
|
||||
-DCMAKE_C_FLAGS="-I${CWD}/src/deps/zlib"
|
||||
LIB_PATH
|
||||
libarchive
|
||||
LIBRARIES
|
||||
archive
|
||||
INCLUDES
|
||||
include
|
||||
)
|
||||
|
||||
# Must be loaded after zlib is defined
|
||||
if(TARGET clone-zlib)
|
||||
add_dependencies(libarchive clone-zlib)
|
||||
endif()
|
||||
26
cmake/targets/BuildLibDeflate.cmake
Normal file
26
cmake/targets/BuildLibDeflate.cmake
Normal file
@@ -0,0 +1,26 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
libdeflate
|
||||
REPOSITORY
|
||||
ebiggers/libdeflate
|
||||
COMMIT
|
||||
dc76454a39e7e83b68c3704b6e3784654f8d5ac5
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
libdeflate
|
||||
TARGETS
|
||||
libdeflate_static
|
||||
ARGS
|
||||
-DLIBDEFLATE_BUILD_STATIC_LIB=ON
|
||||
-DLIBDEFLATE_BUILD_SHARED_LIB=OFF
|
||||
-DLIBDEFLATE_BUILD_GZIP=OFF
|
||||
LIBRARIES
|
||||
deflatestatic WIN32
|
||||
deflate UNIX
|
||||
INCLUDES
|
||||
.
|
||||
)
|
||||
31
cmake/targets/BuildLibuv.cmake
Normal file
31
cmake/targets/BuildLibuv.cmake
Normal file
@@ -0,0 +1,31 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
libuv
|
||||
REPOSITORY
|
||||
libuv/libuv
|
||||
COMMIT
|
||||
da527d8d2a908b824def74382761566371439003
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(LIBUV_CMAKE_C_FLAGS "/DWIN32 /D_WINDOWS -Wno-int-conversion")
|
||||
endif()
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
libuv
|
||||
TARGETS
|
||||
uv_a
|
||||
ARGS
|
||||
-DLIBUV_BUILD_SHARED=OFF
|
||||
-DLIBUV_BUILD_TESTS=OFF
|
||||
-DLIBUV_BUILD_BENCH=OFF
|
||||
-DCMAKE_C_FLAGS=${LIBUV_CMAKE_C_FLAGS}
|
||||
LIBRARIES
|
||||
libuv WIN32
|
||||
uv UNIX
|
||||
INCLUDES
|
||||
include
|
||||
)
|
||||
48
cmake/targets/BuildLolHtml.cmake
Normal file
48
cmake/targets/BuildLolHtml.cmake
Normal file
@@ -0,0 +1,48 @@
|
||||
include(Macros)
|
||||
include(SetupRust)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
lolhtml
|
||||
REPOSITORY
|
||||
cloudflare/lol-html
|
||||
COMMIT
|
||||
8d4c273ded322193d017042d1f48df2766b0f88b
|
||||
)
|
||||
|
||||
set(LOLHTML_CWD ${CWD}/src/deps/lolhtml/c-api)
|
||||
set(LOLHTML_BUILD_PATH ${BUILD_PATH}/lolhtml)
|
||||
|
||||
if(DEBUG)
|
||||
set(LOLHTML_BUILD_TYPE debug)
|
||||
else()
|
||||
set(LOLHTML_BUILD_TYPE release)
|
||||
endif()
|
||||
|
||||
set(LOLHTML_LIBRARY ${LOLHTML_BUILD_PATH}/${LOLHTML_BUILD_TYPE}/${CMAKE_STATIC_LIBRARY_PREFIX}lolhtml${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
|
||||
set(LOLHTML_BUILD_ARGS
|
||||
--target-dir ${BUILD_PATH}/lolhtml
|
||||
)
|
||||
|
||||
if(RELEASE)
|
||||
list(APPEND LOLHTML_BUILD_ARGS --release)
|
||||
endif()
|
||||
|
||||
register_command(
|
||||
TARGET
|
||||
lolhtml
|
||||
CWD
|
||||
${LOLHTML_CWD}
|
||||
COMMAND
|
||||
${CARGO_EXECUTABLE}
|
||||
build
|
||||
${LOLHTML_BUILD_ARGS}
|
||||
ARTIFACTS
|
||||
${LOLHTML_LIBRARY}
|
||||
)
|
||||
|
||||
target_link_libraries(${bun} PRIVATE ${LOLHTML_LIBRARY})
|
||||
if(BUN_LINK_ONLY)
|
||||
target_sources(${bun} PRIVATE ${LOLHTML_LIBRARY})
|
||||
endif()
|
||||
35
cmake/targets/BuildLshpack.cmake
Normal file
35
cmake/targets/BuildLshpack.cmake
Normal file
@@ -0,0 +1,35 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
lshpack
|
||||
REPOSITORY
|
||||
litespeedtech/ls-hpack
|
||||
COMMIT
|
||||
3d0f1fc1d6e66a642e7a98c55deb38aa986eb4b0
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(LSHPACK_INCLUDES . compat/queue)
|
||||
else()
|
||||
set(LSHPACK_INCLUDES .)
|
||||
endif()
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
lshpack
|
||||
LIBRARIES
|
||||
ls-hpack
|
||||
ARGS
|
||||
-DSHARED=OFF
|
||||
-DLSHPACK_XXH=ON
|
||||
# There are linking errors when built with non-Release
|
||||
# Undefined symbols for architecture arm64:
|
||||
# "___asan_handle_no_return", referenced from:
|
||||
# _lshpack_enc_get_static_nameval in libls-hpack.a(lshpack.c.o)
|
||||
# _lshpack_enc_get_static_name in libls-hpack.a(lshpack.c.o)
|
||||
# _update_hash in libls-hpack.a(lshpack.c.o)
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
INCLUDES
|
||||
${LSHPACK_INCLUDES}
|
||||
)
|
||||
58
cmake/targets/BuildMimalloc.cmake
Normal file
58
cmake/targets/BuildMimalloc.cmake
Normal file
@@ -0,0 +1,58 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
mimalloc
|
||||
REPOSITORY
|
||||
oven-sh/mimalloc
|
||||
COMMIT
|
||||
4c283af60cdae205df5a872530c77e2a6a307d43
|
||||
)
|
||||
|
||||
set(MIMALLOC_CMAKE_ARGS
|
||||
-DMI_BUILD_STATIC=ON
|
||||
-DMI_BUILD_OBJECT=ON
|
||||
-DMI_BUILD_SHARED=OFF
|
||||
-DMI_BUILD_TESTS=OFF
|
||||
-DMI_USE_CXX=ON
|
||||
-DMI_OVERRIDE=OFF
|
||||
-DMI_OSX_ZONE=OFF
|
||||
-DMI_OSX_INTERPOSE=OFF
|
||||
-DMI_SKIP_COLLECT_ON_EXIT=ON
|
||||
)
|
||||
|
||||
if(DEBUG)
|
||||
list(APPEND MIMALLOC_CMAKE_ARGS -DMI_DEBUG_FULL=ON)
|
||||
endif()
|
||||
|
||||
if(ENABLE_VALGRIND)
|
||||
list(APPEND MIMALLOC_CMAKE_ARGS -DMI_VALGRIND=ON)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(MIMALLOC_LIBRARY mimalloc-static)
|
||||
elseif(DEBUG)
|
||||
set(MIMALLOC_LIBRARY mimalloc-debug)
|
||||
else()
|
||||
set(MIMALLOC_LIBRARY mimalloc)
|
||||
endif()
|
||||
|
||||
# Workaround for linker issue on macOS and Linux x64
|
||||
# https://github.com/microsoft/mimalloc/issues/512
|
||||
if(APPLE OR (LINUX AND NOT DEBUG))
|
||||
set(MIMALLOC_LIBRARY CMakeFiles/mimalloc-obj.dir/src/static.c.o)
|
||||
endif()
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
mimalloc
|
||||
TARGETS
|
||||
mimalloc-static
|
||||
mimalloc-obj
|
||||
ARGS
|
||||
${MIMALLOC_CMAKE_ARGS}
|
||||
LIBRARIES
|
||||
${MIMALLOC_LIBRARY}
|
||||
INCLUDES
|
||||
include
|
||||
)
|
||||
12
cmake/targets/BuildSQLite.cmake
Normal file
12
cmake/targets/BuildSQLite.cmake
Normal file
@@ -0,0 +1,12 @@
|
||||
include(Macros)
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
sqlite
|
||||
CWD
|
||||
${CWD}/src/bun.js/bindings/sqlite
|
||||
LIBRARIES
|
||||
sqlite3
|
||||
INCLUDES
|
||||
.
|
||||
)
|
||||
17
cmake/targets/BuildTinyCC.cmake
Normal file
17
cmake/targets/BuildTinyCC.cmake
Normal file
@@ -0,0 +1,17 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
tinycc
|
||||
REPOSITORY
|
||||
oven-sh/tinycc
|
||||
COMMIT
|
||||
ab631362d839333660a265d3084d8ff060b96753
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
tinycc
|
||||
LIBRARIES
|
||||
tcc
|
||||
)
|
||||
33
cmake/targets/BuildZlib.cmake
Normal file
33
cmake/targets/BuildZlib.cmake
Normal file
@@ -0,0 +1,33 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
zlib
|
||||
REPOSITORY
|
||||
cloudflare/zlib
|
||||
COMMIT
|
||||
886098f3f339617b4243b286f5ed364b9989e245
|
||||
)
|
||||
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/25755
|
||||
if(APPLE)
|
||||
set(ZLIB_CMAKE_C_FLAGS "-fno-define-target-os-macros")
|
||||
set(ZLIB_CMAKE_CXX_FLAGS "-fno-define-target-os-macros")
|
||||
endif()
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
zlib
|
||||
TARGETS
|
||||
zlib
|
||||
ARGS
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
-DBUILD_EXAMPLES=OFF
|
||||
"-DCMAKE_C_FLAGS=${ZLIB_CMAKE_C_FLAGS}"
|
||||
"-DCMAKE_CXX_FLAGS=${ZLIB_CMAKE_CXX_FLAGS}"
|
||||
LIBRARIES
|
||||
zlib WIN32
|
||||
z UNIX
|
||||
INCLUDES
|
||||
.
|
||||
)
|
||||
28
cmake/targets/BuildZstd.cmake
Normal file
28
cmake/targets/BuildZstd.cmake
Normal file
@@ -0,0 +1,28 @@
|
||||
include(Macros)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
zstd
|
||||
REPOSITORY
|
||||
facebook/zstd
|
||||
COMMIT
|
||||
794ea1b0afca0f020f4e57b6732332231fb23c70
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
zstd
|
||||
TARGETS
|
||||
libzstd_static
|
||||
ARGS
|
||||
-Sbuild/cmake
|
||||
-DZSTD_BUILD_STATIC=ON
|
||||
-DZSTD_BUILD_PROGRAMS=OFF
|
||||
-DZSTD_BUILD_TESTS=OFF
|
||||
-DZSTD_BUILD_CONTRIB=OFF
|
||||
LIB_PATH
|
||||
lib
|
||||
LIBRARIES
|
||||
zstd_static WIN32
|
||||
zstd UNIX
|
||||
)
|
||||
5
cmake/toolchains/darwin-aarch64.cmake
Normal file
5
cmake/toolchains/darwin-aarch64.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
set(CMAKE_SYSTEM_NAME Darwin)
|
||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||
|
||||
set(CMAKE_C_COMPILER_WORKS ON)
|
||||
set(CMAKE_CXX_COMPILER_WORKS ON)
|
||||
6
cmake/toolchains/darwin-x64.cmake
Normal file
6
cmake/toolchains/darwin-x64.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
set(CMAKE_SYSTEM_NAME Darwin)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x64)
|
||||
set(CMAKE_OSX_ARCHITECTURES x86_64)
|
||||
|
||||
set(CMAKE_C_COMPILER_WORKS ON)
|
||||
set(CMAKE_CXX_COMPILER_WORKS ON)
|
||||
5
cmake/toolchains/linux-aarch64.cmake
Normal file
5
cmake/toolchains/linux-aarch64.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||
|
||||
set(CMAKE_C_COMPILER_WORKS ON)
|
||||
set(CMAKE_CXX_COMPILER_WORKS ON)
|
||||
6
cmake/toolchains/linux-x64-baseline.cmake
Normal file
6
cmake/toolchains/linux-x64-baseline.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x64)
|
||||
set(ENABLE_BASELINE ON)
|
||||
|
||||
set(CMAKE_C_COMPILER_WORKS ON)
|
||||
set(CMAKE_CXX_COMPILER_WORKS ON)
|
||||
5
cmake/toolchains/linux-x64.cmake
Normal file
5
cmake/toolchains/linux-x64.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x64)
|
||||
|
||||
set(CMAKE_C_COMPILER_WORKS ON)
|
||||
set(CMAKE_CXX_COMPILER_WORKS ON)
|
||||
6
cmake/toolchains/windows-x64-baseline.cmake
Normal file
6
cmake/toolchains/windows-x64-baseline.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x64)
|
||||
set(ENABLE_BASELINE ON)
|
||||
|
||||
set(CMAKE_C_COMPILER_WORKS ON)
|
||||
set(CMAKE_CXX_COMPILER_WORKS ON)
|
||||
5
cmake/toolchains/windows-x64.cmake
Normal file
5
cmake/toolchains/windows-x64.cmake
Normal file
@@ -0,0 +1,5 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x64)
|
||||
|
||||
set(CMAKE_C_COMPILER_WORKS ON)
|
||||
set(CMAKE_CXX_COMPILER_WORKS ON)
|
||||
177
cmake/tools/SetupBuildkite.cmake
Normal file
177
cmake/tools/SetupBuildkite.cmake
Normal file
@@ -0,0 +1,177 @@
|
||||
include(Macros)
|
||||
|
||||
optionx(BUILDKITE_CACHE BOOL "If the build can use Buildkite caches, even if not running in Buildkite" DEFAULT ${BUILDKITE})
|
||||
|
||||
if(NOT BUILDKITE_CACHE OR NOT BUN_LINK_ONLY)
|
||||
return()
|
||||
endif()
|
||||
|
||||
optionx(BUILDKITE_ORGANIZATION_SLUG STRING "The organization slug to use on Buildkite" DEFAULT "bun")
|
||||
optionx(BUILDKITE_PIPELINE_SLUG STRING "The pipeline slug to use on Buildkite" DEFAULT "bun")
|
||||
optionx(BUILDKITE_BUILD_ID STRING "The build ID to use on Buildkite")
|
||||
optionx(BUILDKITE_GROUP_ID STRING "The group ID to use on Buildkite")
|
||||
|
||||
if(ENABLE_BASELINE)
|
||||
set(DEFAULT_BUILDKITE_GROUP_KEY ${OS}-${ARCH}-baseline)
|
||||
else()
|
||||
set(DEFAULT_BUILDKITE_GROUP_KEY ${OS}-${ARCH})
|
||||
endif()
|
||||
|
||||
optionx(BUILDKITE_GROUP_KEY STRING "The group key to use on Buildkite" DEFAULT ${DEFAULT_BUILDKITE_GROUP_KEY})
|
||||
|
||||
if(BUILDKITE)
|
||||
optionx(BUILDKITE_BUILD_ID_OVERRIDE STRING "The build ID to use on Buildkite")
|
||||
if(BUILDKITE_BUILD_ID_OVERRIDE)
|
||||
setx(BUILDKITE_BUILD_ID ${BUILDKITE_BUILD_ID_OVERRIDE})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(BUILDKITE_PATH ${BUILD_PATH}/buildkite)
|
||||
set(BUILDKITE_BUILDS_PATH ${BUILDKITE_PATH}/builds)
|
||||
|
||||
if(NOT BUILDKITE_BUILD_ID)
|
||||
# TODO: find the latest build on the main branch that passed
|
||||
return()
|
||||
endif()
|
||||
|
||||
setx(BUILDKITE_BUILD_URL https://buildkite.com/${BUILDKITE_ORGANIZATION_SLUG}/${BUILDKITE_PIPELINE_SLUG}/builds/${BUILDKITE_BUILD_ID})
|
||||
setx(BUILDKITE_BUILD_PATH ${BUILDKITE_BUILDS_PATH}/builds/${BUILDKITE_BUILD_ID})
|
||||
|
||||
file(
|
||||
DOWNLOAD ${BUILDKITE_BUILD_URL}
|
||||
HTTPHEADER "Accept: application/json"
|
||||
TIMEOUT 15
|
||||
STATUS BUILDKITE_BUILD_STATUS
|
||||
${BUILDKITE_BUILD_PATH}/build.json
|
||||
)
|
||||
if(NOT BUILDKITE_BUILD_STATUS EQUAL 0)
|
||||
message(FATAL_ERROR "No build found: ${BUILDKITE_BUILD_STATUS} ${BUILDKITE_BUILD_URL}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(READ ${BUILDKITE_BUILD_PATH}/build.json BUILDKITE_BUILD)
|
||||
string(JSON BUILDKITE_BUILD_UUID GET ${BUILDKITE_BUILD} id)
|
||||
string(JSON BUILDKITE_JOBS GET ${BUILDKITE_BUILD} jobs)
|
||||
string(JSON BUILDKITE_JOBS_COUNT LENGTH ${BUILDKITE_JOBS})
|
||||
|
||||
if(NOT BUILDKITE_JOBS_COUNT GREATER 0)
|
||||
message(FATAL_ERROR "No jobs found: ${BUILDKITE_BUILD_URL}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(BUILDKITE_JOBS_FAILED)
|
||||
set(BUILDKITE_JOBS_NOT_FOUND)
|
||||
set(BUILDKITE_JOBS_NO_ARTIFACTS)
|
||||
set(BUILDKITE_JOBS_NO_MATCH)
|
||||
set(BUILDKITE_JOBS_MATCH)
|
||||
|
||||
math(EXPR BUILDKITE_JOBS_MAX_INDEX "${BUILDKITE_JOBS_COUNT} - 1")
|
||||
foreach(i RANGE ${BUILDKITE_JOBS_MAX_INDEX})
|
||||
string(JSON BUILDKITE_JOB GET ${BUILDKITE_JOBS} ${i})
|
||||
string(JSON BUILDKITE_JOB_ID GET ${BUILDKITE_JOB} id)
|
||||
string(JSON BUILDKITE_JOB_PASSED GET ${BUILDKITE_JOB} passed)
|
||||
string(JSON BUILDKITE_JOB_GROUP_ID GET ${BUILDKITE_JOB} group_uuid)
|
||||
string(JSON BUILDKITE_JOB_GROUP_KEY GET ${BUILDKITE_JOB} group_identifier)
|
||||
string(JSON BUILDKITE_JOB_NAME GET ${BUILDKITE_JOB} step_key)
|
||||
if(NOT BUILDKITE_JOB_NAME)
|
||||
string(JSON BUILDKITE_JOB_NAME GET ${BUILDKITE_JOB} name)
|
||||
endif()
|
||||
|
||||
if(NOT BUILDKITE_JOB_PASSED)
|
||||
list(APPEND BUILDKITE_JOBS_FAILED ${BUILDKITE_JOB_NAME})
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if(NOT (BUILDKITE_GROUP_ID AND BUILDKITE_GROUP_ID STREQUAL BUILDKITE_JOB_GROUP_ID) AND
|
||||
NOT (BUILDKITE_GROUP_KEY AND BUILDKITE_GROUP_KEY STREQUAL BUILDKITE_JOB_GROUP_KEY))
|
||||
list(APPEND BUILDKITE_JOBS_NO_MATCH ${BUILDKITE_JOB_NAME})
|
||||
continue()
|
||||
endif()
|
||||
|
||||
set(BUILDKITE_ARTIFACTS_URL https://buildkite.com/organizations/${BUILDKITE_ORGANIZATION_SLUG}/pipelines/${BUILDKITE_PIPELINE_SLUG}/builds/${BUILDKITE_BUILD_UUID}/jobs/${BUILDKITE_JOB_ID}/artifacts)
|
||||
set(BUILDKITE_ARTIFACTS_PATH ${BUILDKITE_BUILD_PATH}/artifacts/${BUILDKITE_JOB_ID}.json)
|
||||
|
||||
file(
|
||||
DOWNLOAD ${BUILDKITE_ARTIFACTS_URL}
|
||||
HTTPHEADER "Accept: application/json"
|
||||
TIMEOUT 15
|
||||
STATUS BUILDKITE_ARTIFACTS_STATUS
|
||||
${BUILDKITE_ARTIFACTS_PATH}
|
||||
)
|
||||
|
||||
if(NOT BUILDKITE_ARTIFACTS_STATUS EQUAL 0)
|
||||
list(APPEND BUILDKITE_JOBS_NOT_FOUND ${BUILDKITE_JOB_NAME})
|
||||
continue()
|
||||
endif()
|
||||
|
||||
file(READ ${BUILDKITE_ARTIFACTS_PATH} BUILDKITE_ARTIFACTS)
|
||||
string(JSON BUILDKITE_ARTIFACTS_LENGTH LENGTH ${BUILDKITE_ARTIFACTS})
|
||||
if(NOT BUILDKITE_ARTIFACTS_LENGTH GREATER 0)
|
||||
list(APPEND BUILDKITE_JOBS_NO_ARTIFACTS ${BUILDKITE_JOB_NAME})
|
||||
continue()
|
||||
endif()
|
||||
|
||||
math(EXPR BUILDKITE_ARTIFACTS_MAX_INDEX "${BUILDKITE_ARTIFACTS_LENGTH} - 1")
|
||||
foreach(i RANGE 0 ${BUILDKITE_ARTIFACTS_MAX_INDEX})
|
||||
string(JSON BUILDKITE_ARTIFACT GET ${BUILDKITE_ARTIFACTS} ${i})
|
||||
string(JSON BUILDKITE_ARTIFACT_ID GET ${BUILDKITE_ARTIFACT} id)
|
||||
string(JSON BUILDKITE_ARTIFACT_PATH GET ${BUILDKITE_ARTIFACT} path)
|
||||
|
||||
if(NOT BUILDKITE_ARTIFACT_PATH MATCHES "\\.(o|a|lib|zip|tar|gz)")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if(BUILDKITE)
|
||||
set(BUILDKITE_DOWNLOAD_COMMAND buildkite-agent artifact download ${BUILDKITE_ARTIFACT_PATH} . --build ${BUILDKITE_BUILD_UUID} --step ${BUILDKITE_JOB_ID})
|
||||
else()
|
||||
set(BUILDKITE_DOWNLOAD_COMMAND curl -L -o ${BUILDKITE_ARTIFACT_PATH} ${BUILDKITE_ARTIFACTS_URL}/${BUILDKITE_ARTIFACT_ID})
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
COMMENT
|
||||
"Downloading ${BUILDKITE_ARTIFACT_PATH}"
|
||||
VERBATIM COMMAND
|
||||
${BUILDKITE_DOWNLOAD_COMMAND}
|
||||
WORKING_DIRECTORY
|
||||
${BUILD_PATH}
|
||||
OUTPUT
|
||||
${BUILD_PATH}/${BUILDKITE_ARTIFACT_PATH}
|
||||
)
|
||||
endforeach()
|
||||
|
||||
list(APPEND BUILDKITE_JOBS_MATCH ${BUILDKITE_JOB_NAME})
|
||||
endforeach()
|
||||
|
||||
if(BUILDKITE_JOBS_FAILED)
|
||||
list(SORT BUILDKITE_JOBS_FAILED COMPARE STRING)
|
||||
list(JOIN BUILDKITE_JOBS_FAILED " " BUILDKITE_JOBS_FAILED)
|
||||
message(WARNING "The following jobs were found, but failed: ${BUILDKITE_JOBS_FAILED}")
|
||||
endif()
|
||||
|
||||
if(BUILDKITE_JOBS_NOT_FOUND)
|
||||
list(SORT BUILDKITE_JOBS_NOT_FOUND COMPARE STRING)
|
||||
list(JOIN BUILDKITE_JOBS_NOT_FOUND " " BUILDKITE_JOBS_NOT_FOUND)
|
||||
message(WARNING "The following jobs were found, but could not fetch their data: ${BUILDKITE_JOBS_NOT_FOUND}")
|
||||
endif()
|
||||
|
||||
if(BUILDKITE_JOBS_NO_MATCH)
|
||||
list(SORT BUILDKITE_JOBS_NO_MATCH COMPARE STRING)
|
||||
list(JOIN BUILDKITE_JOBS_NO_MATCH " " BUILDKITE_JOBS_NO_MATCH)
|
||||
message(WARNING "The following jobs were found, but did not match the group ID: ${BUILDKITE_JOBS_NO_MATCH}")
|
||||
endif()
|
||||
|
||||
if(BUILDKITE_JOBS_NO_ARTIFACTS)
|
||||
list(SORT BUILDKITE_JOBS_NO_ARTIFACTS COMPARE STRING)
|
||||
list(JOIN BUILDKITE_JOBS_NO_ARTIFACTS " " BUILDKITE_JOBS_NO_ARTIFACTS)
|
||||
message(WARNING "The following jobs were found, but had no artifacts: ${BUILDKITE_JOBS_NO_ARTIFACTS}")
|
||||
endif()
|
||||
|
||||
if(BUILDKITE_JOBS_MATCH)
|
||||
list(SORT BUILDKITE_JOBS_MATCH COMPARE STRING)
|
||||
list(JOIN BUILDKITE_JOBS_MATCH " " BUILDKITE_JOBS_MATCH)
|
||||
message(STATUS "The following jobs were found, and matched the group ID: ${BUILDKITE_JOBS_MATCH}")
|
||||
endif()
|
||||
|
||||
if(NOT BUILDKITE_JOBS_FAILED AND NOT BUILDKITE_JOBS_NOT_FOUND AND NOT BUILDKITE_JOBS_NO_MATCH AND NOT BUILDKITE_JOBS_NO_ARTIFACTS AND NOT BUILDKITE_JOBS_MATCH)
|
||||
message(FATAL_ERROR "Something went wrong with Buildkite?")
|
||||
endif()
|
||||
23
cmake/tools/SetupBun.cmake
Normal file
23
cmake/tools/SetupBun.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
include(Macros)
|
||||
|
||||
find_command(
|
||||
VARIABLE
|
||||
BUN_EXECUTABLE
|
||||
COMMAND
|
||||
bun
|
||||
PATHS
|
||||
$ENV{HOME}/.bun/bin
|
||||
VERSION
|
||||
>=1.1.26
|
||||
)
|
||||
|
||||
# If this is not set, some advanced features are not checked.
|
||||
# https://github.com/oven-sh/bun/blob/cd7f6a1589db7f1e39dc4e3f4a17234afbe7826c/src/bun.js/javascript.zig#L1069-L1072
|
||||
setenv(BUN_GARBAGE_COLLECTOR_LEVEL 1)
|
||||
setenv(BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING 1)
|
||||
setenv(BUN_DEBUG_QUIET_LOGS 1)
|
||||
|
||||
# FIXME: https://github.com/oven-sh/bun/issues/11250
|
||||
if(NOT WIN32)
|
||||
setenv(BUN_INSTALL_CACHE_DIR ${CACHE_PATH}/bun)
|
||||
endif()
|
||||
42
cmake/tools/SetupCcache.cmake
Normal file
42
cmake/tools/SetupCcache.cmake
Normal file
@@ -0,0 +1,42 @@
|
||||
include(Macros)
|
||||
|
||||
optionx(ENABLE_CCACHE BOOL "If ccache should be enabled" DEFAULT ON)
|
||||
|
||||
if(NOT ENABLE_CCACHE OR CACHE_STRATEGY STREQUAL "none")
|
||||
setenv(CCACHE_DISABLE 1)
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_command(
|
||||
VARIABLE
|
||||
CCACHE_PROGRAM
|
||||
COMMAND
|
||||
ccache
|
||||
REQUIRED
|
||||
ON
|
||||
)
|
||||
|
||||
set(CCACHE_ARGS CMAKE_C_COMPILER_LAUNCHER CMAKE_CXX_COMPILER_LAUNCHER)
|
||||
foreach(arg ${CCACHE_ARGS})
|
||||
setx(${arg} ${CCACHE_PROGRAM})
|
||||
list(APPEND CMAKE_ARGS -D${arg}=${${arg}})
|
||||
endforeach()
|
||||
|
||||
setenv(CCACHE_DIR ${CACHE_PATH}/ccache)
|
||||
setenv(CCACHE_BASEDIR ${CWD})
|
||||
setenv(CCACHE_NOHASHDIR 1)
|
||||
|
||||
if(CACHE_STRATEGY STREQUAL "read-only")
|
||||
setenv(CCACHE_READONLY 1)
|
||||
elseif(CACHE_STRATEGY STREQUAL "write-only")
|
||||
setenv(CCACHE_RECACHE 1)
|
||||
endif()
|
||||
|
||||
setenv(CCACHE_FILECLONE 1)
|
||||
setenv(CCACHE_STATSLOG ${BUILD_PATH}/ccache.log)
|
||||
|
||||
if(CI)
|
||||
setenv(CCACHE_SLOPPINESS "pch_defines,time_macros,locale,clang_index_store,gcno_cwd,include_file_ctime,include_file_mtime")
|
||||
else()
|
||||
setenv(CCACHE_SLOPPINESS "pch_defines,time_macros,locale,random_seed,clang_index_store,gcno_cwd")
|
||||
endif()
|
||||
22
cmake/tools/SetupEsbuild.cmake
Normal file
22
cmake/tools/SetupEsbuild.cmake
Normal file
@@ -0,0 +1,22 @@
|
||||
include(Macros)
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
setx(ESBUILD_EXECUTABLE ${CWD}/node_modules/.bin/esbuild.exe)
|
||||
else()
|
||||
setx(ESBUILD_EXECUTABLE ${CWD}/node_modules/.bin/esbuild)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COLOR_DIAGNOSTICS)
|
||||
set(ESBUILD_ARGS --color)
|
||||
endif()
|
||||
|
||||
register_command(
|
||||
COMMAND
|
||||
${BUN_EXECUTABLE}
|
||||
install
|
||||
--frozen-lockfile
|
||||
SOURCES
|
||||
${CWD}/package.json
|
||||
OUTPUTS
|
||||
${ESBUILD_EXECUTABLE}
|
||||
)
|
||||
67
cmake/tools/SetupLLVM.cmake
Normal file
67
cmake/tools/SetupLLVM.cmake
Normal file
@@ -0,0 +1,67 @@
|
||||
include(Macros)
|
||||
|
||||
if(CMAKE_HOST_WIN32 OR CMAKE_HOST_APPLE)
|
||||
set(DEFAULT_LLVM_VERSION "18.1.8")
|
||||
else()
|
||||
set(DEFAULT_LLVM_VERSION "16.0.6")
|
||||
endif()
|
||||
|
||||
optionx(LLVM_VERSION STRING "The version of LLVM to use" DEFAULT ${DEFAULT_LLVM_VERSION})
|
||||
parse_semver(${LLVM_VERSION} LLVM)
|
||||
|
||||
if(APPLE)
|
||||
execute_process(
|
||||
COMMAND brew --prefix llvm@${LLVM_VERSION_MAJOR}
|
||||
OUTPUT_VARIABLE DEFAULT_LLVM_PREFIX
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
if(NOT DEFAULT_LLVM_PREFIX)
|
||||
set(DEFAULT_LLVM_PREFIX /opt/homebrew/opt/llvm)
|
||||
endif()
|
||||
elseif(NOT WIN32)
|
||||
set(DEFAULT_LLVM_PREFIX /usr/lib/llvm-${LLVM_VERSION_MAJOR})
|
||||
else()
|
||||
set(DEFAULT_LLVM_PREFIX /usr/lib)
|
||||
endif()
|
||||
|
||||
optionx(LLVM_PREFIX FILEPATH "The path to the LLVM installation" DEFAULT ${DEFAULT_LLVM_PREFIX})
|
||||
set(LLVM_PATH ${LLVM_PREFIX}/bin)
|
||||
|
||||
macro(find_llvm_command VARIABLE COMMAND)
|
||||
find_command(
|
||||
VARIABLE ${VARIABLE}
|
||||
COMMAND ${COMMAND} ${COMMAND}-${LLVM_VERSION_MAJOR}
|
||||
PATHS ${LLVM_PATH}
|
||||
VERSION ${LLVM_VERSION}
|
||||
)
|
||||
list(APPEND CMAKE_ARGS -D${VARIABLE}=${${VARIABLE}})
|
||||
endmacro()
|
||||
|
||||
macro(find_llvm_command_no_version VARIABLE COMMAND)
|
||||
find_command(
|
||||
VARIABLE ${VARIABLE}
|
||||
COMMAND ${COMMAND} ${COMMAND}-${LLVM_VERSION_MAJOR}
|
||||
PATHS ${LLVM_PATH}
|
||||
REQUIRED ON
|
||||
)
|
||||
list(APPEND CMAKE_ARGS -D${VARIABLE}=${${VARIABLE}})
|
||||
endmacro()
|
||||
|
||||
if(WIN32)
|
||||
find_llvm_command(CMAKE_C_COMPILER clang-cl)
|
||||
find_llvm_command(CMAKE_CXX_COMPILER clang-cl)
|
||||
find_llvm_command_no_version(CMAKE_LINKER lld-link)
|
||||
find_llvm_command_no_version(CMAKE_AR llvm-lib)
|
||||
find_llvm_command_no_version(CMAKE_STRIP llvm-strip)
|
||||
else()
|
||||
find_llvm_command(CMAKE_C_COMPILER clang)
|
||||
find_llvm_command(CMAKE_CXX_COMPILER clang++)
|
||||
find_llvm_command(CMAKE_LINKER llvm-link)
|
||||
find_llvm_command(CMAKE_AR llvm-ar)
|
||||
find_llvm_command(CMAKE_STRIP llvm-strip)
|
||||
find_llvm_command(CMAKE_RANLIB llvm-ranlib)
|
||||
if(APPLE)
|
||||
find_llvm_command(CMAKE_DSYMUTIL dsymutil)
|
||||
endif()
|
||||
endif()
|
||||
59
cmake/tools/SetupMacSDK.cmake
Normal file
59
cmake/tools/SetupMacSDK.cmake
Normal file
@@ -0,0 +1,59 @@
|
||||
include(Macros)
|
||||
|
||||
set(MIN_OSX_DEPLOYMENT_TARGET "13.0")
|
||||
|
||||
if(DEFINED ENV{CI})
|
||||
set(DEFAULT_OSX_DEPLOYMENT_TARGET ${MIN_OSX_DEPLOYMENT_TARGET})
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND xcrun --sdk macosx --show-sdk-version
|
||||
OUTPUT_VARIABLE DEFAULT_OSX_DEPLOYMENT_TARGET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_VARIABLE DEFAULT_OSX_DEPLOYMENT_TARGET_ERROR
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(DEFAULT_OSX_DEPLOYMENT_TARGET_ERROR)
|
||||
message(WARNING "Failed to find macOS SDK version, did you run `xcode-select --install`?")
|
||||
message(FATAL_ERROR ${DEFAULT_OSX_DEPLOYMENT_TARGET_ERROR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
optionx(CMAKE_OSX_DEPLOYMENT_TARGET STRING "The macOS SDK version to target" DEFAULT ${DEFAULT_OSX_DEPLOYMENT_TARGET})
|
||||
|
||||
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS ${MIN_OSX_DEPLOYMENT_TARGET})
|
||||
message(FATAL_ERROR "The target macOS SDK version, ${CMAKE_OSX_DEPLOYMENT_TARGET}, is older than the minimum supported version, ${MIN_OSX_DEPLOYMENT_TARGET}.")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND sw_vers -productVersion
|
||||
OUTPUT_VARIABLE MACOS_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
if(MACOS_VERSION VERSION_LESS ${CMAKE_OSX_DEPLOYMENT_TARGET})
|
||||
message(FATAL_ERROR "Your computer is running macOS ${MACOS_VERSION}, which is older than the target macOS SDK ${CMAKE_OSX_DEPLOYMENT_TARGET}. To fix this, either:\n"
|
||||
" - Upgrade your computer to macOS ${CMAKE_OSX_DEPLOYMENT_TARGET} or newer\n"
|
||||
" - Download a newer version of the macOS SDK from Apple: https://developer.apple.com/download/all/?q=xcode\n"
|
||||
" - Set -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_VERSION}\n")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND xcrun --sdk macosx --show-sdk-path
|
||||
OUTPUT_VARIABLE DEFAULT_CMAKE_OSX_SYSROOT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_VARIABLE DEFAULT_CMAKE_OSX_SYSROOT_ERROR
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if(CMAKE_OSX_SYSROOT_ERROR)
|
||||
message(WARNING "Failed to find macOS SDK path, did you run `xcode-select --install`?")
|
||||
message(FATAL_ERROR ${CMAKE_OSX_SYSROOT_ERROR})
|
||||
endif()
|
||||
|
||||
optionx(CMAKE_OSX_SYSROOT STRING "The macOS SDK path to target" DEFAULT ${DEFAULT_CMAKE_OSX_SYSROOT})
|
||||
|
||||
list(APPEND CMAKE_ARGS
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
|
||||
-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
|
||||
)
|
||||
27
cmake/tools/SetupRust.cmake
Normal file
27
cmake/tools/SetupRust.cmake
Normal file
@@ -0,0 +1,27 @@
|
||||
include(Macros)
|
||||
|
||||
find_command(
|
||||
VARIABLE
|
||||
CARGO_EXECUTABLE
|
||||
COMMAND
|
||||
cargo
|
||||
PATHS
|
||||
$ENV{HOME}/.cargo/bin
|
||||
REQUIRED
|
||||
OFF
|
||||
)
|
||||
|
||||
if(EXISTS ${CARGO_EXECUTABLE})
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
set(CARGO_INSTALL_COMMAND "choco install rust")
|
||||
else()
|
||||
set(CARGO_INSTALL_COMMAND "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh")
|
||||
endif()
|
||||
|
||||
message(FATAL_ERROR "Command not found: cargo\n"
|
||||
"Do you have Rust installed? To fix this, try running:\n"
|
||||
" ${CARGO_INSTALL_COMMAND}\n"
|
||||
)
|
||||
134
cmake/tools/SetupWebKit.cmake
Normal file
134
cmake/tools/SetupWebKit.cmake
Normal file
@@ -0,0 +1,134 @@
|
||||
include(Macros)
|
||||
|
||||
optionx(WEBKIT_VERSION STRING "The version of WebKit to use" DEFAULT "147ed53838e21525677492c27099567a6cd19c6b")
|
||||
optionx(WEBKIT_PREBUILT BOOL "If a pre-built version of WebKit should be used" DEFAULT ON)
|
||||
|
||||
if(WEBKIT_PREBUILT)
|
||||
set(DEFAULT_WEBKIT_PATH ${CACHE_PATH}/webkit)
|
||||
else()
|
||||
set(DEFAULT_WEBKIT_PATH ${CWD}/src/bun.js/WebKit)
|
||||
endif()
|
||||
|
||||
optionx(WEBKIT_PATH FILEPATH "The path to the WebKit directory" DEFAULT ${DEFAULT_WEBKIT_PATH})
|
||||
|
||||
setx(WEBKIT_INCLUDE_PATH ${WEBKIT_PATH}/include)
|
||||
setx(WEBKIT_LIB_PATH ${WEBKIT_PATH}/lib)
|
||||
|
||||
if(NOT WEBKIT_PREBUILT)
|
||||
if(EXISTS ${WEBKIT_PATH}/cmakeconfig.h)
|
||||
# You may need to run:
|
||||
# make jsc-compile-debug jsc-copy-headers
|
||||
include_directories(
|
||||
${WEBKIT_PATH}
|
||||
${WEBKIT_PATH}/JavaScriptCore/Headers/JavaScriptCore
|
||||
${WEBKIT_PATH}/JavaScriptCore/PrivateHeaders
|
||||
${WEBKIT_PATH}/bmalloc/Headers
|
||||
${WEBKIT_PATH}/WTF/Headers
|
||||
)
|
||||
endif()
|
||||
|
||||
# After this point, only prebuilt WebKit is supported
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(EXISTS ${WEBKIT_PATH}/package.json)
|
||||
file(READ ${WEBKIT_PATH}/package.json WEBKIT_PACKAGE_JSON)
|
||||
|
||||
if(WEBKIT_PACKAGE_JSON MATCHES ${WEBKIT_VERSION})
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(WEBKIT_OS "windows")
|
||||
elseif(APPLE)
|
||||
set(WEBKIT_OS "macos")
|
||||
elseif(UNIX)
|
||||
set(WEBKIT_OS "linux")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported operating system: ${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
||||
set(WEBKIT_ARCH "arm64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|x64|AMD64")
|
||||
set(WEBKIT_ARCH "amd64")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
if(DEBUG)
|
||||
set(WEBKIT_SUFFIX "-debug")
|
||||
elseif(ENABLE_LTO AND NOT WIN32)
|
||||
set(WEBKIT_SUFFIX "-lto")
|
||||
else()
|
||||
set(WEBKIT_SUFFIX "")
|
||||
endif()
|
||||
|
||||
set(WEBKIT_NAME bun-webkit-${WEBKIT_OS}-${WEBKIT_ARCH}${WEBKIT_SUFFIX})
|
||||
set(WEBKIT_FILENAME ${WEBKIT_NAME}.tar.gz)
|
||||
setx(WEBKIT_DOWNLOAD_URL https://github.com/oven-sh/WebKit/releases/download/autobuild-${WEBKIT_VERSION}/${WEBKIT_FILENAME})
|
||||
|
||||
file(DOWNLOAD ${WEBKIT_DOWNLOAD_URL} ${CACHE_PATH}/${WEBKIT_FILENAME})
|
||||
file(ARCHIVE_EXTRACT INPUT ${CACHE_PATH}/${WEBKIT_FILENAME} DESTINATION ${CACHE_PATH})
|
||||
file(REMOVE ${CACHE_PATH}/${WEBKIT_FILENAME})
|
||||
file(REMOVE_RECURSE ${WEBKIT_PATH})
|
||||
file(RENAME ${CACHE_PATH}/bun-webkit ${WEBKIT_PATH})
|
||||
|
||||
if(APPLE)
|
||||
file(REMOVE_RECURSE ${WEBKIT_INCLUDE_PATH}/unicode)
|
||||
endif()
|
||||
|
||||
# --- WebKit ---
|
||||
# WebKit is either prebuilt and distributed via NPM, or you can pass WEBKIT_PATH to use a local build.
|
||||
# We cannot include their CMake build files (TODO: explain why, for now ask @paperdave why)
|
||||
#
|
||||
# On Unix, this will pull from NPM the single package that is needed and use that
|
||||
# if(WIN32)
|
||||
# set(STATIC_LIB_EXT "lib")
|
||||
# set(libJavaScriptCore "JavaScriptCore")
|
||||
# set(libWTF "WTF")
|
||||
# else()
|
||||
# set(STATIC_LIB_EXT "a")
|
||||
# set(libJavaScriptCore "libJavaScriptCore")
|
||||
# set(libWTF "libWTF")
|
||||
# endif()
|
||||
|
||||
# if(WEBKIT_PREBUILT)
|
||||
|
||||
# elseif(WEBKIT_PATH STREQUAL "omit")
|
||||
|
||||
# else()
|
||||
# # Expected to be WebKit/WebKitBuild/${CMAKE_BUILD_TYPE}
|
||||
# if(EXISTS "${WEBKIT_PATH}/cmakeconfig.h")
|
||||
# # You may need to run:
|
||||
# # make jsc-compile-debug jsc-copy-headers
|
||||
# include_directories(
|
||||
# "${WEBKIT_PATH}/"
|
||||
# "${WEBKIT_PATH}/JavaScriptCore/Headers/JavaScriptCore"
|
||||
# "${WEBKIT_PATH}/JavaScriptCore/PrivateHeaders"
|
||||
# "${WEBKIT_PATH}/bmalloc/Headers"
|
||||
# "${WEBKIT_PATH}/WTF/Headers"
|
||||
# )
|
||||
# set(WEBKIT_LIB_DIR "${WEBKIT_PATH}/lib")
|
||||
|
||||
# if(ENABLE_ASSERTIONS)
|
||||
# add_compile_definitions("BUN_DEBUG=1")
|
||||
# endif()
|
||||
|
||||
# message(STATUS "Using WebKit from ${WEBKIT_PATH}")
|
||||
# else()
|
||||
# if(NOT EXISTS "${WEBKIT_PATH}/lib/${libWTF}.${STATIC_LIB_EXT}" OR NOT EXISTS "${WEBKIT_PATH}/lib/${libJavaScriptCore}.${STATIC_LIB_EXT}")
|
||||
# if(WEBKIT_PATH MATCHES "src/bun.js/WebKit$")
|
||||
# message(FATAL_ERROR "WebKit directory ${WEBKIT_PATH} does not contain all the required files for Bun. Did you forget to init submodules?")
|
||||
# endif()
|
||||
|
||||
# message(FATAL_ERROR "WebKit directory ${WEBKIT_PATH} does not contain all the required files for Bun. Expected a path to the oven-sh/WebKit repository, or a path to a folder containing `include` and `lib`.")
|
||||
# endif()
|
||||
|
||||
# set(WEBKIT_LIB_DIR "${WEBKIT_PATH}/lib")
|
||||
|
||||
# message(STATUS "Using specified WebKit directory: ${WEBKIT_PATH}")
|
||||
# message(STATUS "WebKit assertions: OFF")
|
||||
# endif()
|
||||
# endif()
|
||||
130
cmake/tools/SetupZig.cmake
Normal file
130
cmake/tools/SetupZig.cmake
Normal file
@@ -0,0 +1,130 @@
|
||||
include(Macros)
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
||||
set(DEFAULT_ZIG_ARCH "aarch64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|x64|AMD64")
|
||||
set(DEFAULT_ZIG_ARCH "x86_64")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(DEFAULT_ZIG_TARGET ${DEFAULT_ZIG_ARCH}-macos-none)
|
||||
elseif(WIN32)
|
||||
set(DEFAULT_ZIG_TARGET ${DEFAULT_ZIG_ARCH}-windows-msvc)
|
||||
elseif(LINUX)
|
||||
set(DEFAULT_ZIG_TARGET ${DEFAULT_ZIG_ARCH}-linux-gnu)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported operating system: ${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
|
||||
optionx(ZIG_TARGET STRING "The zig target to use" DEFAULT ${DEFAULT_ZIG_TARGET})
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(DEFAULT_ZIG_OPTIMIZE "ReleaseFast")
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
set(DEFAULT_ZIG_OPTIMIZE "ReleaseSafe")
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
||||
set(DEFAULT_ZIG_OPTIMIZE "ReleaseSmall")
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(DEFAULT_ZIG_OPTIMIZE "Debug")
|
||||
endif()
|
||||
|
||||
# Since Bun 1.1, Windows has been built using ReleaseSafe.
|
||||
# This is because it caught more crashes, but we can reconsider this in the future
|
||||
if(WIN32 AND DEFAULT_ZIG_OPTIMIZE STREQUAL "ReleaseFast")
|
||||
set(DEFAULT_ZIG_OPTIMIZE "ReleaseSafe")
|
||||
endif()
|
||||
|
||||
optionx(ZIG_OPTIMIZE "ReleaseFast|ReleaseSafe|ReleaseSmall|Debug" "The Zig optimize level to use" DEFAULT ${DEFAULT_ZIG_OPTIMIZE})
|
||||
|
||||
# To use LLVM bitcode from Zig, more work needs to be done. Currently, an install of
|
||||
# LLVM 18.1.7 does not compatible with what bitcode Zig 0.13 outputs (has LLVM 18.1.7)
|
||||
# Change to "bc" to experiment, "Invalid record" means it is not valid output.
|
||||
optionx(ZIG_OBJECT_FORMAT "obj|bc" "Output file format for Zig object files" DEFAULT obj)
|
||||
|
||||
optionx(ZIG_VERSION STRING "The version of zig to use" DEFAULT "0.13.0")
|
||||
optionx(ZIG_LOCAL_CACHE_DIR FILEPATH "The path to local the zig cache directory" DEFAULT ${CACHE_PATH}/zig/local)
|
||||
optionx(ZIG_GLOBAL_CACHE_DIR FILEPATH "The path to the global zig cache directory" DEFAULT ${CACHE_PATH}/zig/global)
|
||||
optionx(ZIG_BIN_CACHE_DIR FILEPATH "The path to the zig binary cache directory" DEFAULT ${CACHE_PATH}/zig/bin)
|
||||
optionx(ZIG_REPOSITORY_PATH FILEPATH "The path to the Zig repository" DEFAULT ${CWD}/src/deps/zig)
|
||||
|
||||
register_repository(
|
||||
NAME
|
||||
zig
|
||||
REPOSITORY
|
||||
oven-sh/zig
|
||||
COMMIT
|
||||
131a009ba2eb127a3447d05b9e12f710429aa5ee
|
||||
PATH
|
||||
${ZIG_REPOSITORY_PATH}
|
||||
)
|
||||
|
||||
setenv(ZIG_LOCAL_CACHE_DIR ${ZIG_LOCAL_CACHE_DIR})
|
||||
setenv(ZIG_GLOBAL_CACHE_DIR ${ZIG_GLOBAL_CACHE_DIR})
|
||||
|
||||
set(CMAKE_ZIG_FLAGS
|
||||
--cache-dir ${ZIG_LOCAL_CACHE_DIR}
|
||||
--global-cache-dir ${ZIG_GLOBAL_CACHE_DIR}
|
||||
--zig-lib-dir ${ZIG_REPOSITORY_PATH}/lib
|
||||
)
|
||||
|
||||
find_command(
|
||||
VARIABLE
|
||||
CMAKE_ZIG_COMPILER
|
||||
COMMAND
|
||||
zig
|
||||
zig.exe
|
||||
PATHS
|
||||
${ZIG_BIN_CACHE_DIR}
|
||||
VERSION
|
||||
${ZIG_VERSION}
|
||||
REQUIRED
|
||||
OFF
|
||||
)
|
||||
|
||||
if(NOT CMAKE_ZIG_COMPILER MATCHES "NOTFOUND")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
||||
set(ZIG_HOST_ARCH "aarch64")
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|x64|AMD64")
|
||||
set(ZIG_HOST_ARCH "x86_64")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_HOST_APPLE)
|
||||
set(ZIG_HOST_OS "macos")
|
||||
elseif(CMAKE_HOST_WIN32)
|
||||
set(ZIG_HOST_OS "windows")
|
||||
elseif(CMAKE_HOST_UNIX)
|
||||
set(ZIG_HOST_OS "linux")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported operating system: ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
endif()
|
||||
|
||||
set(ZIG_NAME zig-${ZIG_HOST_OS}-${ZIG_HOST_ARCH}-${ZIG_VERSION})
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
set(ZIG_EXE "zig.exe")
|
||||
set(ZIG_FILENAME ${ZIG_NAME}.zip)
|
||||
else()
|
||||
set(ZIG_EXE "zig")
|
||||
set(ZIG_FILENAME ${ZIG_NAME}.tar.xz)
|
||||
endif()
|
||||
|
||||
setx(ZIG_DOWNLOAD_URL https://ziglang.org/download/${ZIG_VERSION}/${ZIG_FILENAME})
|
||||
|
||||
file(DOWNLOAD ${ZIG_DOWNLOAD_URL} ${ZIG_BIN_CACHE_DIR}/${ZIG_FILENAME})
|
||||
file(ARCHIVE_EXTRACT INPUT ${ZIG_BIN_CACHE_DIR}/${ZIG_FILENAME} DESTINATION ${ZIG_BIN_CACHE_DIR})
|
||||
file(REMOVE ${ZIG_BIN_CACHE_DIR}/${ZIG_FILENAME})
|
||||
file(COPY ${ZIG_BIN_CACHE_DIR}/${ZIG_NAME}/${ZIG_EXE} DESTINATION ${ZIG_BIN_CACHE_DIR})
|
||||
file(REMOVE_RECURSE ${ZIG_BIN_CACHE_DIR}/${ZIG_NAME})
|
||||
file(CHMOD ${ZIG_BIN_CACHE_DIR}/${ZIG_EXE} PERMISSIONS OWNER_EXECUTE)
|
||||
setx(CMAKE_ZIG_COMPILER ${ZIG_BIN_CACHE_DIR}/${ZIG_EXE})
|
||||
|
||||
if(NOT WIN32)
|
||||
file(CREATE_LINK ${ZIG_BIN_CACHE_DIR}/${ZIG_EXE} ${ZIG_BIN_CACHE_DIR}/zig.exe SYMBOLIC)
|
||||
endif()
|
||||
32
package.json
32
package.json
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "bun",
|
||||
"version": "1.1.28",
|
||||
"workspaces": [
|
||||
"./packages/bun-types"
|
||||
],
|
||||
@@ -26,31 +27,32 @@
|
||||
"bun-types": "workspace:packages/bun-types"
|
||||
},
|
||||
"scripts": {
|
||||
"setup": "./scripts/setup.sh",
|
||||
"bump": "bun ./scripts/bump.ts",
|
||||
"build": "if [ ! -e build ]; then bun setup; fi && ninja -C build",
|
||||
"build:valgrind": "cmake . -DZIG_OPTIMIZE=Debug -DUSE_DEBUG_JSC=ON -DCMAKE_BUILD_TYPE=Debug -GNinja -Bbuild-valgrind && ninja -Cbuild-valgrind",
|
||||
"build:tidy": "bash ./scripts/env.sh && BUN_SILENT=1 cmake --log-level=WARNING . ${CMAKE_FLAGS[@]} -DZIG_OPTIMIZE=Debug -DUSE_DEBUG_JSC=ON -DBUN_TIDY_ONLY=ON -DCMAKE_BUILD_TYPE=Debug -GNinja -Bbuild-tidy && BUN_SILENT=1 ninja -Cbuild-tidy",
|
||||
"build:tidy-extra": "cmake . -DZIG_OPTIMIZE=Debug -DUSE_DEBUG_JSC=ON -DBUN_TIDY_ONLY_EXTRA=ON -DCMAKE_BUILD_TYPE=Debug -GNinja -Bbuild-tidy && ninja -Cbuild-tidy",
|
||||
"build:release": "cmake . -DCMAKE_BUILD_TYPE=Release -GNinja -Bbuild-release && ninja -Cbuild-release",
|
||||
"build": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Debug -B build/debug",
|
||||
"build:debug": "bun run build",
|
||||
"build:valgrind": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Debug -DENABLE_BASELINE=ON -ENABLE_VALGRIND=ON -B build/debug-valgrind",
|
||||
"build:release": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -B build/release",
|
||||
"build:ci": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DCI=true -B build/release-ci --verbose",
|
||||
"build:assert": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_ASSERTIONS=ON -DENABLE_LOGS=ON -B build/release-assert",
|
||||
"build:logs": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DENABLE_LOGS=ON -B build/release-logs",
|
||||
"build:safe": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DZIG_OPTIMIZE=ReleaseSafe -B build/release-safe",
|
||||
"build:smol": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=MinSizeRel -B build/release-smol",
|
||||
"build:release:local": "cmake . -DCMAKE_BUILD_TYPE=Release -DWEBKIT_DIR=$(pwd)/src/bun.js/WebKit/WebKitBuild/Release -GNinja -Bbuild-release-local && ninja -Cbuild-release-local",
|
||||
"build:release:with_logs": "cmake . -DCMAKE_BUILD_TYPE=Release -DENABLE_LOGS=true -GNinja -Bbuild-release && ninja -Cbuild-release",
|
||||
"build:debug-zig-release": "cmake . -DCMAKE_BUILD_TYPE=Release -DZIG_OPTIMIZE=Debug -GNinja -Bbuild-debug-zig-release && ninja -Cbuild-debug-zig-release",
|
||||
"build:safe": "cmake . -DZIG_OPTIMIZE=ReleaseSafe -DUSE_DEBUG_JSC=ON -DCMAKE_BUILD_TYPE=Release -GNinja -Bbuild-safe && ninja -Cbuild-safe",
|
||||
"build:windows": "cmake -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Debug && ninja -Cbuild",
|
||||
"build:windows:release": "cmake -B build-release -S . -G Ninja -DCMAKE_BUILD_TYPE=Release && ninja -Cbuild-release",
|
||||
"bump": "bun ./scripts/bump.ts",
|
||||
"typecheck": "tsc --noEmit && cd test && bun run typecheck",
|
||||
"fmt": "prettier --config=.prettierrc-ci --write --cache './{.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}/**/*.{mjs,ts,tsx,js,jsx}'",
|
||||
"fmt:zig": "zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig",
|
||||
"fmt:cpp": "clang-format -i src/bun.js/bindings/**/*.{cpp,h} --verbose",
|
||||
"fmt:zig": "bun run zig:fmt",
|
||||
"lint": "eslint './**/*.d.ts' --cache",
|
||||
"lint:fix": "eslint './**/*.d.ts' --cache --fix",
|
||||
"test": "node scripts/runner.node.mjs ./build/bun-debug",
|
||||
"test:release": "node scripts/runner.node.mjs ./build-release/bun",
|
||||
"banned": "bun packages/bun-internal-test/src/linter.ts",
|
||||
"zig-check": ".cache/zig/zig.exe build check --summary new",
|
||||
"zig-check-all": ".cache/zig/zig.exe build check-all --summary new",
|
||||
"zig-check-windows": ".cache/zig/zig.exe build check-windows --summary new",
|
||||
"zig": ".cache/zig/zig.exe "
|
||||
"zig": "build/debug/cache/zig/bin/zig.exe",
|
||||
"zig:fmt": "bun run zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig",
|
||||
"zig:check": "bun run zig build check --summary new",
|
||||
"zig:check-all": "bun run zig build check-all --summary new",
|
||||
"zig:check-windows": "bun run zig build check-windows --summary new"
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
137
patches/tinycc/CMakeLists.txt
Normal file
137
patches/tinycc/CMakeLists.txt
Normal file
@@ -0,0 +1,137 @@
|
||||
# TODO: Commit to oven-sh/tinycc
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(tinycc VERSION 0.9.28 LANGUAGES C)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
endif()
|
||||
|
||||
add_compile_options(-Wall)
|
||||
|
||||
if(NOT CMAKE_C_COMPILER_ID MATCHES "tcc")
|
||||
add_compile_options(
|
||||
-fno-strict-aliasing
|
||||
-Wdeclaration-after-statement
|
||||
-Wpointer-sign
|
||||
-Wsign-compare
|
||||
-Wunused-result
|
||||
-Wformat-truncation
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
add_compile_options(
|
||||
-fheinous-gnu-extensions
|
||||
-Wno-string-plus-int
|
||||
-Wno-deprecated-declarations
|
||||
)
|
||||
endif()
|
||||
|
||||
add_compile_definitions(
|
||||
CONFIG_TCC_PREDEFS
|
||||
ONE_SOURCE=0
|
||||
TCC_LIBTCC1="\\0"
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
add_compile_definitions(
|
||||
TCC_TARGET_MACHO
|
||||
CONFIG_CODESIGN
|
||||
CONFIG_NEW_MACHO
|
||||
CONFIG_USR_INCLUDE=\"${CMAKE_OSX_SYSROOT}\"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
add_compile_definitions(
|
||||
CONFIG_WIN32
|
||||
CONFIG_TCCDIR=\"${CMAKE_CURRENT_SOURCE_DIR}/win32\"
|
||||
)
|
||||
endif()
|
||||
|
||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION TCC_VERSION)
|
||||
|
||||
add_compile_definitions(TCC_VERSION=\"${TCC_VERSION}\")
|
||||
|
||||
execute_process(
|
||||
COMMAND git rev-parse --short HEAD
|
||||
OUTPUT_VARIABLE TCC_GITHASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
if(TCC_GITHASH)
|
||||
add_compile_definitions(TCC_GITHASH=\"${TCC_GITHASH}\")
|
||||
endif()
|
||||
|
||||
set(TCC_SOURCES
|
||||
libtcc.c
|
||||
tccpp.c
|
||||
tccgen.c
|
||||
tccdbg.c
|
||||
tccelf.c
|
||||
tccasm.c
|
||||
tccrun.c
|
||||
)
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64|ARM64")
|
||||
list(APPEND TCC_SOURCES
|
||||
arm64-gen.c
|
||||
arm64-link.c
|
||||
arm64-asm.c
|
||||
)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|x64|amd64|AMD64")
|
||||
list(APPEND TCC_SOURCES
|
||||
x86_64-gen.c
|
||||
x86_64-link.c
|
||||
i386-asm.c
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND TCC_SOURCES tccmacho.c)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND TCC_SOURCES tccpe.c)
|
||||
endif()
|
||||
|
||||
add_executable(c2str.exe conftest.c)
|
||||
target_compile_options(c2str.exe PRIVATE -DC2STR)
|
||||
|
||||
add_custom_command(
|
||||
TARGET
|
||||
c2str.exe POST_BUILD
|
||||
COMMAND
|
||||
c2str.exe include/tccdefs.h tccdefs_.h
|
||||
WORKING_DIRECTORY
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_library(tcc STATIC ${TCC_SOURCES})
|
||||
|
||||
add_custom_command(
|
||||
TARGET
|
||||
tcc PRE_BUILD
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E touch config.h
|
||||
WORKING_DIRECTORY
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_dependencies(tcc c2str.exe)
|
||||
|
||||
target_include_directories(tcc PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
12
patches/tinycc/tcc.h.patch
Normal file
12
patches/tinycc/tcc.h.patch
Normal file
@@ -0,0 +1,12 @@
|
||||
--- tcc.h
|
||||
+++ tcc.h
|
||||
@@ -23,7 +23,9 @@
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#define _DARWIN_C_SOURCE
|
||||
+#if __has_include("config.h")
|
||||
#include "config.h"
|
||||
+#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
26
patches/zlib/deflate.h.patch
Normal file
26
patches/zlib/deflate.h.patch
Normal file
@@ -0,0 +1,26 @@
|
||||
--- deflate.h
|
||||
+++ deflate.h
|
||||
@@ -326,23 +326,7 @@ extern const uint8_t ZLIB_INTERNAL _dist_code[];
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
|
||||
-#ifdef _MSC_VER
|
||||
-
|
||||
-/* MSC doesn't have __builtin_expect. Just ignore likely/unlikely and
|
||||
- hope the compiler optimizes for the best.
|
||||
-*/
|
||||
-#define likely(x) (x)
|
||||
-#define unlikely(x) (x)
|
||||
-
|
||||
-int __inline __builtin_ctzl(unsigned long mask)
|
||||
-{
|
||||
- unsigned long index ;
|
||||
-
|
||||
- return _BitScanForward(&index, mask) == 0 ? 32 : ((int)index) ;
|
||||
-}
|
||||
-#else
|
||||
#define likely(x) __builtin_expect((x),1)
|
||||
#define unlikely(x) __builtin_expect((x),0)
|
||||
-#endif
|
||||
|
||||
#endif /* DEFLATE_H */
|
||||
@@ -1,92 +0,0 @@
|
||||
param(
|
||||
[Alias("f")][switch]$Force = $false
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
if ($env:CI -eq "true") {
|
||||
& (Join-Path $PSScriptRoot "update-submodules.ps1")
|
||||
}
|
||||
|
||||
if ($env:RELEASE -eq "1") {
|
||||
$Force = $true
|
||||
}
|
||||
|
||||
$DidAnything = $false;
|
||||
|
||||
function Build-Dependency {
|
||||
param(
|
||||
$Script,
|
||||
[string[]]$Outputs
|
||||
)
|
||||
|
||||
$ScriptPath = Join-Path $PSScriptRoot "build-$Script.ps1"
|
||||
|
||||
if (!$Force) {
|
||||
foreach ($Output in $Outputs) {
|
||||
$OutputPath = Join-Path $BUN_DEPS_OUT_DIR $Output
|
||||
if (Test-Path $OutputPath) {
|
||||
Write-Host "$Script - already built"
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Remove-Item $Outputs -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Write-Host "$Script - Building"
|
||||
Push-Location $PSScriptRoot
|
||||
try {
|
||||
& $ScriptPath
|
||||
}
|
||||
catch {
|
||||
Write-Host "Failed to build $Script"
|
||||
throw $_
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
$Script:DidAnything = $true
|
||||
}
|
||||
|
||||
Build-Dependency `
|
||||
-Script "boringssl" `
|
||||
-Outputs @("crypto.lib", "ssl.lib", "decrepit.lib")
|
||||
Build-Dependency `
|
||||
-Script "cares" `
|
||||
-Outputs @("cares.lib")
|
||||
Build-Dependency `
|
||||
-Script "zlib" `
|
||||
-Outputs @("zlib.lib")
|
||||
Build-Dependency `
|
||||
-Script "libarchive" `
|
||||
-Outputs @("archive.lib")
|
||||
Build-Dependency `
|
||||
-Script "lolhtml" `
|
||||
-Outputs @("lolhtml.lib")
|
||||
Build-Dependency `
|
||||
-Script "mimalloc" `
|
||||
-Outputs @("mimalloc.lib")
|
||||
Build-Dependency `
|
||||
-Script "tinycc" `
|
||||
-Outputs @("tcc.lib")
|
||||
Build-Dependency `
|
||||
-Script "zstd" `
|
||||
-Outputs @("zstd.lib")
|
||||
Build-Dependency `
|
||||
-Script "libuv" `
|
||||
-Outputs @("libuv.lib")
|
||||
Build-Dependency `
|
||||
-Script "lshpack" `
|
||||
-Outputs @("lshpack.lib")
|
||||
|
||||
Build-Dependency `
|
||||
-Script "libdeflate" `
|
||||
-Outputs @("deflate.lib")
|
||||
|
||||
if (!($Script:DidAnything)) {
|
||||
Write-Host "(run with -Force to rebuild all)"
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
source "$(dirname -- "${BASH_SOURCE[0]}")/env.sh"
|
||||
|
||||
RELEASE="${RELEASE:-0}"
|
||||
CI="${CI:-}"
|
||||
BUILT_ANY=0
|
||||
SUBMODULES=
|
||||
CACHE_DIR=
|
||||
CACHE=0
|
||||
BUN_DEPS_CACHE_DIR="${BUN_DEPS_CACHE_DIR:-}"
|
||||
|
||||
if [[ "$CI" ]]; then
|
||||
$(dirname -- "${BASH_SOURCE[0]}")/update-submodules.sh
|
||||
fi
|
||||
|
||||
FORCE=
|
||||
|
||||
while getopts "f" opt; do
|
||||
case ${opt} in
|
||||
f)
|
||||
FORCE=1
|
||||
;;
|
||||
\?)
|
||||
echo "Usage: all-dependencies.sh [-h] [-f]"
|
||||
echo "Options:"
|
||||
echo " h Print this help message"
|
||||
echo " f Set force to 1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$RELEASE" == "1" ]; then
|
||||
FORCE=1
|
||||
elif [ -n "$BUN_DEPS_CACHE_DIR" ]; then
|
||||
CACHE_DIR="$BUN_DEPS_CACHE_DIR"
|
||||
CACHE=1
|
||||
SUBMODULES="$(git submodule status)"
|
||||
fi
|
||||
|
||||
dep() {
|
||||
local submodule="$1"
|
||||
local script="$2"
|
||||
if [ "$CACHE" == "1" ]; then
|
||||
local hash="$(echo "$SUBMODULES" | grep "$submodule" | awk '{print $1}')"
|
||||
local os="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
||||
local arch="$(uname -m)"
|
||||
CACHE_KEY="$submodule/$hash-$os-$arch-$CPU_TARGET"
|
||||
mkdir -p "$CACHE_DIR/$CACHE_KEY"
|
||||
fi
|
||||
if [ -z "$FORCE" ]; then
|
||||
HAS_ALL_DEPS=1
|
||||
shift
|
||||
for lib in "${@:2}"; do
|
||||
if [ ! -f "$BUN_DEPS_OUT_DIR/$lib" ]; then
|
||||
if [[ "$CACHE" == "1" && -f "$CACHE_DIR/$CACHE_KEY/$lib" && "$script" != "libarchive" ]]; then
|
||||
mkdir -p "$BUN_DEPS_OUT_DIR"
|
||||
cp "$CACHE_DIR/$CACHE_KEY/$lib" "$BUN_DEPS_OUT_DIR/$lib"
|
||||
printf "%s %s - already cached\n" "$script" "$lib"
|
||||
else
|
||||
HAS_ALL_DEPS=0
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ "$HAS_ALL_DEPS" == "1" ]; then
|
||||
printf "%s - already built\n" "$script"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
printf "building %s\n" "$script"
|
||||
|
||||
set +e
|
||||
bash "$SCRIPT_DIR/build-$script.sh"
|
||||
EXIT=$?
|
||||
set -e
|
||||
|
||||
if [ "$EXIT" -ne 0 ]; then
|
||||
printf "Failed to build %s\n" "$script"
|
||||
exit "$EXIT"
|
||||
fi
|
||||
|
||||
if [ "$CACHE" == "1" ]; then
|
||||
mkdir -p "$CACHE_DIR/$CACHE_KEY"
|
||||
for lib in "${@:2}"; do
|
||||
cp "$BUN_DEPS_OUT_DIR/$lib" "$CACHE_DIR/$CACHE_KEY/$lib"
|
||||
printf "%s %s - cached\n" "$script" "$lib"
|
||||
done
|
||||
fi
|
||||
|
||||
BUILT_ANY=1
|
||||
}
|
||||
|
||||
dep boringssl boringssl libcrypto.a libssl.a libdecrepit.a
|
||||
dep c-ares cares libcares.a
|
||||
dep zlib zlib libz.a # Zlib must come before libarchive.
|
||||
dep libarchive libarchive libarchive.a
|
||||
dep lol-html lolhtml liblolhtml.a
|
||||
dep mimalloc mimalloc-debug libmimalloc-debug.a libmimalloc-debug.o
|
||||
dep mimalloc mimalloc libmimalloc.a libmimalloc.o
|
||||
dep tinycc tinycc libtcc.a
|
||||
dep zstd zstd libzstd.a
|
||||
dep libdeflate libdeflate libdeflate.a
|
||||
dep ls-hpack lshpack liblshpack.a
|
||||
|
||||
if [ "$BUILT_ANY" -eq 0 ]; then
|
||||
printf "(run with -f to rebuild)\n"
|
||||
fi
|
||||
@@ -1,16 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
Push-Location (Join-Path $BUN_DEPS_DIR 'boringssl')
|
||||
try {
|
||||
Remove-Item -ErrorAction SilentlyContinue -Recurse -Force build
|
||||
Set-Location (mkdir -Force build)
|
||||
|
||||
Run cmake @CMAKE_FLAGS ..
|
||||
Run cmake --build . --target crypto --target ssl --target decrepit --clean-first --config Release
|
||||
|
||||
Copy-Item crypto/crypto.lib $BUN_DEPS_OUT_DIR
|
||||
Copy-Item ssl/ssl.lib $BUN_DEPS_OUT_DIR
|
||||
Copy-Item decrepit/decrepit.lib $BUN_DEPS_OUT_DIR
|
||||
Write-Host "-> crypto.lib, ssl.lib, decrepit.lib"
|
||||
} finally { Pop-Location }
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
cd $BUN_DEPS_DIR/boringssl
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
cmake "${CMAKE_FLAGS[@]}" -GNinja ..
|
||||
ninja libcrypto.a libssl.a libdecrepit.a
|
||||
|
||||
cp **/libcrypto.a $BUN_DEPS_OUT_DIR/libcrypto.a
|
||||
cp **/libssl.a $BUN_DEPS_OUT_DIR/libssl.a
|
||||
cp **/libdecrepit.a $BUN_DEPS_OUT_DIR/libdecrepit.a
|
||||
@@ -1,29 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
if ($env:CI -eq "true") {
|
||||
$env:FORCE_UPDATE_SUBMODULES = "1"
|
||||
& (Join-Path $PSScriptRoot "update-submodules.ps1")
|
||||
& (Join-Path $PSScriptRoot "build-libuv.ps1") -CloneOnly $True
|
||||
}
|
||||
|
||||
cd build
|
||||
cmake .. @CMAKE_FLAGS `
|
||||
-G Ninja `
|
||||
-DCMAKE_BUILD_TYPE=Release `
|
||||
-DNO_CODEGEN=0 `
|
||||
-DNO_CONFIGURE_DEPENDS=1 `
|
||||
-DBUN_CPP_ONLY=1
|
||||
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
|
||||
|
||||
.\compile-cpp-only.ps1 -v -j $env:CPUS
|
||||
if ($LASTEXITCODE -ne 0) { throw "C++ compilation failed" }
|
||||
|
||||
# HACK: For some reason, the buildkite agent is hanging when uploading bun-cpp-objects.a
|
||||
# Best guess is that there is an issue when uploading files larger than 500 MB
|
||||
#
|
||||
# For now, use FileSplitter to split the file into smaller chunks:
|
||||
# https://www.powershellgallery.com/packages/FileSplitter/1.3
|
||||
if ($env:BUILDKITE) {
|
||||
Split-File -Path (Resolve-Path "bun-cpp-objects.a") -PartSizeBytes "50MB" -Verbose
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
Push-Location (Join-Path $BUN_DEPS_DIR 'c-ares')
|
||||
try {
|
||||
Set-Location (mkdir -Force build)
|
||||
|
||||
Run cmake @CMAKE_FLAGS -DCARES_STATIC=ON -DCARES_SHARED=OFF ..
|
||||
Run cmake --build . --clean-first --config Release
|
||||
|
||||
Copy-Item lib\cares.lib $BUN_DEPS_OUT_DIR
|
||||
Write-Host "-> cares.lib"
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
|
||||
export FORCE_PIC=1
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
cd $BUN_DEPS_DIR/c-ares
|
||||
|
||||
rm -rf build CMakeCache.txt CMakeFiles
|
||||
mkdir -p build
|
||||
|
||||
cd build
|
||||
|
||||
cmake "${CMAKE_FLAGS[@]}" .. \
|
||||
-DCMAKE_INSTALL_LIBDIR=lib \
|
||||
-DCARES_STATIC=ON \
|
||||
-DCARES_STATIC_PIC=OFF \
|
||||
-DCARES_SHARED=OFF \
|
||||
-DCARES_BUILD_TOOLS=ON \
|
||||
-G "Ninja"
|
||||
|
||||
ninja
|
||||
|
||||
cp lib/libcares.a $BUN_DEPS_OUT_DIR/libcares.a
|
||||
@@ -1,17 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
Push-Location (Join-Path $BUN_DEPS_DIR 'libarchive')
|
||||
try {
|
||||
Remove-Item -Recurse -Force libarchive-build -ErrorAction SilentlyContinue
|
||||
Set-Location (mkdir -Force libarchive-build)
|
||||
|
||||
Run cmake @CMAKE_FLAGS -DBUILD_SHARED_LIBS=0 -DENABLE_BZIP2=0 -DENABLE_CAT=0 -DENABLE_EXPAT=0 -DENABLE_ICONV=0 -DENABLE_INSTALL=0 -DENABLE_LIBB2=0 -DENABLE_LibGCC=0 -DENABLE_LIBXML2=0 -DENABLE_LZ4=0 -DENABLE_LZMA=0 -DENABLE_LZO=0 -DENABLE_MBEDTLS=0 -DENABLE_NETTLE=0 -DENABLE_OPENSSL=0 -DENABLE_PCRE2POSIX=0 -DENABLE_PCREPOSIX=0 -DENABLE_TEST=0 -DENABLE_WERROR=0 -DENABLE_ZLIB=0 -DENABLE_ZSTD=0 -DHAVE_ZLIB_H=1 ..
|
||||
Run cmake --build . --clean-first --config Release --verbose --target archive_static
|
||||
|
||||
Copy-Item libarchive\archive.lib $BUN_DEPS_OUT_DIR\archive.lib
|
||||
Write-Host "-> archive.lib"
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
export FORCE_PIC=1
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
|
||||
cd $BUN_DEPS_DIR/libarchive
|
||||
# Libarchive has a "build" folder which we must not use
|
||||
rm -rf libarchive-build
|
||||
mkdir -p libarchive-build
|
||||
cd libarchive-build
|
||||
cmake $CMAKE_FLAGS \
|
||||
-DBUILD_SHARED_LIBS=0 \
|
||||
-DENABLE_BZIP2=0 \
|
||||
-DENABLE_CAT=0 \
|
||||
-DENABLE_EXPAT=0 \
|
||||
-DENABLE_ICONV=0 \
|
||||
-DENABLE_INSTALL=0 \
|
||||
-DENABLE_LIBB2=0 \
|
||||
-DENABLE_LibGCC=0 \
|
||||
-DENABLE_LIBXML2=0 \
|
||||
-DENABLE_LZ4=0 \
|
||||
-DENABLE_LZMA=0 \
|
||||
-DENABLE_LZO=0 \
|
||||
-DENABLE_MBEDTLS=0 \
|
||||
-DENABLE_NETTLE=0 \
|
||||
-DENABLE_OPENSSL=0 \
|
||||
-DENABLE_PCRE2POSIX=0 \
|
||||
-DENABLE_PCREPOSIX=0 \
|
||||
-DENABLE_TEST=0 \
|
||||
-DENABLE_WERROR=0 \
|
||||
-DENABLE_ZLIB=0 \
|
||||
-DENABLE_ZSTD=0 \
|
||||
-DHAVE_ZLIB_H=1 \
|
||||
-GNinja \
|
||||
-B . -S ..
|
||||
cmake --build . --target libarchive.a --config Release -- -j$CPUS
|
||||
|
||||
cp ./libarchive/libarchive.a $BUN_DEPS_OUT_DIR/libarchive.a
|
||||
@@ -1,16 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
Push-Location (Join-Path $BUN_DEPS_DIR 'libdeflate')
|
||||
try {
|
||||
Remove-Item CMakeCache.txt, CMakeFiles, build -Recurse -ErrorAction SilentlyContinue
|
||||
mkdir -Force build
|
||||
|
||||
Run cmake -S "." -B build @CMAKE_FLAGS -DLIBDEFLATE_BUILD_STATIC_LIB=ON -DLIBDEFLATE_BUILD_SHARED_LIB=OFF -DLIBDEFLATE_BUILD_GZIP=OFF
|
||||
Run cmake --build build --clean-first --config Release
|
||||
|
||||
# In https://github.com/ebiggers/libdeflate/releases/tag/v1.20, it's outputting libdeflate.a even on Windows
|
||||
Copy-Item build/deflatestatic.lib $BUN_DEPS_OUT_DIR/deflate.lib
|
||||
Write-Host "-> deflate.lib"
|
||||
} finally { Pop-Location }
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
cd $BUN_DEPS_DIR/libdeflate
|
||||
rm -rf build CMakeCache.txt CMakeFiles
|
||||
cmake "${CMAKE_FLAGS[@]}" -DLIBDEFLATE_BUILD_STATIC_LIB=ON -DLIBDEFLATE_BUILD_SHARED_LIB=OFF -DLIBDEFLATE_BUILD_GZIP=OFF -B build -S . -G Ninja
|
||||
ninja libdeflate.a -C build
|
||||
cp build/libdeflate.a $BUN_DEPS_OUT_DIR/libdeflate.a
|
||||
@@ -1,46 +0,0 @@
|
||||
param(
|
||||
[bool] $CloneOnly = $false
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
$CWD = Get-Location
|
||||
|
||||
$Source = (Join-Path $PSScriptRoot "../src/deps/libuv")
|
||||
$Commit = "da527d8d2a908b824def74382761566371439003"
|
||||
|
||||
if (!(Test-Path -PathType Container $Source)) {
|
||||
Write-Host "Cloning libuv: $Commit"
|
||||
New-Item -ItemType Directory -Force -Path $Source
|
||||
Push-Location $Source
|
||||
try {
|
||||
Run git init
|
||||
Run git remote add origin "https://github.com/libuv/libuv"
|
||||
Run git fetch --depth 1 origin $Commit
|
||||
Run git checkout FETCH_HEAD
|
||||
} finally { Pop-Location }
|
||||
} else {
|
||||
Push-Location $Source
|
||||
try {
|
||||
$CurrentCommit = git rev-parse HEAD
|
||||
if ($CurrentCommit -ne $Commit) {
|
||||
Write-Host "Updating libuv: $Commit"
|
||||
Run git fetch --depth 1 origin $Commit
|
||||
Run git checkout FETCH_HEAD
|
||||
}
|
||||
} finally { Pop-Location }
|
||||
}
|
||||
|
||||
if(!($CloneOnly)) {
|
||||
Push-Location $Source
|
||||
try {
|
||||
$null = mkdir build -ErrorAction SilentlyContinue
|
||||
Set-Location build
|
||||
|
||||
Run cmake .. @CMAKE_FLAGS "-DCMAKE_C_FLAGS=/DWIN32 /D_WINDOWS -Wno-int-conversion"
|
||||
Run cmake --build . --clean-first --config Release
|
||||
|
||||
Copy-Item libuv.lib $BUN_DEPS_OUT_DIR
|
||||
Write-Host "-> libuv.lib"
|
||||
} finally { Pop-Location }
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
Push-Location (Join-Path $BUN_DEPS_DIR 'lol-html/c-api')
|
||||
try {
|
||||
Run cargo build --release --target x86_64-pc-windows-msvc
|
||||
|
||||
Copy-Item target/x86_64-pc-windows-msvc/release/lolhtml.lib $BUN_DEPS_OUT_DIR
|
||||
Copy-Item target/x86_64-pc-windows-msvc/release/lolhtml.pdb $BUN_DEPS_OUT_DIR
|
||||
Write-Host "-> lolhtml.lib"
|
||||
} finally { Pop-Location }
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
cd $BUN_DEPS_DIR/lol-html/c-api
|
||||
cargo build --release
|
||||
cp target/release/liblolhtml.a $BUN_DEPS_OUT_DIR/liblolhtml.a
|
||||
@@ -1,18 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
Push-Location (Join-Path $BUN_DEPS_DIR 'ls-hpack')
|
||||
try {
|
||||
Set-Location (mkdir -Force build)
|
||||
|
||||
Run cmake .. @CMAKE_FLAGS `
|
||||
-DCMAKE_BUILD_TYPE=Release `
|
||||
-DLSHPACK_XXH=ON `
|
||||
-DSHARED=0
|
||||
|
||||
Run cmake --build . --clean-first --config Release
|
||||
|
||||
Copy-Item ls-hpack.lib $BUN_DEPS_OUT_DIR/lshpack.lib
|
||||
|
||||
Write-Host "-> lshpack.lib"
|
||||
} finally { Pop-Location }
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
rm -rf CMakeFiles CMakeCache build.ninja
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
|
||||
cd $BUN_DEPS_DIR/ls-hpack
|
||||
|
||||
rm -rf CMakeCache* CMakeFiles
|
||||
|
||||
cmake "${CMAKE_FLAGS[@]}" . \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DLSHPACK_XXH=ON \
|
||||
-DSHARED=0 \
|
||||
-GNinja
|
||||
|
||||
ninja libls-hpack.a
|
||||
|
||||
cp ./libls-hpack.a $BUN_DEPS_OUT_DIR/liblshpack.a
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source "$(dirname -- "${BASH_SOURCE[0]}")/env.sh"
|
||||
|
||||
MIMALLOC_OVERRIDE_FLAG=${MIMALLOC_OVERRIDE_FLAG:-}
|
||||
MIMALLOC_VALGRIND_ENABLED_FLAG=${MIMALLOC_VALGRIND_ENABLED_FLAG:-}
|
||||
|
||||
cd $BUN_DEPS_DIR/mimalloc
|
||||
|
||||
rm -rf CMakeCache* CMakeFiles build
|
||||
|
||||
mkdir build
|
||||
|
||||
cd build
|
||||
|
||||
cmake "${CMAKE_FLAGS[@]}" .. \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DMI_DEBUG_FULL=1 \
|
||||
-DMI_SKIP_COLLECT_ON_EXIT=1 \
|
||||
-DMI_BUILD_SHARED=OFF \
|
||||
-DMI_BUILD_STATIC=ON \
|
||||
-DMI_BUILD_TESTS=OFF \
|
||||
-DMI_OSX_ZONE=OFF \
|
||||
-DMI_OSX_INTERPOSE=OFF \
|
||||
-DMI_BUILD_OBJECT=ON \
|
||||
-DMI_OVERRIDE=OFF \
|
||||
-DMI_TRACK_VALGRIND=ON \
|
||||
-DMI_USE_CXX=ON \
|
||||
-GNinja
|
||||
|
||||
ninja
|
||||
|
||||
if [ -f libmimalloc-valgrind-debug.a ]; then
|
||||
file="libmimalloc-valgrind-debug.a"
|
||||
elif [ -f libmimalloc-debug.a ]; then
|
||||
file="libmimalloc-debug.a"
|
||||
else
|
||||
echo "Could not find libmimalloc-valgrind-debug.a or libmimalloc-debug.a"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp $file $BUN_DEPS_OUT_DIR/libmimalloc-debug.a
|
||||
cp CMakeFiles/mimalloc-obj.dir/src/static.c.o $BUN_DEPS_OUT_DIR/libmimalloc-debug.o
|
||||
@@ -1,26 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
Push-Location (Join-Path $BUN_DEPS_DIR 'mimalloc')
|
||||
try {
|
||||
Remove-Item -ErrorAction SilentlyContinue -Recurse -Force build
|
||||
Set-Location (mkdir -Force build)
|
||||
|
||||
Run cmake .. @CMAKE_FLAGS `
|
||||
-DMI_SKIP_COLLECT_ON_EXIT=1 `
|
||||
-DMI_BUILD_SHARED=OFF `
|
||||
-DMI_BUILD_STATIC=ON `
|
||||
-DMI_BUILD_TESTS=OFF `
|
||||
-DMI_OSX_ZONE=OFF `
|
||||
-DMI_OSX_INTERPOSE=OFF `
|
||||
-DMI_BUILD_OBJECT=ON `
|
||||
-DMI_USE_CXX=ON `
|
||||
-DMI_OVERRIDE=OFF `
|
||||
-DMI_OSX_ZONE=OFF
|
||||
|
||||
Run cmake --build . --clean-first --config Release
|
||||
|
||||
Copy-Item mimalloc-static.lib $BUN_DEPS_OUT_DIR/mimalloc.lib
|
||||
|
||||
Write-Host "-> mimalloc.lib"
|
||||
} finally { Pop-Location }
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source "$(dirname -- "${BASH_SOURCE[0]}")/env.sh"
|
||||
|
||||
MIMALLOC_OVERRIDE_FLAG=${MIMALLOC_OVERRIDE_FLAG:-}
|
||||
MIMALLOC_VALGRIND_ENABLED_FLAG=${MIMALLOC_VALGRIND_ENABLED_FLAG:-}
|
||||
|
||||
cd $BUN_DEPS_DIR/mimalloc
|
||||
|
||||
rm -rf CMakeCache* CMakeFiles
|
||||
|
||||
cmake "${CMAKE_FLAGS[@]}" . \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DMI_SKIP_COLLECT_ON_EXIT=1 \
|
||||
-DMI_BUILD_SHARED=OFF \
|
||||
-DMI_BUILD_STATIC=ON \
|
||||
-DMI_BUILD_TESTS=OFF \
|
||||
-DMI_OSX_ZONE=OFF \
|
||||
-DMI_OSX_INTERPOSE=OFF \
|
||||
-DMI_BUILD_OBJECT=ON \
|
||||
-DMI_USE_CXX=ON \
|
||||
-DMI_OVERRIDE=OFF \
|
||||
-DMI_OSX_ZONE=OFF \
|
||||
-GNinja
|
||||
|
||||
ninja
|
||||
|
||||
cp libmimalloc.a $BUN_DEPS_OUT_DIR/libmimalloc.a
|
||||
cp CMakeFiles/mimalloc-obj.dir/src/static.c.o $BUN_DEPS_OUT_DIR/libmimalloc.o
|
||||
@@ -1,29 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
Push-Location (Join-Path $BUN_DEPS_DIR 'tinycc')
|
||||
try {
|
||||
cd win32
|
||||
Run .\build-tcc.bat -clean
|
||||
cd ..
|
||||
|
||||
Set-Content -Path config.h -Value @"
|
||||
#define TCC_VERSION "$(Get-Content VERSION)"
|
||||
#define TCC_GITHASH "$(git rev-parse --short HEAD)"
|
||||
#define CONFIG_TCCDIR "$((Get-Location).Path.Replace('\', '/'))"
|
||||
#define CONFIG_TCC_PREDEFS 1
|
||||
#ifdef TCC_TARGET_X86_64
|
||||
#define CONFIG_TCC_CROSSPREFIX "$PX%-"
|
||||
#endif
|
||||
"@
|
||||
|
||||
Run clang-cl -DTCC_TARGET_PE -DTCC_TARGET_X86_64 config.h -DC2STR -o c2str.exe conftest.c
|
||||
Run .\c2str.exe .\include\tccdefs.h tccdefs_.h
|
||||
|
||||
Run clang-cl @($env:CFLAGS -split ' ') libtcc.c -o tcc.obj "-DTCC_TARGET_PE" "-DTCC_TARGET_X86_64" "-O2" "-W2" "-Zi" "-MD" "-GS-" "-c" "-MT"
|
||||
Run llvm-lib "tcc.obj" "-OUT:tcc.lib"
|
||||
|
||||
Copy-Item tcc.obj $BUN_DEPS_OUT_DIR/tcc.lib
|
||||
|
||||
Write-Host "-> tcc.lib"
|
||||
} finally { Pop-Location }
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
|
||||
cd $BUN_DEPS_DIR/tinycc
|
||||
make clean
|
||||
CFLAGS="${CFLAGS} -DTCC_LIBTCC1=\\\"\0\\\"" ./configure --enable-static --cc="$CC" --ar="$AR" --config-predefs=yes
|
||||
make libtcc.a -j$CPUS
|
||||
cp libtcc.a $BUN_DEPS_OUT_DIR
|
||||
@@ -1,29 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
Push-Location (Join-Path $BUN_DEPS_DIR 'zlib')
|
||||
try {
|
||||
Run git reset --hard
|
||||
|
||||
# TODO: make a patch upstream to change the line
|
||||
# `#ifdef _MSC_VER`
|
||||
# to account for clang-cl, which implements `__builtin_ctzl` and `__builtin_expect`
|
||||
$textToReplace = [regex]::Escape("int __inline __builtin_ctzl(unsigned long mask)") + "[^}]*}"
|
||||
$fileContent = Get-Content "deflate.h" -Raw
|
||||
if ($fileContent -match $textToReplace) {
|
||||
Set-Content -Path "deflate.h" -Value ($fileContent -replace $textToReplace, "")
|
||||
}
|
||||
else {
|
||||
throw "Failed to patch deflate.h"
|
||||
}
|
||||
|
||||
Set-Location (mkdir -Force build)
|
||||
|
||||
Run cmake .. @CMAKE_FLAGS
|
||||
Run cmake --build . --clean-first --config Release
|
||||
|
||||
Copy-Item zlib.lib $BUN_DEPS_OUT_DIR
|
||||
|
||||
Write-Host "-> zlib.lib"
|
||||
}
|
||||
finally { Pop-Location }
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
cd $BUN_DEPS_DIR/zlib
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake $CMAKE_FLAGS -G Ninja -DCMAKE_BUILD_TYPE=Release ..
|
||||
ninja
|
||||
cp ./libz.a $BUN_DEPS_OUT_DIR/libz.a
|
||||
@@ -1,14 +0,0 @@
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
Push-Location (Join-Path $BUN_DEPS_DIR 'zstd')
|
||||
try {
|
||||
Remove-Item CMakeCache.txt, CMakeFiles -Recurse -ErrorAction SilentlyContinue
|
||||
|
||||
# CL_SHOWINCLUDES_PREFIX is workaround for cmake bug in 3.28. .ninja_deps still needs to be deleted. Bug is fixed in 3.30
|
||||
Run cmake -S "build/cmake" @CMAKE_FLAGS -DZSTD_BUILD_STATIC=ON -DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file:"
|
||||
Run cmake --build . --clean-first --config Release
|
||||
|
||||
Copy-Item lib/zstd_static.lib $BUN_DEPS_OUT_DIR/zstd.lib
|
||||
Write-Host "-> zstd.lib"
|
||||
} finally { Pop-Location }
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
|
||||
cd $BUN_DEPS_DIR/zstd
|
||||
rm -rf Release CMakeCache.txt CMakeFiles
|
||||
cmake "${CMAKE_FLAGS[@]}" -DZSTD_BUILD_STATIC=ON -B Release -S build/cmake -G Ninja
|
||||
ninja libzstd_static -C Release
|
||||
cp Release/lib/libzstd.a $BUN_DEPS_OUT_DIR/libzstd.a
|
||||
236
scripts/build.mjs
Normal file
236
scripts/build.mjs
Normal file
@@ -0,0 +1,236 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawn as nodeSpawn } from "node:child_process";
|
||||
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
||||
import { join, relative, resolve } from "node:path";
|
||||
|
||||
// https://cmake.org/cmake/help/latest/manual/cmake.1.html#generate-a-project-buildsystem
|
||||
const generateFlags = [
|
||||
["-S", "string", "path to source directory"],
|
||||
["-B", "string", "path to build directory"],
|
||||
["-D", "string", "define a build option (e.g. -DCMAKE_BUILD_TYPE=Release)"],
|
||||
["-G", "string", "build generator (e.g. -GNinja)"],
|
||||
["-W", "string", "enable warnings (e.g. -Wno-dev)"],
|
||||
["--fresh", "boolean", "force a fresh build"],
|
||||
["--log-level", "string", "set the log level"],
|
||||
["--debug-output", "boolean", "print debug output"],
|
||||
["--toolchain", "string", "the toolchain to use"],
|
||||
];
|
||||
|
||||
// https://cmake.org/cmake/help/latest/manual/cmake.1.html#generate-a-project-buildsystem
|
||||
const buildFlags = [
|
||||
["--config", "string", "build configuration (e.g. --config Release)"],
|
||||
["--target", "string", "build target"],
|
||||
["-t", "string", "same as --target"],
|
||||
["--parallel", "number", "number of parallel jobs"],
|
||||
["-j", "number", "same as --parallel"],
|
||||
["--verbose", "boolean", "enable verbose output"],
|
||||
["-v", "boolean", "same as --verbose"],
|
||||
];
|
||||
|
||||
async function build(args) {
|
||||
if (process.platform === "win32" && !process.env["VSINSTALLDIR"]) {
|
||||
const shellPath = join(import.meta.dirname, "vs-shell.ps1");
|
||||
const scriptPath = import.meta.filename;
|
||||
return spawn("pwsh", ["-NoProfile", "-NoLogo", "-File", shellPath, process.argv0, scriptPath, ...args]);
|
||||
}
|
||||
|
||||
const env = {
|
||||
...process.env,
|
||||
FORCE_COLOR: "1",
|
||||
CLICOLOR_FORCE: "1",
|
||||
};
|
||||
|
||||
const generateOptions = parseOptions(args, generateFlags);
|
||||
const buildOptions = parseOptions(args, buildFlags);
|
||||
|
||||
const buildPath = resolve(generateOptions["-B"] || buildOptions["--build"] || "build");
|
||||
generateOptions["-B"] = buildPath;
|
||||
buildOptions["--build"] = buildPath;
|
||||
|
||||
if (!generateOptions["-S"]) {
|
||||
generateOptions["-S"] = process.cwd();
|
||||
}
|
||||
|
||||
const cacheRead = isCacheReadEnabled();
|
||||
const cacheWrite = isCacheWriteEnabled();
|
||||
if (cacheRead || cacheWrite) {
|
||||
const cachePath = getCachePath();
|
||||
if (cacheRead && !existsSync(cachePath)) {
|
||||
const mainCachePath = getCachePath(getDefaultBranch());
|
||||
if (existsSync(mainCachePath)) {
|
||||
mkdirSync(cachePath, { recursive: true });
|
||||
cpSync(mainCachePath, cachePath, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
generateOptions["-DCACHE_PATH"] = cmakePath(cachePath);
|
||||
generateOptions["--fresh"] = undefined;
|
||||
if (cacheRead && cacheWrite) {
|
||||
generateOptions["-DCACHE_STRATEGY"] = "read-write";
|
||||
} else if (cacheRead) {
|
||||
generateOptions["-DCACHE_STRATEGY"] = "read-only";
|
||||
} else if (cacheWrite) {
|
||||
generateOptions["-DCACHE_STRATEGY"] = "write-only";
|
||||
}
|
||||
}
|
||||
|
||||
const toolchain = generateOptions["--toolchain"];
|
||||
if (toolchain) {
|
||||
const toolchainPath = resolve(import.meta.dirname, "..", "cmake", "toolchains", `${toolchain}.cmake`);
|
||||
generateOptions["--toolchain"] = toolchainPath;
|
||||
}
|
||||
|
||||
const generateArgs = Object.entries(generateOptions).flatMap(([flag, value]) =>
|
||||
flag.startsWith("-D") ? [`${flag}=${value}`] : [flag, value],
|
||||
);
|
||||
await spawn("cmake", generateArgs, { env });
|
||||
|
||||
const envPath = resolve(buildPath, ".env");
|
||||
if (existsSync(envPath)) {
|
||||
const envFile = readFileSync(envPath, "utf8");
|
||||
for (const line of envFile.split(/\r\n|\n|\r/)) {
|
||||
const [key, value] = line.split("=");
|
||||
env[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
const buildArgs = Object.entries(buildOptions)
|
||||
.sort(([a], [b]) => (a === "--build" ? -1 : a.localeCompare(b)))
|
||||
.flatMap(([flag, value]) => [flag, value]);
|
||||
await spawn("cmake", buildArgs, { env });
|
||||
|
||||
const buildFiles = ["ccache.log", "compile_commands.json"];
|
||||
const buildPaths = [buildPath, ...readdirSync(buildPath).map(path => join(buildPath, path))];
|
||||
const buildArtifacts = [];
|
||||
for (const buildPath of buildPaths) {
|
||||
for (const buildFile of buildFiles) {
|
||||
const path = join(buildPath, buildFile);
|
||||
if (existsSync(path)) {
|
||||
buildArtifacts.push(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isBuildkite()) {
|
||||
await Promise.all(buildArtifacts.map(path => spawn("buildkite-agent", ["artifact", "upload", relative(buildPath, path)], { cwd: buildPath, env })));
|
||||
}
|
||||
}
|
||||
|
||||
function cmakePath(path) {
|
||||
return path.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
function getCachePath(branch) {
|
||||
const buildPath = process.env.BUILDKITE_BUILD_PATH;
|
||||
const repository = process.env.BUILDKITE_REPO;
|
||||
const fork = process.env.BUILDKITE_PULL_REQUEST_REPO;
|
||||
const repositoryKey = (fork || repository).replace(/[^a-z0-9]/gi, "-");
|
||||
const branchKey = (branch || process.env.BUILDKITE_BRANCH).replace(/[^a-z0-9]/gi, "-");
|
||||
const stepKey = process.env.BUILDKITE_STEP_KEY.replace(/[^a-z0-9]/gi, "-");
|
||||
return resolve(buildPath, "..", "cache", repositoryKey, branchKey, stepKey);
|
||||
}
|
||||
|
||||
function isCacheReadEnabled() {
|
||||
return (
|
||||
isBuildkite() &&
|
||||
process.env.BUILDKITE_CLEAN_CHECKOUT !== "true" &&
|
||||
process.env.BUILDKITE_BRANCH !== getDefaultBranch()
|
||||
);
|
||||
}
|
||||
|
||||
function isCacheWriteEnabled() {
|
||||
return isBuildkite();
|
||||
}
|
||||
|
||||
function isBuildkite() {
|
||||
return process.env.BUILDKITE === "true";
|
||||
}
|
||||
|
||||
function getDefaultBranch() {
|
||||
return process.env.BUILDKITE_PIPELINE_DEFAULT_BRANCH || "main";
|
||||
}
|
||||
|
||||
function parseOptions(args, flags = []) {
|
||||
const options = {};
|
||||
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
const arg = args[i];
|
||||
|
||||
for (const [flag, type] of flags) {
|
||||
if (arg === flag) {
|
||||
if (type === "boolean") {
|
||||
options[arg] = undefined;
|
||||
} else {
|
||||
options[arg] = args[++i];
|
||||
}
|
||||
} else if (arg.startsWith(flag)) {
|
||||
const delim = arg.indexOf("=");
|
||||
if (delim === -1) {
|
||||
options[flag] = arg.slice(flag.length);
|
||||
} else {
|
||||
options[arg.slice(0, delim)] = arg.slice(delim + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
async function spawn(command, args, options) {
|
||||
const effectiveArgs = args.filter(Boolean);
|
||||
const description = [command, ...effectiveArgs].map(arg => (arg.includes(" ") ? JSON.stringify(arg) : arg)).join(" ");
|
||||
console.log("$", description);
|
||||
|
||||
const subprocess = nodeSpawn(command, effectiveArgs, {
|
||||
stdio: "pipe",
|
||||
...options,
|
||||
});
|
||||
|
||||
let timestamp;
|
||||
subprocess.on("spawn", () => {
|
||||
timestamp = Date.now();
|
||||
});
|
||||
|
||||
const stdout = new Promise(resolve => {
|
||||
subprocess.stdout.on("end", resolve);
|
||||
subprocess.stdout.on("data", data => process.stdout.write(data));
|
||||
});
|
||||
|
||||
const stderr = new Promise(resolve => {
|
||||
subprocess.stderr.on("end", resolve);
|
||||
subprocess.stderr.on("data", data => process.stderr.write(data));
|
||||
});
|
||||
|
||||
const done = Promise.all([stdout, stderr]);
|
||||
|
||||
const { error, exitCode, signalCode } = await new Promise(resolve => {
|
||||
subprocess.on("error", error => resolve({ error }));
|
||||
subprocess.on("exit", (exitCode, signalCode) => resolve({ exitCode, signalCode }));
|
||||
});
|
||||
|
||||
await done;
|
||||
|
||||
const duration = Date.now() - timestamp;
|
||||
if (duration > 60000) {
|
||||
console.log(`Took ${(duration / 60000).toFixed(2)} minutes`);
|
||||
} else {
|
||||
console.log(`Took ${(duration / 1000).toFixed(2)} seconds`);
|
||||
}
|
||||
|
||||
if (exitCode === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
console.error(error);
|
||||
} else if (signalCode) {
|
||||
console.error(`Command killed: ${signalCode}`);
|
||||
} else {
|
||||
console.error(`Command exited: code ${exitCode}`);
|
||||
}
|
||||
|
||||
process.exit(exitCode ?? 1);
|
||||
}
|
||||
|
||||
build(process.argv.slice(2));
|
||||
@@ -1,2 +0,0 @@
|
||||
.\scripts\env.ps1
|
||||
ninja -Cbuild
|
||||
@@ -1,50 +0,0 @@
|
||||
param(
|
||||
[switch]$Baseline = $false
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
|
||||
$Target = If ($Baseline) { "windows-x64-baseline" } Else { "windows-x64" }
|
||||
$Tag = "bun-$Target"
|
||||
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
mkdir -Force build
|
||||
buildkite-agent artifact download "**" build --step "${Target}-build-zig"
|
||||
buildkite-agent artifact download "**" build --step "${Target}-build-cpp"
|
||||
buildkite-agent artifact download "**" build --step "${Target}-build-deps"
|
||||
mv -Force -ErrorAction SilentlyContinue build\build\bun-deps\* build\bun-deps
|
||||
mv -Force -ErrorAction SilentlyContinue build\build\* build
|
||||
|
||||
Set-Location build
|
||||
|
||||
# HACK: See scripts/build-bun-cpp.ps1
|
||||
Join-File -Path "$(Resolve-Path .)\bun-cpp-objects.a" -Verbose -DeletePartFiles
|
||||
|
||||
cmake .. @CMAKE_FLAGS `
|
||||
-G Ninja `
|
||||
-DCMAKE_BUILD_TYPE=Release `
|
||||
-DNO_CODEGEN=1 `
|
||||
-DNO_CONFIGURE_DEPENDS=1 `
|
||||
-DBUN_LINK_ONLY=1 `
|
||||
"-DBUN_DEPS_OUT_DIR=$(Resolve-Path bun-deps)" `
|
||||
"-DBUN_CPP_ARCHIVE=$(Resolve-Path bun-cpp-objects.a)" `
|
||||
"-DBUN_ZIG_OBJ_DIR=$(Resolve-Path .)"
|
||||
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
|
||||
|
||||
ninja -v -j $env:CPUS
|
||||
if ($LASTEXITCODE -ne 0) { throw "Link failed!" }
|
||||
|
||||
Set-Location ..
|
||||
$Dist = mkdir -Force "${Tag}"
|
||||
cp -r build\bun.exe "$Dist\bun.exe"
|
||||
Compress-Archive -Force "$Dist" "${Dist}.zip"
|
||||
$Dist = "$Dist-profile"
|
||||
MkDir -Force "$Dist"
|
||||
cp -r build\bun.exe "$Dist\bun.exe"
|
||||
cp -r build\bun.pdb "$Dist\bun.pdb"
|
||||
Compress-Archive -Force "$Dist" "$Dist.zip"
|
||||
|
||||
$env:BUN_GARBAGE_COLLECTOR_LEVEL = "1"
|
||||
$env:BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING = "1"
|
||||
.\build\bun.exe --print "JSON.stringify(require('bun:internal-for-testing').crash_handler.getFeatureData())" > .\features.json
|
||||
@@ -1,42 +0,0 @@
|
||||
import path from "path";
|
||||
|
||||
process.chdir(path.join(import.meta.dir, "../"));
|
||||
|
||||
const git_branch = await Bun.$`git rev-parse --abbrev-ref HEAD`.text();
|
||||
|
||||
if (git_branch.trim() !== "main") {
|
||||
console.error("You must be on the main branch to run this script");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const kinds = ["major", "minor", "patch"];
|
||||
const increment = kinds.findIndex(type => process.argv[2] === type);
|
||||
if (increment === -1) {
|
||||
console.error("Usage: bun bump <major|minor|patch>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const cmakelists = await Bun.file("./CMakeLists.txt").text();
|
||||
|
||||
const found_version_line = cmakelists.indexOf("set(Bun_VERSION");
|
||||
if (found_version_line === -1) {
|
||||
throw new Error("Could not find version line in CMakeLists.txt");
|
||||
}
|
||||
|
||||
const version = /set\(Bun_VERSION "([0-9]+\.[0-9]+\.[0-9]+)"/.exec(cmakelists);
|
||||
if (!version) {
|
||||
throw new Error("Could not find version in CMakeLists.txt");
|
||||
}
|
||||
|
||||
const to_arg = process.argv.find(arg => arg.startsWith("--last-version="));
|
||||
const to = to_arg ? to_arg.slice("--last-version=".length) : version[1];
|
||||
|
||||
const updated_version = to
|
||||
.split(".")
|
||||
.map((v, i) => (i === increment ? parseInt(v) + 1 : i < increment ? parseInt(v) : 0))
|
||||
.join(".");
|
||||
|
||||
await Bun.write("./CMakeLists.txt", cmakelists.replace(version[1], updated_version));
|
||||
await Bun.write("LATEST", to);
|
||||
|
||||
console.log("Bumping version from %s to %s", version[1], updated_version);
|
||||
@@ -1,35 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ -z "$GITHUB_TOKEN" ]; then
|
||||
echo "GITHUB_TOKEN is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
query="\"query{repository(owner:\\\"oven-sh\\\",name:\\\"bun\\\"){releases(first:1){edges{node{tagName}}}}}\""
|
||||
tagName=$(curl -fsSL "https://api.github.com/graphql" -X POST -d '{"query":'${query}'}' \
|
||||
-H "Authorization: bearer ${GITHUB_TOKEN}" -H "Content-Type: application/json" \
|
||||
| jq -r '.data.repository.releases.edges[0].node.tagName')
|
||||
|
||||
if [ -z "$headRef" ]; then
|
||||
headRef=$(git rev-parse HEAD)
|
||||
fi
|
||||
|
||||
query="\"query{repository(owner:\\\"oven-sh\\\",name:\\\"bun\\\"){ref(qualifiedName:\\\"${tagName}\\\"){compare(headRef:\\\"${headRef}\\\"){aheadBy}}}}\""
|
||||
aheadBy=$(curl -fsSL "https://api.github.com/graphql" -X POST -d '{"query":'${query}'}' \
|
||||
-H "Authorization: bearer ${GITHUB_TOKEN}" -H "Content-Type: application/json" \
|
||||
| jq -r '.data.repository.ref.compare.aheadBy')
|
||||
|
||||
if [ "$1" == '--raw' ]; then
|
||||
if [ "$aheadBy" == "null" ]; then
|
||||
echo "1"
|
||||
else
|
||||
echo "${aheadBy}"
|
||||
fi
|
||||
else
|
||||
echo "Latest version is ${tagName}"
|
||||
if [ "$aheadBy" == "null" ]; then
|
||||
echo "Current commit is not available on GitHub.com"
|
||||
else
|
||||
echo "Ahead by ${aheadBy} commits."
|
||||
fi
|
||||
echo "(call script with --raw to print just a number)"
|
||||
fi
|
||||
@@ -1,47 +0,0 @@
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
$ErrorActionPreference = 'SilentlyContinue' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
|
||||
function Reset-Submodule {
|
||||
param (
|
||||
$Repository
|
||||
)
|
||||
Push-Location $Repository
|
||||
try {
|
||||
Run git reset --hard
|
||||
Run git clean -fdx
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
|
||||
$Deps = Join-Path $PSScriptRoot "../src/deps"
|
||||
$DepsOut = Join-Path $PSScriptRoot "../src/deps"
|
||||
|
||||
Reset-Submodule $Deps\base64
|
||||
Reset-Submodule $Deps\boringssl
|
||||
Reset-Submodule $Deps\c-ares
|
||||
Reset-Submodule $Deps\libarchive
|
||||
Reset-Submodule $Deps\lol-html
|
||||
Reset-Submodule $Deps\mimalloc
|
||||
Reset-Submodule $Deps\picohttpparser
|
||||
Reset-Submodule $Deps\tinycc
|
||||
Reset-Submodule $Deps\zlib
|
||||
Reset-Submodule $Deps\zstd
|
||||
Reset-Submodule $Deps\ls-hpack
|
||||
|
||||
Remove-Item -Force $DepsOut\base64.lib
|
||||
Remove-Item -Force $DepsOut\crypto.lib
|
||||
Remove-Item -Force $DepsOut\ssl.lib
|
||||
Remove-Item -Force $DepsOut\decrepit.lib
|
||||
Remove-Item -Force $DepsOut\cares.lib
|
||||
Remove-Item -Force $DepsOut\archive.lib
|
||||
Remove-Item -Force $DepsOut\lolhtml.lib
|
||||
Remove-Item -Force $DepsOut\mimalloc.lib
|
||||
Remove-Item -Force $DepsOut\tcc.lib
|
||||
Remove-Item -Force $DepsOut\zlib.lib
|
||||
Remove-Item -Force $DepsOut\zstd.lib
|
||||
Remove-Item -Force $DepsOut\libuv.lib
|
||||
Remove-Item -Force $DepsOut\lshpack.lib
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
FORCE=
|
||||
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
BUN_BASE_DIR=${BUN_BASE_DIR:-$(cd $SCRIPT_DIR && cd .. && pwd)}
|
||||
BUN_DEPS_OUT_DIR=${BUN_DEPS_OUT_DIR:-$BUN_BASE_DIR/src/deps/}
|
||||
BUN_DEPS_DIR=${BUN_DEPS_DIR:-$BUN_BASE_DIR/src/deps/}
|
||||
|
||||
rm -f $BUN_DEPS_OUT_DIR/*.a
|
||||
|
||||
git_reset() {
|
||||
dir=$(pwd)
|
||||
cd $1
|
||||
git reset --hard
|
||||
git clean -fdx
|
||||
cd $dir
|
||||
}
|
||||
|
||||
git_reset $BUN_DEPS_DIR/boringssl
|
||||
git_reset $BUN_DEPS_DIR/c-ares
|
||||
git_reset $BUN_DEPS_DIR/libarchive
|
||||
git_reset $BUN_DEPS_DIR/lol-html
|
||||
git_reset $BUN_DEPS_DIR/mimalloc
|
||||
git_reset $BUN_DEPS_DIR/picohttpparser
|
||||
git_reset $BUN_DEPS_DIR/tinycc
|
||||
git_reset $BUN_DEPS_DIR/zlib
|
||||
git_reset $BUN_DEPS_DIR/zstd
|
||||
git_reset $BUN_DEPS_DIR/ls-hpack
|
||||
@@ -1,73 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
export TARGET_PLATFORM=${1:-win32}
|
||||
export TARGET_ARCH=${2:-x64}
|
||||
|
||||
if ! which bun; then
|
||||
export PATH="$PATH:$HOME/.bun/bin"
|
||||
fi
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../"
|
||||
|
||||
OUT=build-codegen-${TARGET_PLATFORM}-${TARGET_ARCH}
|
||||
|
||||
if [ -n "$3" ]; then
|
||||
OUT="$3"
|
||||
fi
|
||||
|
||||
rm -rf "$OUT/codegen"
|
||||
rm -rf "$OUT/js"
|
||||
mkdir -p "$OUT"
|
||||
mkdir -p "$OUT/"{codegen,js,tmp_functions,tmp_modules}
|
||||
|
||||
OUT=$(realpath "$OUT")
|
||||
|
||||
task() {
|
||||
echo '$ '"$@"
|
||||
"$@"
|
||||
if [ "$?" != "0" ]; then
|
||||
# some scripts are flaky, run them again
|
||||
echo "!!! retrying"
|
||||
"$@"
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "!!! failed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
task bun ./src/codegen/bundle-modules.ts --debug=OFF "$OUT"
|
||||
|
||||
rm -rf "$OUT/tmp_functions"
|
||||
rm -rf "$OUT/tmp_modules"
|
||||
|
||||
CLASSES=(
|
||||
./src/bun.js/*.classes.ts
|
||||
./src/bun.js/api/*.classes.ts
|
||||
./src/bun.js/test/*.classes.ts
|
||||
./src/bun.js/webcore/*.classes.ts
|
||||
./src/bun.js/node/*.classes.ts
|
||||
)
|
||||
task bun "./src/codegen/generate-classes.ts" ${CLASSES[@]} "$OUT/codegen"
|
||||
|
||||
LUTS=(
|
||||
./src/bun.js/bindings/BunObject.cpp
|
||||
./src/bun.js/bindings/ZigGlobalObject.lut.txt
|
||||
./src/bun.js/bindings/JSBuffer.cpp
|
||||
./src/bun.js/bindings/BunProcess.cpp
|
||||
./src/bun.js/bindings/ProcessBindingConstants.cpp
|
||||
./src/bun.js/bindings/ProcessBindingNatives.cpp
|
||||
)
|
||||
for lut in ${LUTS[@]}; do
|
||||
result=$(basename $lut | sed 's/.lut.txt/.cpp/' | sed 's/.cpp/.lut.h/')
|
||||
task bun "./src/codegen/create-hash-table.ts" "$lut" "$OUT/codegen/$result"
|
||||
done
|
||||
|
||||
task bun "./src/codegen/generate-jssink.ts" "$OUT/codegen"
|
||||
|
||||
wait
|
||||
|
||||
rm -rf "$OUT/tmp"*
|
||||
|
||||
echo "-> `basename "$OUT"`"
|
||||
@@ -1,42 +0,0 @@
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[string]$OutDir,
|
||||
[Parameter(Mandatory)][string]$Tag,
|
||||
[Parameter(Mandatory)][string]$PackageName
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$Url = "https://github.com/oven-sh/WebKit/releases/download/autobuild-$Tag/$PackageName.tar.gz"
|
||||
$CacheDir = (mkdir -Force (Join-Path $PSScriptRoot "../.cache"))
|
||||
$TarPath = Join-Path $CacheDir "$PackageName-$Tag.tar.gz"
|
||||
|
||||
if (Test-Path $OutDir\.tag) {
|
||||
$CurrentTag = Get-Content -Path (Join-Path $OutDir ".tag")
|
||||
if ($CurrentTag -eq $Tag) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Item $OutDir -ErrorAction SilentlyContinue -Recurse
|
||||
$null = mkdir -Force $OutDir
|
||||
try {
|
||||
Write-Host "-- Downloading WebKit"
|
||||
if (!(Test-Path $TarPath)) {
|
||||
try {
|
||||
Invoke-WebRequest $Url -OutFile $TarPath -MaximumRetryCount 3 -RetryIntervalSec 1
|
||||
} catch {
|
||||
Write-Error "Failed to fetch WebKit from: $Url"
|
||||
throw $_
|
||||
}
|
||||
}
|
||||
|
||||
Push-Location $CacheDir
|
||||
tar.exe "-xzf" "$PackageName-$Tag.tar.gz" -C (Resolve-Path -Relative $OutDir\..\).replace('\', '/')
|
||||
Pop-Location
|
||||
|
||||
Set-Content -Path (Join-Path $OutDir ".tag") -Value "$Tag"
|
||||
} catch {
|
||||
Remove-Item -Force -ErrorAction SilentlyContinue $OutDir
|
||||
throw $_
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
OUTDIR="$1"
|
||||
TAG="$2"
|
||||
PKG="$3"
|
||||
|
||||
if [ -z "$OUTDIR" ]; then
|
||||
echo "Missing outdir"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "Missing tag"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$PKG" ]; then
|
||||
echo "Missing package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
url="https://github.com/oven-sh/WebKit/releases/download/autobuild-$TAG/$PKG.tar.gz"
|
||||
|
||||
old_tar_dir="$(dirname "$0")/../.webkit-cache"
|
||||
tar_dir="$(dirname "$0")/../.cache"
|
||||
if [ -d "$old_tar_dir" ]; then
|
||||
# migration step from the old system
|
||||
mkdir "$tar_dir"
|
||||
mv "$old_tar_dir"/* "$tar_dir"
|
||||
rm -r "$old_tar_dir"
|
||||
fi
|
||||
|
||||
tar="$tar_dir/$PKG-$TAG.tar.gz"
|
||||
|
||||
mkdir -p "$OUTDIR"
|
||||
mkdir -p "$tar_dir"
|
||||
|
||||
if [ -f "$OUTDIR/.tag" ]; then
|
||||
read_tag="$(cat "$OUTDIR/.tag")"
|
||||
if [ "$read_tag" == "$TAG-$PKG" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf "$OUTDIR"
|
||||
|
||||
download () {
|
||||
local command="$1"
|
||||
local retries="$2"
|
||||
local options="$-"
|
||||
if [[ $options == *e* ]]; then
|
||||
set +e
|
||||
fi
|
||||
$command
|
||||
local exit_code=$?
|
||||
if [[ $options == *e* ]]; then
|
||||
set -e
|
||||
fi
|
||||
if [[ $exit_code -ne 0 && $retries -gt 0 ]]; then
|
||||
download "$command" $(($retries - 1))
|
||||
else
|
||||
return $exit_code
|
||||
fi
|
||||
}
|
||||
|
||||
# this is a big download so we will retry 5 times and ask curl to resume
|
||||
# download from where failure occurred if it fails and is rerun
|
||||
if [ ! -f "$tar" ]; then
|
||||
echo "-- Downloading WebKit"
|
||||
if ! download "curl -C - --http1.1 -o $tar.tmp -L $url" 5; then
|
||||
echo "Failed to download $url"
|
||||
exit 1
|
||||
else
|
||||
mv $tar.tmp $tar
|
||||
fi
|
||||
fi
|
||||
|
||||
tar -xzf "$tar" -C "$(dirname "$OUTDIR")" || (rm "$tar" && exit 1)
|
||||
|
||||
# We want to make sure we use the system-version of icucore on macOS
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
# delete the unicode folder from include
|
||||
rm -rf "$OUTDIR/include/unicode"
|
||||
fi
|
||||
|
||||
echo "$TAG-$PKG" >"$OUTDIR/.tag"
|
||||
@@ -1,42 +0,0 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$ZigVersion="0.13.0"
|
||||
$Target="windows"
|
||||
$Arch="x86_64"
|
||||
|
||||
$Url = "https://ziglang.org/builds/zig-${Target}-${Arch}-${ZigVersion}.zip"
|
||||
$CacheDir = (mkdir -Force (Join-Path $PSScriptRoot "../.cache"))
|
||||
$TarPath = Join-Path $CacheDir "zig-${ZigVersion}.zip"
|
||||
$OutDir = Join-Path $CacheDir "zig"
|
||||
|
||||
if (Test-Path $OutDir\.tag) {
|
||||
$CurrentTag = Get-Content -Path (Join-Path $OutDir ".tag")
|
||||
if ($CurrentTag -eq $ZigVersion) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Item $OutDir -ErrorAction SilentlyContinue -Recurse
|
||||
$null = mkdir -Force $OutDir
|
||||
Push-Location $CacheDir
|
||||
try {
|
||||
if (!(Test-Path $TarPath)) {
|
||||
try {
|
||||
Write-Host "-- Downloading Zig"
|
||||
Invoke-RestMethod $Url -OutFile $TarPath -MaximumRetryCount 3 -RetryIntervalSec 1
|
||||
} catch {
|
||||
Write-Error "Failed to fetch Zig from: $Url"
|
||||
throw $_
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Item "$OutDir" -Recurse
|
||||
Expand-Archive "$TarPath" "$OutDir\..\"
|
||||
Move-Item "zig-$Target-$Arch-$ZigVersion" "zig"
|
||||
Set-Content -Path (Join-Path $OutDir ".tag") -Value "$ZigVersion"
|
||||
} catch {
|
||||
Remove-Item -Force -ErrorAction SilentlyContinue $OutDir
|
||||
throw $_
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
cd $(dirname $(dirname "${BASH_SOURCE[0]}"))
|
||||
|
||||
zig_version=""
|
||||
if [ -n "$1" ]; then
|
||||
zig_version="$1"
|
||||
update_repo=true
|
||||
|
||||
if [ "$zig_version" == "master" ]; then
|
||||
zig_version=$(curl -fsSL https://ziglang.org/download/index.json | jq -r .master.version)
|
||||
fi
|
||||
else
|
||||
zig_version=$(grep 'recommended_zig_version = "' "build.zig" | cut -d'"' -f2)
|
||||
fi
|
||||
|
||||
case $(uname -ms) in
|
||||
'Darwin x86_64')
|
||||
target='macos'
|
||||
arch='x86_64'
|
||||
;;
|
||||
'Darwin arm64')
|
||||
target='macos'
|
||||
arch='aarch64'
|
||||
;;
|
||||
'Linux aarch64' | 'Linux arm64')
|
||||
target='linux'
|
||||
arch='aarch64'
|
||||
;;
|
||||
'Linux x86_64')
|
||||
target='linux'
|
||||
arch='x86_64'
|
||||
;;
|
||||
*)
|
||||
printf "error: cannot get platform name from '%s'\n" "${unamestr}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
url="https://ziglang.org/builds/zig-${target}-${arch}-${zig_version}.tar.xz"
|
||||
dest="$(pwd)/.cache/zig-${zig_version}.tar.xz"
|
||||
extract_at="$(pwd)/.cache/zig"
|
||||
|
||||
mkdir -p ".cache"
|
||||
|
||||
update_repo_if_needed() {
|
||||
if [ "$update_repo" == "true" ]; then
|
||||
files=(
|
||||
build.zig
|
||||
Dockerfile
|
||||
scripts/download-zig.ps1
|
||||
.github/workflows/*
|
||||
)
|
||||
|
||||
zig_version_previous=$(grep 'recommended_zig_version = "' "build.zig" | cut -d'"' -f2)
|
||||
|
||||
for file in ${files[@]}; do
|
||||
sed -i 's/'"${zig_version_previous}"'/'"${zig_version}"'/g' "$file"
|
||||
done
|
||||
|
||||
printf "Zig was updated to ${zig_version}. Please commit new files."
|
||||
fi
|
||||
# symlink extracted zig to extracted zig.exe
|
||||
# TODO: Workaround for https://github.com/ziglang/vscode-zig/issues/164
|
||||
ln -sf "${extract_at}/zig" "${extract_at}/zig.exe"
|
||||
chmod +x "${extract_at}/zig.exe"
|
||||
}
|
||||
|
||||
if [ -e "${extract_at}/.version" ]; then
|
||||
if [ "$(cat "${extract_at}/.version")" == "${url}" ]; then
|
||||
update_repo_if_needed
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [ -e "${dest}" ]; then
|
||||
printf -- "-- Downloading Zig v%s\n" "${zig_version}"
|
||||
curl -o "$dest" -L "$url"
|
||||
fi
|
||||
|
||||
rm -rf "${extract_at}"
|
||||
mkdir -p "${extract_at}"
|
||||
tar -xf "${dest}" -C "${extract_at}" --strip-components=1
|
||||
|
||||
echo "${url}" > "${extract_at}/.version"
|
||||
|
||||
update_repo_if_needed
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user