2018-11-01 12:47:21 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -x
|
|
|
|
set -e
|
|
|
|
|
|
|
|
brew install s3cmd gcc@8
|
|
|
|
|
|
|
|
ZIGDIR="$(pwd)"
|
2019-09-19 14:04:27 -07:00
|
|
|
CACHE_BASENAME="llvm+clang-9.0.0-macos-x86_64-gcc8-release"
|
2018-11-01 12:47:21 -07:00
|
|
|
PREFIX="$HOME/$CACHE_BASENAME"
|
|
|
|
TMPDIR="$HOME/tmpz"
|
|
|
|
JOBS="-j2"
|
|
|
|
|
|
|
|
# I tried using the system default compiler (clang), but it couldn't statically link libc++.
|
|
|
|
# So we use gcc-8 from homebrew.
|
|
|
|
export CC=gcc-8
|
|
|
|
export CXX=g++-8
|
|
|
|
|
|
|
|
rm -rf $PREFIX
|
|
|
|
rm -rf $TMPDIR
|
|
|
|
mkdir $TMPDIR
|
|
|
|
|
|
|
|
cd $HOME
|
|
|
|
HAVE_CACHE="true"
|
2018-11-05 09:01:40 -08:00
|
|
|
wget -nv "https://ziglang.org/builds/$CACHE_BASENAME.tar.xz" || HAVE_CACHE="false"
|
2018-11-01 12:47:21 -07:00
|
|
|
if [ "${HAVE_CACHE}" = "true" ]; then
|
|
|
|
tar xf "$CACHE_BASENAME.tar.xz"
|
|
|
|
else
|
|
|
|
if [ "${BUILD_REASON}" == "PullRequest" ]; then
|
|
|
|
echo "Need cached llvm+clang for pull request builds."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $TMPDIR
|
|
|
|
wget https://zlib.net/zlib-1.2.11.tar.xz
|
|
|
|
tar xf zlib-1.2.11.tar.xz
|
|
|
|
cd zlib-1.2.11/
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_INSTALL_PREFIX=$PREFIX
|
|
|
|
make $JOBS install
|
|
|
|
rm $PREFIX/lib/libz*dylib
|
|
|
|
|
|
|
|
cd $TMPDIR
|
2019-09-19 14:04:27 -07:00
|
|
|
wget https://releases.llvm.org/9.0.0/llvm-9.0.0.src.tar.xz
|
|
|
|
tar xf llvm-9.0.0.src.tar.xz
|
|
|
|
cd llvm-9.0.0.src/
|
2018-11-01 12:47:21 -07:00
|
|
|
mkdir build
|
|
|
|
cd build
|
2019-09-19 15:32:40 -07:00
|
|
|
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_BUILD_TYPE=Release -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="AVR" -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_TERMINFO=OFF
|
2018-11-01 12:47:21 -07:00
|
|
|
make $JOBS install
|
|
|
|
|
|
|
|
cd $TMPDIR
|
2019-09-19 14:04:27 -07:00
|
|
|
wget https://releases.llvm.org/9.0.0/cfe-9.0.0.src.tar.xz
|
|
|
|
tar xf cfe-9.0.0.src.tar.xz
|
|
|
|
cd cfe-9.0.0.src/
|
2018-11-01 12:47:21 -07:00
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_BUILD_TYPE=Release
|
|
|
|
make $JOBS install
|
|
|
|
|
|
|
|
cd $HOME
|
|
|
|
tar cfJ "$CACHE_BASENAME.tar.xz" "$CACHE_BASENAME"
|
|
|
|
cp "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
|
2019-06-04 17:29:38 -07:00
|
|
|
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$CACHE_BASENAME.tar.xz" "s3://ziglang.org/builds/$CACHE_BASENAME.tar.xz"
|
2018-11-01 12:47:21 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd $ZIGDIR
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PREFIX -DCMAKE_INSTALL_PREFIX=$(pwd)/release -DZIG_STATIC=ON
|
|
|
|
make $JOBS install
|
2019-09-21 20:55:56 -07:00
|
|
|
release/bin/zig build test
|
2018-11-01 12:47:21 -07: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)
|
|
|
|
DIRNAME="zig-macos-x86_64-$VERSION"
|
|
|
|
TARBALL="$DIRNAME.tar.xz"
|
|
|
|
mv release "$DIRNAME"
|
|
|
|
tar cfJ "$TARBALL" "$DIRNAME"
|
|
|
|
|
|
|
|
mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
|
2019-06-04 17:29:38 -07:00
|
|
|
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
2018-11-04 13:24:46 -08:00
|
|
|
|
2018-11-04 20:26:23 -08:00
|
|
|
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
2018-11-04 13:24:46 -08:00
|
|
|
BYTESIZE=$(wc -c < $TARBALL)
|
2019-03-20 20:19:18 -07:00
|
|
|
|
|
|
|
JSONFILE="macos-$GITBRANCH.json"
|
|
|
|
touch $JSONFILE
|
|
|
|
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
|
|
|
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
|
|
|
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
|
|
|
|
2019-04-03 13:04:24 -07:00
|
|
|
s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
|
2019-03-20 20:19:18 -07:00
|
|
|
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/macos-$VERSION.json"
|
|
|
|
|
2018-11-29 08: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-04 13: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-01 12:47:21 -07:00
|
|
|
fi
|