authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-14 22:58:49-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-14 23:03:16-07:00
log45eb9554c4feec743924c0193d9ec50d9c94d0e4
tree126fdbadea3d0802ebe92b5e2a0eb23982a6e965
parent406353103a56dfbf7f7966191ceee5917cc582d9

ci: windows: try using zig-bootstrap to build zig


6 files changed, 114 insertions(+), 100 deletions(-)

ci/azure/pipelines.yml+1-1
...@@ -60,7 +60,7 @@ jobs:...@@ -60,7 +60,7 @@ jobs:
60 - task: DownloadSecureFile@160 - task: DownloadSecureFile@1
61 inputs:61 inputs:
62 secureFile: s3cfg62 secureFile: s3cfg
63 - script: ci/azure/windows_msvc_script.bat63 - script: ci/azure/windows_script.bat
64 name: main64 name: main
65 displayName: 'Build and test'65 displayName: 'Build and test'
66- job: OnMasterSuccess66- job: OnMasterSuccess
ci/azure/windows_msvc_install deleted-11
...@@ -1,11 +0,0 @@
1#!/bin/sh
2
3set -x
4set -e
5
6pacman -Suy --needed --noconfirm
7pacman -S --needed --noconfirm wget p7zip python3-pip tar xz
8
9pip install s3cmd
10wget -nv "https://ziglang.org/deps/llvm%2bclang%2blld-11.0.0-x86_64-windows-msvc-release-mt.tar.xz"
11tar xf llvm+clang+lld-11.0.0-x86_64-windows-msvc-release-mt.tar.xz
ci/azure/windows_msvc_script.bat deleted-47
...@@ -1,47 +0,0 @@
1@echo on
2SET "SRCROOT=%cd%"
3SET "PREVPATH=%PATH%"
4SET "PREVMSYSEM=%MSYSTEM%"
5
6set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
7SET "MSYSTEM=MINGW64"
8bash -lc "cd ${SRCROOT} && ci/azure/windows_msvc_install" || exit /b
9SET "PATH=%PREVPATH%"
10SET "MSYSTEM=%PREVMSYSTEM%"
11
12SET "ZIGBUILDDIR=%SRCROOT%\build"
13SET "ZIGINSTALLDIR=%ZIGBUILDDIR%\dist"
14SET "ZIGPREFIXPATH=%SRCROOT%\llvm+clang+lld-11.0.0-x86_64-windows-msvc-release-mt"
15
16call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
17
18REM Make the `zig version` number consistent.
19REM This will affect the cmake command below.
20git.exe config core.abbrev 9
21git.exe fetch --unshallow
22git.exe fetch --tags
23
24mkdir %ZIGBUILDDIR%
25cd %ZIGBUILDDIR%
26cmake.exe .. -Thost=x64 -G"Visual Studio 16 2019" -A x64 "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release -DZIG_OMIT_STAGE2=ON || exit /b
27msbuild /maxcpucount /p:Configuration=Release INSTALL.vcxproj || exit /b
28
29"%ZIGINSTALLDIR%\bin\zig.exe" build test-behavior -Dskip-non-native || exit /b
30REM Disabled to prevent OOM
31REM "%ZIGINSTALLDIR%\bin\zig.exe" build test-stage2 -Dskip-non-native || exit /b
32"%ZIGINSTALLDIR%\bin\zig.exe" build test-fmt -Dskip-non-native || exit /b
33"%ZIGINSTALLDIR%\bin\zig.exe" build test-std -Dskip-non-native || exit /b
34"%ZIGINSTALLDIR%\bin\zig.exe" build test-compiler-rt -Dskip-non-native || exit /b
35"%ZIGINSTALLDIR%\bin\zig.exe" build test-compare-output -Dskip-non-native || exit /b
36"%ZIGINSTALLDIR%\bin\zig.exe" build test-standalone -Dskip-non-native || exit /b
37"%ZIGINSTALLDIR%\bin\zig.exe" build test-stack-traces -Dskip-non-native || exit /b
38"%ZIGINSTALLDIR%\bin\zig.exe" build test-cli -Dskip-non-native || exit /b
39"%ZIGINSTALLDIR%\bin\zig.exe" build test-asm-link -Dskip-non-native || exit /b
40"%ZIGINSTALLDIR%\bin\zig.exe" build test-runtime-safety -Dskip-non-native || exit /b
41"%ZIGINSTALLDIR%\bin\zig.exe" build test-translate-c -Dskip-non-native || exit /b
42"%ZIGINSTALLDIR%\bin\zig.exe" build test-run-translated-c -Dskip-non-native || exit /b
43"%ZIGINSTALLDIR%\bin\zig.exe" build docs || exit /b
44
45set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
46SET "MSYSTEM=MINGW64"
47bash -lc "cd ${SRCROOT} && ci/azure/windows_upload" || exit /b
ci/azure/windows_script created+105
...@@ -0,0 +1,105 @@
1#!/bin/sh
2
3set -x
4set -e
5
6pacman -Suy --needed --noconfirm
7pacman -S --needed --noconfirm cmake ninja wget p7zip python3-pip tar xz
8
9pip install s3cmd
10
11ZIGDIR="$(pwd)"
12CACHE_BASENAME="zig+llvm+lld+clang-x86_64-windows-gnu-0.8.0-dev.1939+5a3ea9bec"
13PREFIX="$HOME/$CACHE_BASENAME"
14ZIG="$PREFIX/bin/zig"
15
16cd "$HOME"
17wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
18tar xf "$CACHE_BASENAME.tar.xz"
19
20cd "$ZIGDIR"
21
22# Make the `zig version` number consistent.
23# This will affect the cmake command below.
24git config core.abbrev 9
25git fetch --unshallow || true
26git fetch --tags
27
28export CC="$ZIG cc"
29export CXX="$ZIG c++"
30
31mkdir build
32cd build
33cmake .. -DCMAKE_BUILD_TYPE=Release \
34 "-DCMAKE_PREFIX_PATH=$PREFIX" \
35 "-DCMAKE_INSTALL_PREFIX=$(pwd)/dist" \
36 -DZIG_OMIT_STAGE2=ON \
37 -DZIG_STATIC=ON \
38 -GNinja
39
40# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
41# so that installation and testing do not get affected by them.
42unset CC
43unset CXX
44
45ninja install
46
47# Here we rebuild zig but this time using the Zig binary we just now produced to
48# build zig1.o rather than relying on the one built with stage0. See
49# https://github.com/ziglang/zig/issues/6830 for more details.
50cmake .. -DZIG_EXECUTABLE="$(pwd)/dist/bin/zig.exe"
51ninja install
52
53
54dist/bin/zig build test-behavior -Dskip-non-native
55# Disabled to prevent OOM
56# dist/bin/zig build test-stage2
57dist/bin/zig build test-fmt -Dskip-non-native
58dist/bin/zig build test-std -Dskip-non-native
59dist/bin/zig build test-compiler-rt -Dskip-non-native
60dist/bin/zig build test-compare-output -Dskip-non-native
61dist/bin/zig build test-standalone -Dskip-non-native
62dist/bin/zig build test-stack-traces -Dskip-non-native
63dist/bin/zig build test-cli -Dskip-non-native
64dist/bin/zig build test-asm-link -Dskip-non-native
65dist/bin/zig build test-runtime-safety -Dskip-non-native
66dist/bin/zig build test-translate-c -Dskip-non-native
67dist/bin/zig build test-run-translated-c -Dskip-non-native
68dist/bin/zig build docs
69
70if [ "${BUILD_REASON}" != "PullRequest" ]; then
71 cd "$ZIGDIR/build"
72
73 mv ../LICENSE dist/
74 mv ../zig-cache/langref.html dist/
75 mv dist/bin/zig.exe dist/
76 rmdir dist/bin
77
78 VERSION=$(dist/zig.exe version)
79 DIRNAME="zig-windows-x86_64-$VERSION"
80 TARBALL="$DIRNAME.zip"
81 mv dist "$DIRNAME"
82 7z a "$TARBALL" "$DIRNAME"
83
84 # mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
85 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
86
87 SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
88 BYTESIZE=$(wc -c < $TARBALL)
89
90 JSONFILE="windows-$GITBRANCH.json"
91 touch $JSONFILE
92 echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
93 echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
94 echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
95
96 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
97 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-windows-$VERSION.json"
98
99 # `set -x` causes these variables to be mangled.
100 # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
101 set +x
102 echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
103 echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
104 echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
105fi
ci/azure/windows_script.bat created+8
...@@ -0,0 +1,8 @@
1@echo on
2SET "SRCROOT=%cd%"
3SET "PREVPATH=%PATH%"
4SET "PREVMSYSEM=%MSYSTEM%"
5
6set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
7SET "MSYSTEM=MINGW64"
8bash -lc "cd ${SRCROOT} && ci/azure/windows_script" || exit /b
ci/azure/windows_upload deleted-41
...@@ -1,41 +0,0 @@
1#!/bin/sh
2
3set -x
4set -e
5
6if [ "${BUILD_REASON}" != "PullRequest" ]; then
7 cd "$ZIGBUILDDIR"
8
9 mv ../LICENSE dist/
10 mv ../zig-cache/langref.html dist/
11 mv dist/bin/zig.exe dist/
12 rmdir dist/bin
13
14 VERSION=$(dist/zig.exe version)
15 DIRNAME="zig-windows-x86_64-$VERSION"
16 TARBALL="$DIRNAME.zip"
17 mv dist "$DIRNAME"
18 7z a "$TARBALL" "$DIRNAME"
19
20 # mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
21 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
22
23 SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
24 BYTESIZE=$(wc -c < $TARBALL)
25
26 JSONFILE="windows-$GITBRANCH.json"
27 touch $JSONFILE
28 echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
29 echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
30 echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
31
32 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
33 s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-windows-$VERSION.json"
34
35 # `set -x` causes these variables to be mangled.
36 # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
37 set +x
38 echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
39 echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
40 echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
41fi