| ... | ... | @@ -3,24 +3,31 @@ |
| 3 | 3 | set -x |
| 4 | 4 | set -e |
| 5 | 5 | |
| 6 | | brew update && brew install s3cmd ninja gnu-tar |
| 6 | brew update && brew install s3cmd |
| 7 | 7 | |
| 8 | 8 | ZIGDIR="$(pwd)" |
| 9 | |
| 10 | HOST_ARCH="x86_64" |
| 11 | HOST_TARGET="$HOST_ARCH-macos-gnu" |
| 12 | HOST_MCPU="baseline" |
| 13 | HOST_CACHE_BASENAME="zig+llvm+lld+clang-$HOST_TARGET-0.8.0-dev.2168+2d1196773" |
| 14 | HOST_PREFIX="$HOME/$HOST_CACHE_BASENAME" |
| 15 | |
| 9 | 16 | ARCH="aarch64" |
| 10 | | # {product}-{os}{sdk_version}-{arch}-{llvm_version}-{cmake_build_type} |
| 11 | | CACHE_HOST_BASENAME="ci-llvm-macos10.15-x86_64-12.0.0.1-release" |
| 12 | | CACHE_ARM64_BASENAME="ci-llvm-macos11.0-arm64-12.0.0.1-release" |
| 13 | | PREFIX_HOST="$HOME/$CACHE_HOST_BASENAME" |
| 14 | | PREFIX_ARM64="$HOME/$CACHE_ARM64_BASENAME" |
| 17 | TARGET="$ARCH-macos-gnu" |
| 18 | MCPU="cyclone" |
| 19 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.8.0-dev.2168+2d1196773" |
| 20 | PREFIX="$HOME/$CACHE_BASENAME" |
| 21 | |
| 15 | 22 | JOBS="-j2" |
| 16 | 23 | |
| 17 | | rm -rf $PREFIX |
| 24 | rm -rf $HOST_PREFIX $PREFIX |
| 18 | 25 | cd $HOME |
| 19 | | wget -nv "https://ziglang.org/deps/$CACHE_HOST_BASENAME.tar.xz" |
| 20 | | wget -nv "https://ziglang.org/deps/$CACHE_ARM64_BASENAME.tar.xz" |
| 21 | 26 | |
| 22 | | gtar xf "$CACHE_HOST_BASENAME.tar.xz" |
| 23 | | gtar xf "$CACHE_ARM64_BASENAME.tar.xz" |
| 27 | wget -nv "https://ziglang.org/deps/$HOST_CACHE_BASENAME.tar.xz" |
| 28 | wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz" |
| 29 | tar xf "$HOST_CACHE_BASENAME.tar.xz" |
| 30 | tar xf "$CACHE_BASENAME.tar.xz" |
| 24 | 31 | |
| 25 | 32 | cd $ZIGDIR |
| 26 | 33 | |
| ... | ... | @@ -30,83 +37,75 @@ git config core.abbrev 9 |
| 30 | 37 | git fetch --unshallow || true |
| 31 | 38 | git fetch --tags |
| 32 | 39 | |
| 33 | | # Select xcode: latest version found on vmImage macOS-10.15 . |
| 34 | | DEVELOPER_DIR=/Applications/Xcode_12.4.app |
| 40 | # Build host zig compiler in debug so that we can get the |
| 41 | # current version when packaging |
| 35 | 42 | |
| 36 | | export ZIG_LOCAL_CACHE_DIR="$ZIGDIR/zig-cache" |
| 37 | | export ZIG_GLOBAL_CACHE_DIR="$ZIGDIR/zig-cache" |
| 43 | ZIG="$HOST_PREFIX/bin/zig" |
| 38 | 44 | |
| 39 | | # Build zig for host and use `Debug` type to make builds a little faster. |
| 45 | export CC="$ZIG cc -target $HOST_TARGET -mcpu=$HOST_MCPU" |
| 46 | export CXX="$ZIG c++ -target $HOST_TARGET -mcpu=$HOST_MCPU" |
| 40 | 47 | |
| 41 | | cd $ZIGDIR |
| 42 | 48 | mkdir build.host |
| 43 | 49 | cd build.host |
| 44 | | cmake -G "Ninja" .. \ |
| 50 | cmake .. \ |
| 45 | 51 | -DCMAKE_INSTALL_PREFIX="$(pwd)/release" \ |
| 46 | | -DCMAKE_PREFIX_PATH="$PREFIX_HOST" \ |
| 47 | | -DCMAKE_BUILD_TYPE="Debug" \ |
| 48 | | -DZIG_STATIC="OFF" |
| 49 | | |
| 50 | | # Build but do not install. |
| 51 | | ninja $JOBS |
| 52 | -DCMAKE_PREFIX_PATH="$HOST_PREFIX" \ |
| 53 | -DCMAKE_BUILD_TYPE=Debug \ |
| 54 | -DZIG_TARGET_TRIPLE="$HOST_TARGET" \ |
| 55 | -DZIG_TARGET_MCPU="$HOST_MCPU" \ |
| 56 | -DZIG_STATIC=ON |
| 52 | 57 | |
| 53 | | ZIG_EXE="$ZIGDIR/build.host/zig" |
| 58 | make $JOBS install |
| 54 | 59 | |
| 55 | | # Build zig for arm64 target. |
| 56 | | # - use `Release` type for published tarballs |
| 57 | | # - ad-hoc codesign with linker |
| 58 | | # - note: apple quarantine of downloads (eg. via safari) still apply |
| 60 | unset CC |
| 61 | unset CXX |
| 59 | 62 | |
| 63 | # Build zig compiler cross-compiled for arm64 |
| 60 | 64 | cd $ZIGDIR |
| 61 | | mkdir build.arm64 |
| 62 | | cd build.arm64 |
| 63 | | cmake -G "Ninja" .. \ |
| 65 | |
| 66 | ZIG="$ZIGDIR/build.host/release/bin/zig" |
| 67 | |
| 68 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" |
| 69 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" |
| 70 | |
| 71 | mkdir build |
| 72 | cd build |
| 73 | cmake .. \ |
| 64 | 74 | -DCMAKE_INSTALL_PREFIX="$(pwd)/release" \ |
| 65 | | -DCMAKE_PREFIX_PATH="$PREFIX_ARM64" \ |
| 66 | | -DCMAKE_BUILD_TYPE="Release" \ |
| 67 | | -DCMAKE_CROSSCOMPILING="True" \ |
| 68 | | -DCMAKE_SYSTEM_NAME="Darwin" \ |
| 69 | | -DCMAKE_C_FLAGS="-arch arm64" \ |
| 70 | | -DCMAKE_CXX_FLAGS="-arch arm64" \ |
| 71 | | -DCMAKE_EXE_LINKER_FLAGS="-lz -Xlinker -adhoc_codesign" \ |
| 72 | | -DZIG_USE_LLVM_CONFIG="OFF" \ |
| 73 | | -DZIG_EXECUTABLE="$ZIG_EXE" \ |
| 74 | | -DZIG_TARGET_TRIPLE="${ARCH}-macos" \ |
| 75 | | -DZIG_STATIC="OFF" |
| 76 | | |
| 77 | | ninja $JOBS install |
| 78 | | |
| 79 | | # Disable test because binary is foreign arch. |
| 80 | | #release/bin/zig build test |
| 75 | -DCMAKE_PREFIX_PATH="$PREFIX" \ |
| 76 | -DCMAKE_BUILD_TYPE=Release \ |
| 77 | -DZIG_TARGET_TRIPLE="$TARGET" \ |
| 78 | -DZIG_TARGET_MCPU="$MCPU" \ |
| 79 | -DZIG_EXECUTABLE="$ZIG" \ |
| 80 | -DZIG_STATIC=ON |
| 81 | |
| 82 | make $JOBS install |
| 83 | |
| 84 | unset CC |
| 85 | unset CXX |
| 81 | 86 | |
| 82 | 87 | if [ "${BUILD_REASON}" != "PullRequest" ]; then |
| 83 | 88 | mv ../LICENSE release/ |
| 84 | 89 | |
| 85 | 90 | # We do not run test suite but still need langref. |
| 86 | 91 | mkdir -p release/docs |
| 87 | | $ZIG_EXE run ../doc/docgen.zig -- $ZIG_EXE ../doc/langref.html.in release/docs/langref.html |
| 92 | $ZIG run ../doc/docgen.zig -- $ZIG ../doc/langref.html.in release/docs/langref.html |
| 88 | 93 | |
| 89 | 94 | # Produce the experimental std lib documentation. |
| 90 | 95 | mkdir -p release/docs/std |
| 91 | | $ZIG_EXE test ../lib/std/std.zig \ |
| 96 | $ZIG test ../lib/std/std.zig \ |
| 92 | 97 | --override-lib-dir ../lib \ |
| 93 | 98 | -femit-docs=release/docs/std \ |
| 94 | 99 | -fno-emit-bin |
| 95 | 100 | |
| 96 | | # Remove the unnecessary bin dir in $prefix/bin/zig |
| 97 | 101 | mv release/bin/zig release/ |
| 98 | 102 | rmdir release/bin |
| 99 | 103 | |
| 100 | | # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig |
| 101 | | mv release/lib/zig release/lib2 |
| 102 | | rmdir release/lib |
| 103 | | mv release/lib2 release/lib |
| 104 | | |
| 105 | | VERSION=$($ZIG_EXE version) |
| 104 | VERSION=$(../build.host/release/bin/zig version) |
| 106 | 105 | DIRNAME="zig-macos-$ARCH-$VERSION" |
| 107 | 106 | TARBALL="$DIRNAME.tar.xz" |
| 108 | | gtar cJf "$TARBALL" release/ --owner=root --sort=name --transform="s,^release,${DIRNAME}," |
| 109 | | ln "$TARBALL" "$BUILD_ARTIFACTSTAGINGDIRECTORY/." |
| 107 | mv release "$DIRNAME" |
| 108 | tar cfJ "$TARBALL" "$DIRNAME" |
| 110 | 109 | |
| 111 | 110 | mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg" |
| 112 | 111 | s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/ |
| ... | ... | @@ -114,12 +113,13 @@ if [ "${BUILD_REASON}" != "PullRequest" ]; then |
| 114 | 113 | SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1) |
| 115 | 114 | BYTESIZE=$(wc -c < $TARBALL) |
| 116 | 115 | |
| 117 | | JSONFILE="tarball.json" |
| 116 | JSONFILE="macos-$GITBRANCH.json" |
| 118 | 117 | touch $JSONFILE |
| 119 | 118 | echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE |
| 120 | 119 | echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE |
| 121 | 120 | echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE |
| 122 | 121 | |
| 122 | s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE" |
| 123 | 123 | s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-macos-$VERSION.json" |
| 124 | 124 | |
| 125 | 125 | # `set -x` causes these variables to be mangled. |