diff --git a/ci/azure/pipelines.yml b/ci/azure/pipelines.yml index 1e281bb8e7..572c76416f 100644 --- a/ci/azure/pipelines.yml +++ b/ci/azure/pipelines.yml @@ -60,7 +60,7 @@ jobs: - task: DownloadSecureFile@1 inputs: secureFile: s3cfg - - script: ci/azure/windows_msvc_script.bat + - script: ci/azure/windows_script.bat name: main displayName: 'Build and test' - job: OnMasterSuccess diff --git a/ci/azure/windows_msvc_install b/ci/azure/windows_msvc_install deleted file mode 100644 index 7df1aa6461..0000000000 --- a/ci/azure/windows_msvc_install +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -set -x -set -e - -pacman -Suy --needed --noconfirm -pacman -S --needed --noconfirm wget p7zip python3-pip tar xz - -pip install s3cmd -wget -nv "https://ziglang.org/deps/llvm%2bclang%2blld-11.0.0-x86_64-windows-msvc-release-mt.tar.xz" -tar xf llvm+clang+lld-11.0.0-x86_64-windows-msvc-release-mt.tar.xz diff --git a/ci/azure/windows_msvc_script.bat b/ci/azure/windows_msvc_script.bat deleted file mode 100644 index 9d28eccd0b..0000000000 --- a/ci/azure/windows_msvc_script.bat +++ /dev/null @@ -1,47 +0,0 @@ -@echo on -SET "SRCROOT=%cd%" -SET "PREVPATH=%PATH%" -SET "PREVMSYSEM=%MSYSTEM%" - -set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" -SET "MSYSTEM=MINGW64" -bash -lc "cd ${SRCROOT} && ci/azure/windows_msvc_install" || exit /b -SET "PATH=%PREVPATH%" -SET "MSYSTEM=%PREVMSYSTEM%" - -SET "ZIGBUILDDIR=%SRCROOT%\build" -SET "ZIGINSTALLDIR=%ZIGBUILDDIR%\dist" -SET "ZIGPREFIXPATH=%SRCROOT%\llvm+clang+lld-11.0.0-x86_64-windows-msvc-release-mt" - -call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - -REM Make the `zig version` number consistent. -REM This will affect the cmake command below. -git.exe config core.abbrev 9 -git.exe fetch --unshallow -git.exe fetch --tags - -mkdir %ZIGBUILDDIR% -cd %ZIGBUILDDIR% -cmake.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 -msbuild /maxcpucount /p:Configuration=Release INSTALL.vcxproj || exit /b - -"%ZIGINSTALLDIR%\bin\zig.exe" build test-behavior -Dskip-non-native || exit /b -REM Disabled to prevent OOM -REM "%ZIGINSTALLDIR%\bin\zig.exe" build test-stage2 -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-fmt -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-std -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-compiler-rt -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-compare-output -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-standalone -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-stack-traces -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-cli -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-asm-link -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-runtime-safety -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-translate-c -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-run-translated-c -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build docs || exit /b - -set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" -SET "MSYSTEM=MINGW64" -bash -lc "cd ${SRCROOT} && ci/azure/windows_upload" || exit /b diff --git a/ci/azure/windows_script b/ci/azure/windows_script new file mode 100644 index 0000000000..f24d6aafb7 --- /dev/null +++ b/ci/azure/windows_script @@ -0,0 +1,105 @@ +#!/bin/sh + +set -x +set -e + +pacman -Suy --needed --noconfirm +pacman -S --needed --noconfirm cmake ninja wget p7zip python3-pip tar xz + +pip install s3cmd + +ZIGDIR="$(pwd)" +CACHE_BASENAME="zig+llvm+lld+clang-x86_64-windows-gnu-0.8.0-dev.1939+5a3ea9bec" +PREFIX="$HOME/$CACHE_BASENAME" +ZIG="$PREFIX/bin/zig" + +cd "$HOME" +wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz" +tar xf "$CACHE_BASENAME.tar.xz" + +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 + +export CC="$ZIG cc" +export CXX="$ZIG c++" + +mkdir build +cd build +cmake .. -DCMAKE_BUILD_TYPE=Release \ + "-DCMAKE_PREFIX_PATH=$PREFIX" \ + "-DCMAKE_INSTALL_PREFIX=$(pwd)/dist" \ + -DZIG_OMIT_STAGE2=ON \ + -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 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)/dist/bin/zig.exe" +ninja install + + +dist/bin/zig build test-behavior -Dskip-non-native +# Disabled to prevent OOM +# dist/bin/zig build test-stage2 +dist/bin/zig build test-fmt -Dskip-non-native +dist/bin/zig build test-std -Dskip-non-native +dist/bin/zig build test-compiler-rt -Dskip-non-native +dist/bin/zig build test-compare-output -Dskip-non-native +dist/bin/zig build test-standalone -Dskip-non-native +dist/bin/zig build test-stack-traces -Dskip-non-native +dist/bin/zig build test-cli -Dskip-non-native +dist/bin/zig build test-asm-link -Dskip-non-native +dist/bin/zig build test-runtime-safety -Dskip-non-native +dist/bin/zig build test-translate-c -Dskip-non-native +dist/bin/zig build test-run-translated-c -Dskip-non-native +dist/bin/zig build docs + +if [ "${BUILD_REASON}" != "PullRequest" ]; then + cd "$ZIGDIR/build" + + mv ../LICENSE dist/ + mv ../zig-cache/langref.html dist/ + mv dist/bin/zig.exe dist/ + rmdir dist/bin + + VERSION=$(dist/zig.exe version) + DIRNAME="zig-windows-x86_64-$VERSION" + TARBALL="$DIRNAME.zip" + mv dist "$DIRNAME" + 7z a "$TARBALL" "$DIRNAME" + + # mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg" + s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" 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="windows-$GITBRANCH.json" + touch $JSONFILE + echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE + echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE + echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE + + s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE" + s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-windows-$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" +fi diff --git a/ci/azure/windows_script.bat b/ci/azure/windows_script.bat new file mode 100644 index 0000000000..17116b835d --- /dev/null +++ b/ci/azure/windows_script.bat @@ -0,0 +1,8 @@ +@echo on +SET "SRCROOT=%cd%" +SET "PREVPATH=%PATH%" +SET "PREVMSYSEM=%MSYSTEM%" + +set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" +SET "MSYSTEM=MINGW64" +bash -lc "cd ${SRCROOT} && ci/azure/windows_script" || exit /b diff --git a/ci/azure/windows_upload b/ci/azure/windows_upload deleted file mode 100755 index 1f47359dd9..0000000000 --- a/ci/azure/windows_upload +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -set -x -set -e - -if [ "${BUILD_REASON}" != "PullRequest" ]; then - cd "$ZIGBUILDDIR" - - mv ../LICENSE dist/ - mv ../zig-cache/langref.html dist/ - mv dist/bin/zig.exe dist/ - rmdir dist/bin - - VERSION=$(dist/zig.exe version) - DIRNAME="zig-windows-x86_64-$VERSION" - TARBALL="$DIRNAME.zip" - mv dist "$DIRNAME" - 7z a "$TARBALL" "$DIRNAME" - - # mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg" - s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" 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="windows-$GITBRANCH.json" - touch $JSONFILE - echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE - echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE - echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE - - s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE" - s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-windows-$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" -fi