diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-06-02 14:58:15 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-06-02 17:03:11 -0700 |
| commit | 05cd8936c885d2b538091eb814724472c73ec8b8 (patch) | |
| tree | 1e8c31188f041dc68309efd9993b1e401f4acde9 /ci/drone/linux_script_build | |
| parent | 16c5cbab0c414852bf8b911ed6efdf4ceeac9600 (diff) | |
| download | zig-05cd8936c885d2b538091eb814724472c73ec8b8.tar.gz zig-05cd8936c885d2b538091eb814724472c73ec8b8.zip | |
ci: drone: use zig-bootstrap tarball instead of system toolchain
Diffstat (limited to 'ci/drone/linux_script_build')
| -rwxr-xr-x | ci/drone/linux_script_build | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/ci/drone/linux_script_build b/ci/drone/linux_script_build index 3aedafbb89..179988f6e3 100755 --- a/ci/drone/linux_script_build +++ b/ci/drone/linux_script_build @@ -2,8 +2,30 @@ . ./ci/drone/linux_script_base -apk update -apk add samurai +PREFIX="/deps/local" +ZIG="$PREFIX/bin/zig" +TARGET="$TRIPLEARCH-linux-musl" +MCPU="baseline" + +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" + +# The `CMAKE_AR` parameter will consider any spaces to +# be part of the executable path rather than CLI args, so we have +# to create wrapper scripts for `zig ar` and zig ranlib`. + +cat <<'ENDFILE' >$PREFIX/bin/ar +#!/bin/sh +/deps/local/bin/zig ar $@ +ENDFILE + +cat <<'ENDFILE' >$PREFIX/bin/ranlib +#!/bin/sh +/deps/local/bin/zig ranlib $@ +ENDFILE + +chmod +x $PREFIX/bin/ar +chmod +x $PREFIX/bin/ranlib # Make the `zig version` number consistent. # This will affect the cmake command below. @@ -13,6 +35,25 @@ git fetch --tags mkdir build cd build -cmake .. -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$DISTDIR" -DZIG_STATIC=ON -DCMAKE_PREFIX_PATH=/deps/local -GNinja +cmake .. \ + -DCMAKE_INSTALL_PREFIX="$DISTDIR" \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_AR="$PREFIX/bin/ar" \ + -DCMAKE_RANLIB="$PREFIX/bin/ranlib" \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -GNinja + +# Now CMake will use Zig as the C/C++ compiler. We reset the environment variables +# so that installation and testing do not get affected by them. +unset CC +unset CXX +samu install +# Here we rebuild Zig but this time using the Zig binary we just now produced to +# build zig1.o rather than relying on the one built with stage0. See +# https://github.com/ziglang/zig/issues/6830 for more details. +cmake .. -DZIG_EXECUTABLE="$DISTDIR/bin/zig" samu install |
