blob: faca3527f09a9cb294d47d8507104386f0369c6f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
#!/bin/sh
set -x
set -e
# Probe CPU/brand details.
echo "lscpu:"
(lscpu | sed 's,^, : ,') 1>&2
pwd
(env | sort | sed 's,^, : ,') 1>&2
WORKSPACE="$DRONE_WORKSPACE"
LOCAL="/deps/local"
ZIG="$LOCAL/bin/zig"
ARCH="$(uname -m)"
TARGET="${ARCH}-linux-musl"
MCPU="baseline"
JOBS="-j$(nproc)"
export PATH=/deps/local/bin:$PATH
# Make the `zig version` number consistent.
# This will affect the cmake command below.
git config core.abbrev 9
# Build debug zig.
echo "BUILD debug zig with zig:$($ZIG version)"
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
mkdir _debug
cd _debug
cmake .. \
-DCMAKE_INSTALL_PREFIX="$(pwd)/staging" \
-DCMAKE_PREFIX_PATH="$LOCAL" \
-DCMAKE_BUILD_TYPE=Debug \
-DZIG_TARGET_TRIPLE="$TARGET" \
-DZIG_TARGET_MCPU="$MCPU" \
-DZIG_STATIC=ON \
-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
ninja $JOBS install
ZIG=$(pwd)/staging/bin/zig
# 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="$ZIG"
ninja $JOBS install
cd $WORKSPACE
# Build release zig.
echo "BUILD release zig with zig:$($ZIG version)"
echo "zig version: $($ZIG version)"
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
mkdir _release
cd _release
cmake .. \
-DCMAKE_INSTALL_PREFIX="$(pwd)/staging" \
-DCMAKE_PREFIX_PATH="$LOCAL" \
-DCMAKE_BUILD_TYPE=Release \
-DZIG_TARGET_TRIPLE="$TARGET" \
-DZIG_TARGET_MCPU="$MCPU" \
-DZIG_STATIC=ON \
-GNinja
unset CC
unset CXX
ninja $JOBS install
cd $WORKSPACE
# Look for non-conforming code formatting.
# Formatting errors can be fixed by running `zig fmt` on the files printed here.
$ZIG fmt --check .
$ZIG test test/behavior.zig -fno-stage1 -fLLVM -I test
$ZIG build test-behavior -Denable-qemu -Denable-wasmtime
$ZIG build test-compiler-rt -Denable-qemu -Denable-wasmtime
$ZIG build test-std -Denable-qemu -Denable-wasmtime
$ZIG build test-minilibc -Denable-qemu -Denable-wasmtime
$ZIG build test-compare-output -Denable-qemu -Denable-wasmtime
$ZIG build test-standalone -Denable-qemu -Denable-wasmtime
$ZIG build test-stack-traces -Denable-qemu -Denable-wasmtime
$ZIG build test-cli -Denable-qemu -Denable-wasmtime
$ZIG build test-asm-link -Denable-qemu -Denable-wasmtime
$ZIG build test-runtime-safety -Denable-qemu -Denable-wasmtime
$ZIG build test-translate-c -Denable-qemu -Denable-wasmtime
$ZIG build test-run-translated-c -Denable-qemu -Denable-wasmtime
$ZIG build docs -Denable-qemu -Denable-wasmtime
$ZIG build # test building self-hosted without LLVM
$ZIG build test-fmt -Denable-qemu -Denable-wasmtime
$ZIG build test-stage2 -Denable-qemu -Denable-wasmtime
# Look for HTML errors.
tidy --drop-empty-elements no -qe zig-cache/langref.html
# The remainder of this script is for master branch only.
if [ -n "$DRONE_PULL_REQUEST" ]; then
exit 0
fi
STAGING=_release/staging
# Produce the experimental std lib documentation.
mkdir -p $STAGING/docs/std
$ZIG test lib/std/std.zig \
--zig-lib-dir lib \
-femit-docs=$STAGING/docs/std \
-fno-emit-bin
cp LICENSE $STAGING/
cp zig-cache/langref.html $STAGING/docs/
# Remove the unnecessary bin dir in $prefix/bin/zig
mv $STAGING/bin/zig $STAGING/
rmdir $STAGING/bin
# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
mv $STAGING/lib/zig $STAGING/lib2
rmdir $STAGING/lib
mv $STAGING/lib2 $STAGING/lib
VERSION=$($STAGING/zig version)
BASENAME="zig-linux-$ARCH-$VERSION"
TARBALL="${BASENAME}.tar.xz"
mv "$STAGING" "$BASENAME"
tar cfJ "$TARBALL" "$BASENAME"
ls -l "$TARBALL"
# TODO: push artifact/meta somewhere
## mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
## s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
##
## SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
## BYTESIZE=$(wc -c < $TARBALL)
##
## JSONFILE="linux-$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/$ARCH-linux-$VERSION.json"
##
## # `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
## 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"
## echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"
|