Skip to content

Commit 5610ac6

Browse files
rivymeltinglava
authored andcommitted
CI: fix and improve AppVeyor CI
* includes a fix/workaround for ongoing `gcc` library issues - see github:rust-lang/rust#47048 and github:rust-lang/rust#53454 - note: this fix is required for successful gcc/gnu compilation of `expr` on windows * improves clarity and logging of the AppVeyor config * "install" phase is more generic and more easily usable within other rust crates
1 parent 07df234 commit 5610ac6

File tree

1 file changed

+103
-55
lines changed

1 file changed

+103
-55
lines changed

.appveyor.yml

Lines changed: 103 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# spell-checker:words POSIX repo SDK SDKs toolchain toolchains
2+
# spell-checker:ignore uutils ARCH ABI BACKTRACE BINDIR cl COMNTOOLS dllcrt findstr maint MINGW MINGWDIR mkdir MSVC MSYS rustc rustlib rustup USERPROFILE vcvarsall
3+
14
version: "{build} ~ {branch}"
25

36
branches:
@@ -6,111 +9,156 @@ branches:
69

710
os: Visual Studio 2015
811

12+
artifacts:
13+
- path: target\%TARGET%\debug\uutils.exe
14+
name: uutils.exe
15+
916
matrix:
1017
allow_failures:
1118
- CHANNEL: nightly
19+
# - ABI: gnu
1220

1321
environment:
1422
global:
1523
FEATURES: "generic"
24+
BUILD_OPTIONS: "--no-default-features"
25+
TEST_OPTIONS: "--no-default-features --no-fail-fast"
26+
1627
matrix:
28+
# minimum version
1729
- CHANNEL: 1.27.0
1830
ARCH: i686
19-
TOOLCHAIN: msvc
31+
ABI: msvc
32+
# "msvc" ABI
2033
- CHANNEL: stable
2134
ARCH: i686
22-
TOOLCHAIN: msvc
35+
ABI: msvc
2336
- CHANNEL: stable
2437
ARCH: x86_64
25-
TOOLCHAIN: msvc
38+
ABI: msvc
2639
# - CHANNEL: beta
2740
# ARCH: i686
28-
# TOOLCHAIN: msvc
41+
# ABI: msvc
2942
# - CHANNEL: beta
3043
# ARCH: x86_64
31-
# TOOLCHAIN: msvc
44+
# ABI: msvc
3245
- CHANNEL: nightly
3346
ARCH: i686
34-
TOOLCHAIN: msvc
47+
ABI: msvc
48+
FEATURES: "generic nightly"
3549
- CHANNEL: nightly
3650
ARCH: x86_64
37-
TOOLCHAIN: msvc
51+
ABI: msvc
52+
FEATURES: "generic nightly"
53+
# "gnu" ABI
3854
- CHANNEL: stable
3955
ARCH: i686
40-
TOOLCHAIN: gnu
56+
ABI: gnu
4157
- CHANNEL: stable
4258
ARCH: x86_64
43-
TOOLCHAIN: gnu
59+
ABI: gnu
4460
# - CHANNEL: beta
4561
# ARCH: i686
46-
# TOOLCHAIN: gnu
62+
# ABI: gnu
4763
# - CHANNEL: beta
4864
# ARCH: x86_64
49-
# TOOLCHAIN: gnu
50-
- CHANNEL: nightly
51-
ARCH: i686
52-
TOOLCHAIN: gnu
53-
- CHANNEL: nightly
54-
ARCH: x86_64
55-
TOOLCHAIN: gnu
65+
# ABI: gnu
66+
# - CHANNEL: nightly
67+
# ARCH: i686
68+
# ABI: gnu
69+
# - CHANNEL: nightly
70+
# ARCH: x86_64
71+
# ABI: gnu
72+
# * specific gnu compilers
5673
- CHANNEL: stable
5774
ARCH: i686
58-
TOOLCHAIN: gnu
75+
ABI: gnu
5976
MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/dwarf/i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z/download
6077
MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z
61-
MINGW_DIR: mingw32
62-
DIR_TEMP_MINGW: C:\cached\mingw
78+
- CHANNEL: stable
79+
ARCH: x86_64
80+
ABI: gnu
81+
MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-posix/seh/x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z/download#mingw-w64-x86_64-7.3.0-posix-seh.7z
6382

6483
install:
6584
# force branch checkout (if knowable), then reset to the specific commit ## (can be needed for accurate code coverage info)
6685
# * this allows later apps to see the branch name using standard `git branch` operations, yet always builds the correct specific commit
6786
# * ref: <https://github.com/appveyor/ci/issues/1606>[`@`](https://archive.is/RVpnF)
68-
- if DEFINED APPVEYOR_REPO_BRANCH if /I "%APPVEYOR_REPO_SCM%"=="git" ( git checkout "%APPVEYOR_REPO_BRANCH%" & git reset --hard "%APPVEYOR_REPO_COMMIT%" )
87+
- if DEFINED APPVEYOR_REPO_BRANCH if /I "%APPVEYOR_REPO_SCM%"=="git" ( git checkout "%APPVEYOR_REPO_BRANCH%" 2>NUL & git reset --hard "%APPVEYOR_REPO_COMMIT%" )
6988
# ensure CWD is project main directory
7089
- cd "%APPVEYOR_BUILD_FOLDER%"
7190
# create a working area
7291
- ps: if ( ! $env:CI_TEMP_DIR ) { $env:CI_TEMP_DIR = "${env:TEMP}\${env:APPVEYOR_JOB_ID}" ; mkdir -force $env:CI_TEMP_DIR | out-null }
73-
- set "TARGET=%ARCH%-pc-windows-%TOOLCHAIN%"
74-
# install `rust` via `rustup`
75-
- call appveyor DownloadFile "https://win.rustup.rs/" -FileName "%CI_TEMP_DIR%\rustup-init.exe"
76-
- call "%CI_TEMP_DIR%\\rustup-init.exe" -y --default-toolchain %CHANNEL% --default-host %TARGET% --no-modify-path
92+
93+
# define the TARGET host
94+
- set "TARGET=%ARCH%-pc-windows-%ABI%"
95+
96+
# show relevant environment settings
97+
- ps: ('CHANNEL', 'ARCH', 'ABI', 'FEATURES', 'BUILD_OPTIONS', 'TEST_OPTIONS', 'TARGET') |% { write-host -f yellow "$_=$(get-content -ea silent env:/$_)" }
98+
99+
# rust installation
100+
# * install `rust` via `rustup`
101+
- appveyor DownloadFile "https://win.rustup.rs/" -FileName "%CI_TEMP_DIR%\rustup-init.exe"
102+
- call "%CI_TEMP_DIR%\rustup-init.exe" -y --default-toolchain %CHANNEL% --default-host %TARGET% --no-modify-path >NUL
77103
- set "PATH=%PATH%;%USERPROFILE%\.cargo\bin"
104+
- ps: $env:TOOLCHAIN = $("$(rustup show active-toolchain)" -split '\s+')[0]
105+
# * set RUST_BACKTRACE for enhanced error messages
106+
- set RUST_BACKTRACE=1
107+
# * show rust versions
78108
- rustc -vV
79109
- cargo -vV
80110

81-
# finalize FEATURES
82-
- if /I "%CHANNEL%"=="nightly" set "FEATURES=nightly %FEATURES%"
83-
84-
# "gnu" toolchain setup
85-
- if /I "%TOOLCHAIN%"=="gnu" set "PATH=%PATH%;C:\MinGW\bin"
86-
# * use the system MSYS if we can
87-
- if /I "%TOOLCHAIN%"=="gnu" if /I "%ARCH%"=="i686" set "MSYS_BITS=32"
88-
- if /I "%TOOLCHAIN%"=="gnu" if /I "%ARCH%"=="x86_64" set "MSYS_BITS=64"
89-
- if defined MSYS_BITS set PATH=C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin;%PATH%
111+
# "gnu" ABI setup
112+
# * use the system MinGW/MSYS if we can
113+
- if /i "%ABI%"=="gnu" set MSYS_BINDIR=C:\msys64\usr\bin
114+
- if /i "%ABI%"=="gnu" if /i "%ARCH%"=="i686" set "MSYS_BITS=32"
115+
- if /i "%ABI%"=="gnu" if /i "%ARCH%"=="x86_64" set "MSYS_BITS=64"
116+
- if defined MSYS_BITS set "MSYS_MINGWDIR=C:\msys64\mingw%MSYS_BITS%"
117+
- if defined MSYS_MINGWDIR set "MSYS_BINDIR=C:\msys64\usr\bin"
118+
## * workaround for rust-lang/rust#47048 / rust-lang/rust#53454 ## !maint: remove when resolved
119+
- if /i "%ABI%"=="gnu" if /i "%ARCH%"=="i686" if not DEFINED MINGW_URL set "MINGW_URL=https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/mingw-builds/8.1.0/threads-posix/dwarf/i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z"
120+
- if /i "%ABI%"=="gnu" if /i "%ARCH%"=="x86_64" if not DEFINED MINGW_URL set "MINGW_URL=https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z"
121+
## (end workaround)
90122
# * specific MinGW, if specified
91-
- ps: |
92-
if ((Test-Path Env:\MINGW_ARCHIVE) -and -not (Test-Path "${env:DIR_TEMP_MINGW}\${env:MINGW_ARCHIVE}")) {
93-
if (Test-Path "${env:DIR_TEMP_MINGW}") {
94-
rm -Recurse ${env:DIR_TEMP_MINGW}\*;
95-
}
96-
New-Item -ItemType Directory -Force -Path ${env:DIR_TEMP_MINGW} | Out-Null;
97-
$download_loc = ${env:MINGW_URL};
98-
appveyor DownloadFile $download_loc -FileName "${env:DIR_TEMP_MINGW}\${env:MINGW_ARCHIVE}";
99-
}
100-
- if defined MINGW_ARCHIVE 7z x -y "%DIR_TEMP_MINGW%\%MINGW_ARCHIVE%" > nul
101-
- if defined MINGW_ARCHIVE set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH%
102-
103-
# "msvc" toolchain setup
104-
- if "%TOOLCHAIN%" == "msvc" if "%ARCH%" == "i686" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat"
105-
- if "%TOOLCHAIN%" == "msvc" if "%ARCH%" == "x86_64" "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
106-
- if "%TOOLCHAIN%" == "msvc" if "%ARCH%" == "x86_64" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
123+
- ps: if ( ! $env:MINGW_ARCHIVE -and $env:MINGW_URL ) { $env:MINGW_ARCHIVE = $($([URI]$env:MINGW_URL).fragment).TrimStart('#') }
124+
- ps: if ( ! $env:MINGW_ARCHIVE -and $env:MINGW_URL ) { $env:MINGW_ARCHIVE = $([URI]$env:MINGW_URL).segments[-1] }
125+
- if defined MINGW_ARCHIVE curl --insecure -fsSL "%MINGW_URL%" -o "%CI_TEMP_DIR%\%MINGW_ARCHIVE%"
126+
- if defined MINGW_ARCHIVE mkdir "%CI_TEMP_DIR%\MinGW" >NUL
127+
- if defined MINGW_ARCHIVE 7z x -y "%CI_TEMP_DIR%\%MINGW_ARCHIVE%" -o"%CI_TEMP_DIR%\MinGW" >NUL
128+
- if defined MINGW_ARCHIVE set "MSYS_MINGWDIR=%CI_TEMP_DIR%\MinGW\mingw%MSYS_BITS%"
129+
- if defined MINGW_ARCHIVE set "MSYS_BINDIR=%MSYS_MINGWDIR%\bin"
130+
# * MinGW/MSYS PATH setup
131+
- if defined MSYS_MINGWDIR set PATH=%MSYS_MINGWDIR%\%ARCH%-w64-mingw32\bin;%MSYS_BINDIR%;%PATH%
132+
## * workaround for rust-lang/rust#47048 / rust-lang/rust#53454 ## !maint: remove when resolved
133+
# ** ref: <https://github.com/rust-lang/rust/issues/47048>, <https://github.com/rust-lang/rust/issues/53454>
134+
# ** egs: <https://github.com/pkgw/tectonic/commit/29686db533d8732d7d97fc94270ed33b77f29295>, <https://github.com/rukai/PF_Sandbox/blob/e842613cf9ff102dfb3fbd87381319e6e6dfe3ae/appveyor.yml>
135+
- if /i "%ABI%"=="gnu" rustup install %CHANNEL%-%ARCH%-pc-windows-msvc
136+
- if /i "%ABI%"=="gnu" rustup default %CHANNEL%-%ARCH%-pc-windows-msvc
137+
- if /i "%ABI%"=="gnu" rustup target add %TARGET%
138+
- ps: $env:TOOLCHAIN = $("$(rustup show active-toolchain)" -split '\s+')[0]
139+
- if /i "%ABI%"=="gnu" rustup show
140+
- if /i "%ABI%"=="gnu" rustc -vV
141+
# ** copy libs from gcc toolchain to rust toolchain (more specifically, "crt2.o" and "dllcrt2.o" are needed)
142+
- if defined MSYS_MINGWDIR copy /y "%MSYS_MINGWDIR%\%ARCH%-w64-mingw32\lib\*.o" "%USERPROFILE%\.rustup\toolchains\%TOOLCHAIN%\lib\rustlib\%TARGET%\lib" >NUL
143+
## (end workaround)
144+
# * show `gcc` info
145+
- if /i "%ABI%"=="gnu" ( where gcc && gcc --version )
107146

108-
artifacts:
109-
- path: target\debug\uutils.exe
110-
name: uutils.exe
147+
# "msvc" ABI setup
148+
- if /i "%ABI%" == "msvc" if /i "%ARCH%" == "i686" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat"
149+
- if /i "%ABI%" == "msvc" if /i "%ARCH%" == "x86_64" call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
150+
- if /i "%ABI%" == "msvc" if /i "%ARCH%" == "x86_64" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
151+
# * show `cl` info
152+
- if /i "%ABI%"=="msvc" ( where cl && cl 2>&1 | findstr /i /c:"version" )
153+
154+
# finalize options
155+
- ps: if ("$env:FEATURES".length) { $env:BUILD_OPTIONS = $(($env:BUILD_OPTIONS, "--features `"${env:FEATURES}`"")|?{$_}) -join ' ' }
156+
- ps: if ("$env:FEATURES".length) { $env:TEST_OPTIONS = $(($env:TEST_OPTIONS, "--features `"${env:FEATURES}`"")|?{$_}) -join ' ' }
111157

112158
build_script:
113-
- cargo build --features "%FEATURES%" --no-default-features
159+
- ps: $env:BUILD_CMD = $(("cargo +${env:TOOLCHAIN} build --target=${env:TARGET}", $env:BUILD_OPTIONS)|?{$_}) -join ' '
160+
- echo [ `%BUILD_CMD%` ] & %BUILD_CMD%
114161

115162
test_script:
116-
- cargo test --no-fail-fast --features "%FEATURES%" --no-default-features
163+
- ps: $env:TEST_CMD = $(("cargo +${env:TOOLCHAIN} test --target=${env:TARGET}", $env:TEST_OPTIONS)|?{$_}) -join ' '
164+
- echo [ `%TEST_CMD%` ] & %TEST_CMD%

0 commit comments

Comments
 (0)