Commit 37402e4d17

Andrew Kelley <andrew@ziglang.org>
2022-11-14 23:10:05
CI: separate aarch64 and x86_64 macos scripts
1 parent bbd0775
Changed files (3)
.github
workflows
ci
.github/workflows/ci.yaml
@@ -30,7 +30,7 @@ jobs:
         uses: actions/checkout@v3
       
       - name: Run Build Script
-        run: ./ci/macos/build.sh
+        run: ./ci/macos/build-x86_64.sh
   macos-aarch64:
     runs-on: [self-hosted, macOS, aarch64]
     env: 
@@ -40,7 +40,7 @@ jobs:
         uses: actions/checkout@v3
       
       - name: Run Build Script
-        run: ./ci/macos/build.sh
+        run: ./ci/macos/build-aarch64.sh
   # windows:
   #   runs-on: [self-hosted, Windows, x64]
   #   env: 
ci/macos/build-aarch64.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+set -x
+set -e
+
+echo "Running on Version:" $MACOS_VERSION
+
+# Script assumes the presence of the following:
+# s3cmd 
+
+ZIGDIR="$(pwd)"
+TARGET="$ARCH-macos-none"
+MCPU="baseline"
+CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0"
+PREFIX="$HOME/$CACHE_BASENAME"
+ZIG="$PREFIX/bin/zig"
+
+cd $ZIGDIR
+
+# Make the `zig version` number consistent.
+# This will affect the cmake command below.
+git config core.abbrev 9
+git fetch --unshallow || true
+git fetch --tags
+
+mkdir build
+cd build
+$HOME/local/bin/cmake .. \
+  -DCMAKE_INSTALL_PREFIX="stage3-release" \
+  -DCMAKE_PREFIX_PATH="$PREFIX" \
+  -DCMAKE_BUILD_TYPE=Release \
+  -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
+  -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
+  -DZIG_TARGET_TRIPLE="$TARGET" \
+  -DZIG_TARGET_MCPU="$MCPU" \
+  -DZIG_STATIC=ON \
+  -GNinja
+
+$HOME/local/bin/ninja install
+
+stage3-release/bin/zig build test docs \
+  --zig-lib-dir "$(pwd)/../lib" \
+  -Denable-macos-sdk \
+  -Dstatic-llvm \
+  -Dskip-non-native \
+  --search-prefix "$PREFIX"
+
+# Produce the experimental std lib documentation.
+mkdir -p "stage3-release/doc/std"
+stage3-release/bin/zig test "$(pwd)/../lib/std/std.zig" \
+  --zig-lib-dir "$(pwd)/../lib" \
+  -femit-docs="$(pwd)/stage3-release/doc/std" \
+  -fno-emit-bin
ci/macos/build.sh → ci/macos/build-x86_64.sh
@@ -18,12 +18,10 @@ JOBS="-j2"
 rm -rf $PREFIX
 cd $HOME
 
-curl -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
+curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
 tar xf "$CACHE_BASENAME.tar.xz"
 
 ZIG="$PREFIX/bin/zig"
-export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
-export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
 
 cd $ZIGDIR
 
@@ -35,19 +33,16 @@ git fetch --tags
 
 mkdir build
 cd build
-cmake .. \
+$HOME/local/bin/cmake .. \
   -DCMAKE_INSTALL_PREFIX="stage3-release" \
   -DCMAKE_PREFIX_PATH="$PREFIX" \
   -DCMAKE_BUILD_TYPE=Release \
+  -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
+  -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
   -DZIG_TARGET_TRIPLE="$TARGET" \
   -DZIG_TARGET_MCPU="$MCPU" \
   -DZIG_STATIC=ON
 
-# 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
-
 make $JOBS install
 
 stage3-release/bin/zig build test docs \
@@ -62,4 +57,4 @@ mkdir -p "stage3-release/doc/std"
 stage3-release/bin/zig test "$(pwd)/../lib/std/std.zig" \
   --zig-lib-dir "$(pwd)/../lib" \
   -femit-docs="$(pwd)/stage3-release/doc/std" \
-  -fno-emit-bin
\ No newline at end of file
+  -fno-emit-bin