Skip to content

Commit 852dfd7

Browse files
committed
ci: extract installing msys2 into a script
1 parent e0b1b3b commit 852dfd7

File tree

3 files changed

+47
-52
lines changed

3 files changed

+47
-52
lines changed

src/ci/azure-pipelines/steps/install-windows-build-deps.yml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
11
steps:
2-
# Download and install MSYS2, needed primarily for the test suite (run-make) but
3-
# also used by the MinGW toolchain for assembling things.
4-
#
5-
# FIXME: we should probe the default azure image and see if we can use the MSYS2
6-
# toolchain there. (if there's even one there). For now though this gets the job
7-
# done.
8-
- bash: |
9-
set -e
10-
choco install msys2 --params="/InstallDir:$(System.Workfolder)/msys2 /NoPath" -y --no-progress
11-
echo "##vso[task.prependpath]$(System.Workfolder)/msys2/usr/bin"
12-
mkdir -p "$(System.Workfolder)/msys2/home/$USERNAME"
13-
displayName: Install msys2
14-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
15-
16-
- bash: pacman -S --noconfirm --needed base-devel ca-certificates make diffutils tar
17-
displayName: Install msys2 base deps
18-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
19-
202
# If we need to download a custom MinGW, do so here and set the path
213
# appropriately.
224
#
@@ -46,17 +28,6 @@ steps:
4628
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), ne(variables['MINGW_URL'],''))
4729
displayName: Download custom MinGW
4830

49-
# FIXME(#65767): workaround msys bug, step 1
50-
- bash: |
51-
set -e
52-
arch=i686
53-
if [ "$MSYS_BITS" = "64" ]; then
54-
arch=x86_64
55-
fi
56-
curl -O https://ci-mirrors.rust-lang.org/rustc/msys2-repo/mingw/$arch/mingw-w64-$arch-ca-certificates-20180409-1-any.pkg.tar.xz
57-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
58-
displayName: Download working ca-certificates for msys
59-
6031
# Otherwise install MinGW through `pacman`
6132
- bash: |
6233
set -e
@@ -69,29 +40,6 @@ steps:
6940
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['MINGW_URL'],''))
7041
displayName: Download standard MinGW
7142

72-
# FIXME(#65767): workaround msys bug, step 2
73-
- bash: |
74-
set -e
75-
arch=i686
76-
if [ "$MSYS_BITS" = "64" ]; then
77-
arch=x86_64
78-
fi
79-
pacman -U --noconfirm --noprogressbar mingw-w64-$arch-ca-certificates-20180409-1-any.pkg.tar.xz
80-
rm mingw-w64-$arch-ca-certificates-20180409-1-any.pkg.tar.xz
81-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
82-
displayName: Install working ca-certificates for msys
83-
84-
# Make sure we use the native python interpreter instead of some msys equivalent
85-
# one way or another. The msys interpreters seem to have weird path conversions
86-
# baked in which break LLVM's build system one way or another, so let's use the
87-
# native version which keeps everything as native as possible.
88-
- bash: |
89-
set -e
90-
cp C:/Python27amd64/python.exe C:/Python27amd64/python2.7.exe
91-
echo "##vso[task.prependpath]C:/Python27amd64"
92-
displayName: Prefer the "native" Python as LLVM has trouble building with MSYS sometimes
93-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
94-
9543
# Note that this is originally from the github releases patch of Ninja
9644
- bash: |
9745
set -e

src/ci/azure-pipelines/steps/run.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ steps:
9191
displayName: "Disable git automatic line ending conversion (on C:/)"
9292
condition: and(succeeded(), not(variables.SKIP_JOB))
9393

94+
- bash: src/ci/scripts/install-msys2.sh
95+
env:
96+
AGENT_OS: $(Agent.OS)
97+
SYSTEM_WORKFOLDER: $(System.Workfolder)
98+
displayName: Install msys2
99+
condition: and(succeeded(), not(variables.SKIP_JOB))
100+
94101
- template: install-windows-build-deps.yml
95102

96103
# Looks like docker containers have IPv6 disabled by default, so let's turn it

src/ci/scripts/install-msys2.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# Download and install MSYS2, needed primarily for the test suite (run-make) but
3+
# also used by the MinGW toolchain for assembling things.
4+
#
5+
# FIXME: we should probe the default azure image and see if we can use the MSYS2
6+
# toolchain there. (if there's even one there). For now though this gets the job
7+
# done.
8+
9+
set -euo pipefail
10+
IFS=$'\n\t'
11+
12+
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
13+
14+
if isWindows; then
15+
# FIXME(#65767): workaround msys bug, step 1
16+
arch=i686
17+
if [ "$MSYS_BITS" = "64" ]; then
18+
arch=x86_64
19+
fi
20+
curl -O "${MIRRORS_BASE}/msys2-repo/mingw/$arch/mingw-w64-$arch-ca-certificates-20180409-1-any.pkg.tar.xz"
21+
22+
choco install msys2 --params="/InstallDir:${SYSTEM_WORKFOLDER}/msys2 /NoPath" -y --no-progress
23+
mkdir -p "${SYSTEM_WORKFOLDER}/msys2/home/${USERNAME}"
24+
25+
ciCommandAddPath "${SYSTEM_WORKFOLDER}/msys2/usr/bin"
26+
export PATH="${SYSTEM_WORKFOLDER}/msys2/usr/bin"
27+
28+
pacman -S --noconfirm --needed base-devel ca-certificates make diffutils tar
29+
30+
# FIXME(#65767): workaround msys bug, step 2
31+
pacman -U --noconfirm --noprogressbar mingw-w64-$arch-ca-certificates-20180409-1-any.pkg.tar.xz
32+
rm mingw-w64-$arch-ca-certificates-20180409-1-any.pkg.tar.xz
33+
34+
# Make sure we use the native python interpreter instead of some msys equivalent
35+
# one way or another. The msys interpreters seem to have weird path conversions
36+
# baked in which break LLVM's build system one way or another, so let's use the
37+
# native version which keeps everything as native as possible.
38+
cp C:/Python27amd64/python.exe C:/Python27amd64/python2.7.exe
39+
ciCommandAddPath "C:\\Python27amd64"
40+
fi

0 commit comments

Comments
 (0)