diff --git a/ci/azure/pipelines.yml b/ci/azure/pipelines.yml index 572c76416f..1e281bb8e7 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_script.bat + - script: ci/azure/windows_msvc_script.bat name: main displayName: 'Build and test' - job: OnMasterSuccess diff --git a/ci/azure/windows_msvc_install b/ci/azure/windows_msvc_install new file mode 100644 index 0000000000..bdc4bd0bf1 --- /dev/null +++ b/ci/azure/windows_msvc_install @@ -0,0 +1,11 @@ +#!/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-12.0.0-x86_64-windows-msvc-release-mt.tar.xz" +tar xf llvm+clang+lld-12.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 new file mode 100644 index 0000000000..e45b53f4ad --- /dev/null +++ b/ci/azure/windows_msvc_script.bat @@ -0,0 +1,47 @@ +@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-12.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 deleted file mode 100644 index 5e342fff96..0000000000 --- a/ci/azure/windows_script +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/sh - -set -x -set -e - -pacman -Suy --needed --noconfirm -pacman -S --needed --noconfirm cmake git 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.1951+c59241bda" -PREFIX="$HOME/$CACHE_BASENAME" -ZIG="$PREFIX/bin/zig.exe" - -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 - -mkdir build -cd build -"$ZIG" build -Dstage1 -Domit-stage2 -Drelease \ - -Dtarget=x86_64-windows-gnu \ - -Dcpu=x86_64_v2 \ - --search-prefix "$PREFIX" \ - --override-lib-dir "$ZIGDIR/lib" \ - --prefix "$(pwd)/dist" - -dist/bin/zig.exe build test-behavior -Dskip-non-native -# Disabled to prevent OOM -# dist/bin/zig build test-stage2 -dist/bin/zig.exe build test-fmt -Dskip-non-native -dist/bin/zig.exe build test-std -Dskip-non-native -dist/bin/zig.exe build test-compiler-rt -Dskip-non-native -dist/bin/zig.exe build test-compare-output -Dskip-non-native -dist/bin/zig.exe build test-standalone -Dskip-non-native -dist/bin/zig.exe build test-stack-traces -Dskip-non-native -dist/bin/zig.exe build test-cli -Dskip-non-native -dist/bin/zig.exe build test-asm-link -Dskip-non-native -dist/bin/zig.exe build test-runtime-safety -Dskip-non-native -dist/bin/zig.exe build test-translate-c -Dskip-non-native -dist/bin/zig.exe build test-run-translated-c -Dskip-non-native -dist/bin/zig.exe 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 deleted file mode 100644 index 17116b835d..0000000000 --- a/ci/azure/windows_script.bat +++ /dev/null @@ -1,8 +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_script" || exit /b diff --git a/ci/azure/windows_upload b/ci/azure/windows_upload new file mode 100755 index 0000000000..1f47359dd9 --- /dev/null +++ b/ci/azure/windows_upload @@ -0,0 +1,41 @@ +#!/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