Skip to content

Commit d3be887

Browse files
committed
CI: use zig build to produce release artifact
For both macOS and FreeBSD.
1 parent ed7965a commit d3be887

File tree

2 files changed

+41
-37
lines changed

2 files changed

+41
-37
lines changed

ci/azure/macos_script

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ git fetch --tags
3434
mkdir build
3535
cd build
3636
cmake .. \
37-
-DCMAKE_INSTALL_PREFIX="$(pwd)/stage2" \
3837
-DCMAKE_PREFIX_PATH="$PREFIX" \
3938
-DCMAKE_BUILD_TYPE=Release \
4039
-DZIG_TARGET_TRIPLE="$TARGET" \
4140
-DZIG_TARGET_MCPU="$MCPU" \
42-
-DZIG_STATIC=ON \
43-
-DZIG_OMIT_STAGE2=ON
41+
-DZIG_STATIC=ON
4442

4543
# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
4644
# so that installation and testing do not get affected by them.
@@ -49,35 +47,30 @@ unset CXX
4947

5048
make $JOBS install
5149

52-
# Here we rebuild zig but this time using the Zig binary we just now produced to
53-
# build zig1.o rather than relying on the one built with stage0. See
54-
# https://github.com/ziglang/zig/issues/6830 for more details.
55-
cmake .. -DZIG_EXECUTABLE="$(pwd)/stage2/bin/zig"
56-
make $JOBS install
57-
58-
stage2/bin/zig build -p release \
50+
stage2/bin/zig build \
51+
--prefix stage3-release \
5952
--search-prefix "$PREFIX" \
6053
-Dstatic-llvm \
6154
-Drelease \
6255
-Dstrip \
6356
-Dtarget="$TARGET" \
6457
-Denable-stage1
6558

66-
release/bin/zig build test docs \
59+
stage3-release/bin/zig build test docs \
6760
-Denable-macos-sdk \
6861
-Dstatic-llvm \
6962
--search-prefix "$PREFIX"
7063

7164
if [ "${BUILD_REASON}" != "PullRequest" ]; then
72-
mv ../LICENSE release/
73-
mv ../zig-cache/langref.html release/
74-
mv release/bin/zig release/
75-
rmdir release/bin
65+
mv ../LICENSE stage3-release/
66+
mv ../zig-cache/langref.html stage3-release/
67+
mv stage3-release/bin/zig stage3-release/
68+
rmdir stage3-release/bin
7669

77-
VERSION=$(release/zig version)
70+
VERSION=$(stage3-release/zig version)
7871
DIRNAME="zig-macos-$ARCH-$VERSION"
7972
TARBALL="$DIRNAME.tar.xz"
80-
mv release "$DIRNAME"
73+
mv stage3-release "$DIRNAME"
8174
tar cfJ "$TARBALL" "$DIRNAME"
8275

8376
mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"

ci/srht/freebsd_script

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ sudo pkg update -fq
77
sudo pkg install -y cmake py39-s3cmd wget curl jq samurai
88

99
ZIGDIR="$(pwd)"
10-
CACHE_BASENAME="zig+llvm+lld+clang-x86_64-freebsd-gnu-0.10.0-dev.3524+74673b7f6"
10+
TARGET="x86_64-freebsd-gnu"
11+
MCPU="baseline"
12+
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.3524+74673b7f6"
1113
PREFIX="$HOME/$CACHE_BASENAME"
1214

1315
cd $HOME
@@ -30,38 +32,47 @@ export TERM=dumb
3032
mkdir build
3133
cd build
3234
cmake .. \
33-
-DCMAKE_BUILD_TYPE=Release \
34-
-DCMAKE_PREFIX_PATH=$PREFIX \
35-
"-DCMAKE_INSTALL_PREFIX=$(pwd)/release" \
36-
-DZIG_STATIC=ON \
37-
-DZIG_TARGET_TRIPLE=x86_64-freebsd-gnu \
38-
-GNinja
35+
-DCMAKE_BUILD_TYPE=Release \
36+
-DCMAKE_PREFIX_PATH=$PREFIX \
37+
-DZIG_TARGET_TRIPLE="$TARGET" \
38+
-DZIG_TARGET_MCPU="$MCPU" \
39+
-DZIG_STATIC=ON \
40+
-GNinja
3941
samu install
4042

41-
# Here we rebuild zig but this time using the Zig binary we just now produced to
42-
# build zig1.o rather than relying on the one built with stage0. This makes it
43-
# a stage3 build rather than a stage2 build.
44-
cmake .. -DZIG_EXECUTABLE="$PREFIX/bin/zig"
45-
samu install
43+
# TODO: eliminate this workaround. Without this, zig does not end up passing
44+
# -isystem /usr/include when building libc++, resulting in #include <sys/endian.h>
45+
# "file not found" errors.
46+
stage2/bin/zig libc >libc.txt
47+
export ZIG_LIBC="$(pwd)/libc.txt"
4648

47-
# Here we skip some tests to save time.
48-
release/bin/zig build test docs \
49+
stage2/bin/zig build \
50+
--prefix stage3-release \
4951
--search-prefix "$PREFIX" \
5052
-Dstatic-llvm \
53+
-Drelease \
54+
-Dstrip \
55+
-Dtarget="$TARGET" \
56+
-Denable-stage1
57+
58+
# Here we skip some tests to save time.
59+
stage3-release/bin/zig build test docs \
60+
-Dstatic-llvm \
61+
--search-prefix "$PREFIX" \
5162
-Dskip-stage1 \
5263
-Dskip-non-native
5364

5465
if [ -f ~/.s3cfg ]; then
55-
mv ../LICENSE release/
56-
mv ../zig-cache/langref.html release/
57-
mv release/bin/zig release/
58-
rmdir release/bin
66+
mv ../LICENSE stage3-release/
67+
mv ../zig-cache/langref.html stage3-release/
68+
mv stage3-release/bin/zig stage3-release/
69+
rmdir stage3-release/bin
5970

6071
GITBRANCH=$(basename $GITHUB_REF)
61-
VERSION=$(release/zig version)
72+
VERSION=$(stage3-release/zig version)
6273
DIRNAME="zig-freebsd-x86_64-$VERSION"
6374
TARBALL="$DIRNAME.tar.xz"
64-
mv release "$DIRNAME"
75+
mv stage3-release "$DIRNAME"
6576
tar cfJ "$TARBALL" "$DIRNAME"
6677

6778
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/

0 commit comments

Comments
 (0)