101 lines
2.8 KiB
Bash
Executable File
101 lines
2.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -x
|
|
set -e
|
|
|
|
sudo pkg update -fq
|
|
sudo pkg install -y cmake py37-s3cmd wget curl jq samurai
|
|
|
|
ZIGDIR="$(pwd)"
|
|
CACHE_BASENAME="zig+llvm+lld+clang-x86_64-freebsd-gnu-0.8.0-dev.1939+5a3ea9bec"
|
|
PREFIX="$HOME/$CACHE_BASENAME"
|
|
|
|
cd $HOME
|
|
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
|
tar xf "$CACHE_BASENAME.tar.xz"
|
|
|
|
ZIG="$PREFIX/bin/zig"
|
|
NATIVE_LIBC_TXT="$HOME/native_libc.txt"
|
|
$ZIG libc > "$NATIVE_LIBC_TXT"
|
|
export ZIG_LIBC="$NATIVE_LIBC_TXT"
|
|
export CC="$ZIG cc"
|
|
export CXX="$ZIG c++"
|
|
|
|
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
|
|
|
|
# SourceHut reports that it is a terminal that supports escape codes, but it
|
|
# is a filthy liar. Here we tell Zig to not try to send any terminal escape
|
|
# codes to show progress.
|
|
export TERM=dumb
|
|
|
|
mkdir build
|
|
cd build
|
|
cmake .. \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_PREFIX_PATH=$PREFIX \
|
|
"-DCMAKE_INSTALL_PREFIX=$(pwd)/release" \
|
|
-DZIG_STATIC=ON \
|
|
-DZIG_TARGET_TRIPLE="x86_64-native-gnu" \
|
|
-DZIG_TARGET_MCPU="baseline" \
|
|
-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
|
|
unset ZIG_LIBC
|
|
|
|
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="$(pwd)/release/bin/zig" -DZIG_TARGET_MCPU="x86_64_v2"
|
|
samu install
|
|
|
|
# Here we skip some tests to save time.
|
|
release/bin/zig build test -Dskip-compile-errors -Dskip-non-native
|
|
|
|
if [ -f ~/.s3cfg ]; then
|
|
mv ../LICENSE release/
|
|
mv ../zig-cache/langref.html release/
|
|
mv release/bin/zig release/
|
|
rmdir release/bin
|
|
|
|
GITBRANCH=$(basename $GITHUB_REF)
|
|
VERSION=$(release/zig version)
|
|
DIRNAME="zig-freebsd-x86_64-$VERSION"
|
|
TARBALL="$DIRNAME.tar.xz"
|
|
mv release "$DIRNAME"
|
|
tar cfJ "$TARBALL" "$DIRNAME"
|
|
|
|
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
|
|
|
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
|
BYTESIZE=$(wc -c < $TARBALL)
|
|
|
|
JSONFILE="freebsd-$GITBRANCH.json"
|
|
touch $JSONFILE
|
|
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
|
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
|
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
|
|
|
s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
|
|
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-freebsd-$VERSION.json"
|
|
|
|
if [ "$GITBRANCH" = "master" ]; then
|
|
# avoid leaking oauth token
|
|
set +x
|
|
|
|
OAUTH_TOKEN="$(cat ~/.oauth_token)"
|
|
cd "$ZIGDIR"
|
|
./ci/srht/on_master_success "$VERSION" "$OAUTH_TOKEN"
|
|
fi
|
|
fi
|