2018-11-02 03:47:21 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -x
|
|
|
|
set -e
|
|
|
|
|
2021-04-13 00:42:51 +08:00
|
|
|
brew update && brew install s3cmd
|
2018-11-02 03:47:21 +08:00
|
|
|
|
|
|
|
ZIGDIR="$(pwd)"
|
2019-12-10 14:32:45 +08:00
|
|
|
ARCH="x86_64"
|
2020-10-15 08:36:43 +08:00
|
|
|
CACHE_BASENAME="zig+llvm+lld+clang-$ARCH-macos-gnu-0.6.0+1c9ef63a"
|
2018-11-02 03:47:21 +08:00
|
|
|
PREFIX="$HOME/$CACHE_BASENAME"
|
|
|
|
JOBS="-j2"
|
|
|
|
|
|
|
|
rm -rf $PREFIX
|
|
|
|
cd $HOME
|
2020-10-13 09:38:28 +08:00
|
|
|
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
2020-07-24 14:26:34 +08:00
|
|
|
tar xf "$CACHE_BASENAME.tar.xz"
|
2018-11-02 03:47:21 +08:00
|
|
|
|
2020-10-14 17:25:51 +08:00
|
|
|
ZIG="$PREFIX/bin/zig"
|
2020-10-15 08:36:43 +08:00
|
|
|
NATIVE_LIBC_TXT="$HOME/native_libc.txt"
|
|
|
|
$ZIG libc > "$NATIVE_LIBC_TXT"
|
|
|
|
export ZIG_LIBC="$NATIVE_LIBC_TXT"
|
2020-10-14 17:25:51 +08:00
|
|
|
export CC="$ZIG cc"
|
|
|
|
export CXX="$ZIG c++"
|
|
|
|
|
2018-11-02 03:47:21 +08:00
|
|
|
cd $ZIGDIR
|
2019-10-25 16:26:22 +08:00
|
|
|
|
2019-10-25 15:25:10 +08:00
|
|
|
# Make the `zig version` number consistent.
|
|
|
|
# This will affect the cmake command below.
|
|
|
|
git config core.abbrev 9
|
2021-01-02 07:40:46 +08:00
|
|
|
git fetch --unshallow || true
|
|
|
|
git fetch --tags
|
2019-10-25 15:25:10 +08:00
|
|
|
|
2018-11-02 03:47:21 +08:00
|
|
|
mkdir build
|
|
|
|
cd build
|
2020-10-14 17:25:51 +08:00
|
|
|
cmake .. \
|
|
|
|
-DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
|
|
|
|
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
2020-10-15 08:36:43 +08:00
|
|
|
-DZIG_TARGET_TRIPLE="$ARCH-native-gnu" \
|
2021-04-15 15:18:21 +08:00
|
|
|
-DZIG_TARGET_MCPU="baseline" \
|
2020-10-15 08:36:43 +08:00
|
|
|
-DZIG_STATIC=ON
|
|
|
|
|
2020-10-15 08:59:29 +08:00
|
|
|
# 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.
|
2020-10-15 08:36:43 +08:00
|
|
|
unset CC
|
|
|
|
unset CXX
|
2020-10-15 08:59:29 +08:00
|
|
|
unset ZIG_LIBC
|
2020-10-14 17:25:51 +08:00
|
|
|
|
2018-11-02 03:47:21 +08:00
|
|
|
make $JOBS install
|
2020-10-29 07:31:59 +08:00
|
|
|
|
|
|
|
# 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.
|
2021-04-15 15:18:21 +08:00
|
|
|
cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig" -DZIG_TARGET_MCPU="x86_64_v2"
|
2020-10-29 07:31:59 +08:00
|
|
|
make $JOBS install
|
|
|
|
|
2019-09-22 11:55:56 +08:00
|
|
|
release/bin/zig build test
|
2018-11-02 03:47:21 +08:00
|
|
|
|
|
|
|
if [ "${BUILD_REASON}" != "PullRequest" ]; then
|
|
|
|
mv ../LICENSE release/
|
|
|
|
mv ../zig-cache/langref.html release/
|
|
|
|
mv release/bin/zig release/
|
|
|
|
rmdir release/bin
|
|
|
|
|
|
|
|
VERSION=$(release/zig version)
|
2019-12-10 14:32:45 +08:00
|
|
|
DIRNAME="zig-macos-$ARCH-$VERSION"
|
2018-11-02 03:47:21 +08:00
|
|
|
TARBALL="$DIRNAME.tar.xz"
|
|
|
|
mv release "$DIRNAME"
|
|
|
|
tar cfJ "$TARBALL" "$DIRNAME"
|
|
|
|
|
|
|
|
mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
|
2019-06-05 08:29:38 +08:00
|
|
|
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
2018-11-05 05:24:46 +08:00
|
|
|
|
2018-11-05 12:26:23 +08:00
|
|
|
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
2018-11-05 05:24:46 +08:00
|
|
|
BYTESIZE=$(wc -c < $TARBALL)
|
2019-03-21 11:19:18 +08:00
|
|
|
|
|
|
|
JSONFILE="macos-$GITBRANCH.json"
|
|
|
|
touch $JSONFILE
|
|
|
|
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
|
|
|
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
|
|
|
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
|
|
|
|
2019-04-04 04:04:24 +08:00
|
|
|
s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
|
2019-12-10 14:32:45 +08:00
|
|
|
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-macos-$VERSION.json"
|
2019-03-21 11:19:18 +08:00
|
|
|
|
2018-11-30 00:05:30 +08:00
|
|
|
# `set -x` causes these variables to be mangled.
|
|
|
|
# See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
|
|
|
|
set +x
|
2018-11-05 05:24:46 +08:00
|
|
|
echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
|
|
|
|
echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
|
|
|
|
echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
|
2018-11-02 03:47:21 +08:00
|
|
|
fi
|