Skip to content

Commit e99ac3b

Browse files
committed
Improve Windows build setup
- Install a sensible `pkg-config` by default. Suitable for the Haskell toolchain. See the comments. - Remove the fixup of the config. With a suitable `pkg-config` they are not needed. - Remove the input for pacman packages. They can be installed afterwards by the user.
1 parent b1dbfc6 commit e99ac3b

File tree

3 files changed

+41
-96
lines changed

3 files changed

+41
-96
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ This action will install the system dependencies we have:
66

77
- libsodium
88
- libsecp256k1
9+
- pkg-config
10+
- openssl
911
- libblst
12+
- libsystemd (on Linux only)
1013

1114
See [iohk-nix/releases](https://github.com/input-output-hk/iohk-nix/releases/tag/latest)
1215

@@ -19,13 +22,12 @@ See [iohk-nix/releases](https://github.com/input-output-hk/iohk-nix/releases/tag
1922

2023
## haskell action
2124

22-
This action will install ghc and cabal as needed
25+
This action will set ghc and cabal as needed
2326

2427
```
2528
- name: Install Haskell
2629
uses: input-output-hk/actions/haskell@latest
2730
with:
2831
ghc-version: ${{ matrix.ghc }}
2932
cabal-version: 3.10.1.0
30-
pacman-packages: ... # more pacman package to install
31-
```
33+
```

base/action.yml

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: 'Setup IOG librararies'
2-
description: 'Installs libsodum, libsecp256k1 and libblst'
1+
name: 'Setup IOG libraries'
2+
description: 'Installs a set of libraries our projects usually depend on'
33
inputs:
44
use-sodium-vrf:
55
description: Use libsodium with VRF extension
@@ -28,24 +28,38 @@ runs:
2828
popd
2929
rm -fR __prep__
3030
31-
- name: "[darwin] update environemnt variables"
31+
- name: "[darwin] update environment variables"
3232
if: runner.os == 'macOS'
3333
shell: bash
3434
run: |
35-
echo 'PKG_CONFIG_PATH=/usr/local/opt/cardano/lib/pkgconfig:$PKG_CONFIG_PATH' >> $GITHUB_ENV
35+
echo "LD_LIBRARY_PATH=/usr/local/lib" >> $GITHUB_ENV
36+
echo "PKG_CONFIG_PATH=/usr/local/opt/cardano/lib/pkgconfig:/usr/local/opt/[email protected]/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
3637
38+
# There are three pkg-config packages available for mingw, and each one has their problems:
39+
#
40+
# - `pacman -S pkgconf` (usually pulled by installing `base-devel`): can't interpret the `PKG_CONFIG_PATH` in a semicolon format.
41+
# For `PKG_CONFIG_PATH=C:/pathA;C:/pathB` it searches in `C`, `/pathA;C` and `/pathB`.
42+
#
43+
# - `pacman -S mingw-w64-x86_64-pkgconf`: when queried for multiple modversions (as cabal does), it will return only one.
44+
#
45+
# - `pacman -S mingw-w64-x86_64-pkg-config`: will strip out `C:/mingw64/lib` and `C:/mingw64/include` from the returned values
46+
# unless provided with `PKG_CONFIG_ALLOW_SYSTEM_(CFLAGS|LIBS)` as I do here.
3747
- name: "[windows] Install library dependencies"
3848
if: runner.os == 'Windows'
3949
shell: C:/msys64/usr/bin/bash.exe -e '{0}'
4050
env:
41-
MSYSTEM: MSYS
51+
MSYSTEM: MINGW64
4252
# do not ever change to $HOME by yourself.
4353
CHERE_INVOKING: 1
4454
# do we want to inherit the path?
4555
# MSYS2_PATH_TYPE: inherit
4656
run: |
47-
/usr/bin/pacman --noconfirm -S \
48-
mingw-w64-x86_64-pkg-config
57+
mv /c/Strawberry/perl/bin/pkg-config /c/Strawberry/perl/bin/perl-pkg-config
58+
mv /c/Strawberry/perl/bin/pkg-config.bat /c/Strawberry/perl/bin/perl-pkg-config.bat
59+
60+
/usr/bin/pacman --noconfirm -S mingw-w64-x86_64-pkg-config mingw-w64-x86_64-openssl
61+
echo "PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1" >> $GITHUB_ENV
62+
echo "PKG_CONFIG_ALLOW_SYSTEM_LIBS=1" >> $GITHUB_ENV
4963
5064
mkdir __prep__
5165
pushd __prep__
@@ -58,20 +72,22 @@ runs:
5872
popd
5973
rm -fR __prep__
6074
61-
- name: "[windows] update environemnt variables"
75+
# MSYS will inherit the PATH from PWSH, but not the other way round, and setting the path
76+
# to "PATH=...:$PATH" in bash results in all the paths starting with `/c/` instead of `C:\` which
77+
# makes some actions (like `actions/checkout`) fail as it cannot find executables.
78+
- name: "[windows] update environment variables"
6279
if: runner.os == 'Windows'
6380
shell: pwsh
6481
run: |
65-
# Add the `bin` folder, which contains all the .dlls on windows, so we
66-
# can find them.
67-
"PATH=C:\\msys64\mingw64\opt\cardano\bin;C:\msys64\mingw64\bin;{0}" -f $env:PATH >> $env:GITHUB_ENV
68-
"PKG_CONFIG_PATH=C:\\msys64\mingw64\opt\cardano\lib\pkgconfig;{0}" -f $env:PKG_CONFIG_PATH >> $env:GITHUB_ENV
69-
82+
"PATH=C:\\msys64\\mingw64\\opt\\cardano\\bin;C:\\msys64\\mingw64\\bin;{0}" -f $env:PATH >> $env:GITHUB_ENV
83+
"PKG_CONFIG_PATH=C:\\msys64\\mingw64\\opt\\cardano\\lib\\pkgconfig;C:\\msys64\\mingw64\\lib\\pkgconfig;C:\\msys64\\mingw64\\share\\pkgconfig;C:\\msys64\\usr\\lib\\pkgconfig;C:\\msys64\\usr\\share\\pkgconfig;{0}" -f $env:PKG_CONFIG_PATH >> $env:GITHUB_ENV
7084
7185
- name: "[linux] Install library dependencies"
7286
if: runner.os == 'Linux'
7387
shell: bash
7488
run: |
89+
sudo apt-get -y install libsystemd-dev
90+
7591
mkdir __prep__
7692
pushd __prep__
7793
curl -sL ${{ inputs.url-prefix }}/debian.${{ inputs.use-sodium-vrf && 'libsodium-vrf' || 'libsodium' }}.deb > libsodium.deb
@@ -83,9 +99,9 @@ runs:
8399
popd
84100
rm -fR __prep__
85101
86-
- name: "[linux] update environemnt variables"
102+
- name: "[linux] update environment variables"
87103
if: runner.os == 'Linux'
88104
shell: bash
89105
run: |
90-
echo 'PKG_CONFIG_PATH=/usr/local/opt/cardano/lib/pkgconfig:$PKG_CONFIG_PATH' >> $GITHUB_ENV
91-
echo 'LD_LIBRARY_PATH=/usr/local/opt/cardano/lib:$LD_LIBRARY_PATH' >> $GITHUB_ENV
106+
echo "PKG_CONFIG_PATH=/usr/local/opt/cardano/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
107+
echo "LD_LIBRARY_PATH=/usr/local/opt/cardano/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV

haskell/action.yml

Lines changed: 4 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: 'Setup libsecp256k1'
2-
description: 'Installs libsecp256k1'
1+
name: 'Setup Haskell toolchain versions'
2+
description: 'Setup Haskell toolchain versions'
33
inputs:
44
ghc-version:
55
description: Version of GHC to install
@@ -9,10 +9,6 @@ inputs:
99
description: Version of cabal to install
1010
default: ''
1111

12-
pacman-packages:
13-
description: Pacman packages to install
14-
default: ''
15-
1612
outputs:
1713
cabal-store:
1814
description: "Prefix"
@@ -21,85 +17,16 @@ outputs:
2117
runs:
2218
using: "composite"
2319
steps:
24-
- name: "Install pkg-config"
25-
if: runner.os == 'macOS'
26-
shell: bash
27-
run: brew install pkg-config
28-
29-
- name: Setup PKG_CONFIG_PATH
30-
shell: bash
31-
run: |
32-
if [ ${{ runner.os }} == "macOS" ]; then
33-
# OpenSSL is installed in a non-standard location in MacOS. See
34-
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md
35-
echo "PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/opt/[email protected]/lib/pkgconfig" | tee -a "$GITHUB_ENV"
36-
elif [ ${{ runner.os }} == "Linux" ]; then
37-
echo "PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig" | tee -a "$GITHUB_ENV"
38-
fi
39-
40-
- name: Setup LD_LIBRARY_PATH
41-
shell: bash
42-
run: |
43-
if [ ${{ runner.os }} != "Windows" ]; then
44-
# OpenSSL is installed in a non-standard location in MacOS. See
45-
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md
46-
echo "LD_LIBRARY_PATH=/usr/local/lib" | tee -a "$GITHUB_ENV"
47-
fi
48-
49-
# For some unknown reason, the pacman setup must come before ghc installation.
50-
# It appears as if PATHEXT is set _after_ ghcup install ghc/cabal, and
51-
# as such we'd need pacman.exe instead.
52-
- name: "WIN: Install System Dependencies via pacman (msys2)"
53-
if: runner.os == 'Windows' && inputs.pacman-packages != ''
54-
shell: pwsh
55-
run: |
56-
# ghcup should be installed on current GHA Windows runners. Let's use ghcup to run
57-
# pacman, to install the necessary dependencies, ...
58-
ghcup run -- pacman --noconfirm -S ${{ inputs.pacman-packages }}
59-
60-
- name: Setup GHC (Windows)
61-
if: inputs.ghc-version != '' && runner.os == 'Windows'
62-
shell: pwsh
63-
run: ghcup install ghc --set ${{ inputs.ghc-version }}
64-
65-
- name: Setup GHC (Posix)
20+
- name: Setup GHC
6621
if: inputs.ghc-version != ''
6722
shell: bash
6823
run: ghcup install ghc --set ${{ inputs.ghc-version }}
6924

70-
- name: Setup cabal (Windows)
71-
if: inputs.cabal-version != '' && runner.os == 'Windows'
72-
shell: pwsh
73-
run: ghcup install cabal --set ${{ inputs.cabal-version }}
74-
75-
- name: Setup cabal (Posix)
25+
- name: Setup cabal
7626
if: inputs.cabal-version != ''
7727
shell: bash
7828
run: ghcup install cabal --set ${{ inputs.cabal-version }}
7929

80-
- name: "WIN: fixup cabal config"
81-
if: runner.os == 'Windows'
82-
shell: pwsh
83-
run: |
84-
# make sure cabal knows about msys64, and mingw64 tools. Not clear why C:/cabal/config is empty
85-
# and C:/cabal doesn't even exist. The ghcup bootstrap file should have create it in the image:
86-
# See https://github.com/haskell/ghcup-hs/blob/787edc17af4907dbc51c85e25c490edd8d68b80b/scripts/bootstrap/bootstrap-haskell#L591
87-
# So we'll do it by hand here for now.
88-
#
89-
# We'll _not_ add extra-include-dirs, or extra-lib-dirs, and rely on what's shipped with GHC.
90-
# https://github.com/msys2/MINGW-packages/issues/10837#issuecomment-1047105402
91-
# https://gitlab.haskell.org/ghc/ghc/-/issues/21111
92-
# if we _do_ want them, this would be the lines to add below
93-
94-
$ghcMingwDir = Join-Path -Path $(ghc --print-libdir) `
95-
-ChildPath ../mingw/x86_64-*-mingw32/lib/ `
96-
-Resolve
97-
98-
cabal user-config -a "extra-prog-path: C:/msys64/mingw64/bin, C:/msys64/usr/bin" `
99-
-a "extra-include-dirs: C:/msys64/mingw64/include" `
100-
-a ("extra-lib-dirs: {0}, C:/msys64/mingw64/lib" -f $ghcMingwDir) `
101-
-f init
102-
10330
# Unify the computation of the cabal store directory to a single step. This makes referencing the cabal
10431
# store in later steps easier.
10532
#

0 commit comments

Comments
 (0)