From 9d1f71e60f8999839a179e17221457c37fc9a5b5 Mon Sep 17 00:00:00 2001 From: Shayne Fletcher Date: Mon, 15 Jul 2024 16:15:08 -0400 Subject: [PATCH] use cabal to build/run the ci script --- .github/workflows/ghc-lib-da-ghc-8.4.3.yml | 43 ++++--------------- .../ghc-lib-ghc-9.10.1-ghc-9.8.2.yml | 27 ++---------- .../workflows/ghc-lib-ghc-9.8.2-ghc-9.6.5.yml | 27 ++---------- .../ghc-lib-ghc-master-ghc-9.10.1.yml | 27 ++---------- ghc-lib-gen.cabal | 33 ++++++++++---- ghc-lib-gen/src/Ghclibgen.hs | 7 --- 6 files changed, 45 insertions(+), 119 deletions(-) diff --git a/.github/workflows/ghc-lib-da-ghc-8.4.3.yml b/.github/workflows/ghc-lib-da-ghc-8.4.3.yml index 9f9fdb76..900ab57c 100644 --- a/.github/workflows/ghc-lib-da-ghc-8.4.3.yml +++ b/.github/workflows/ghc-lib-da-ghc-8.4.3.yml @@ -17,47 +17,22 @@ jobs: cd /c curl -L https://github.com/commercialhaskell/stackage-content/releases/download/msys2-20230526/msys2-20230526-x86_64.tar.xz -o msys2-20230526-x86_64.tar.xz tar xvf ./msys2-20230526-x86_64.tar.xz > /dev/null + echo "/c/mingw64/usr/bin" >> $GITHUB_PATH + echo "/c/msys64/usr/bin" >> $GITHUB_PATH + echo "MSYSTEM=CLANG64" >> $GITHUB_ENV if: matrix.os == 'windows' - name: Install ghcup shell: bash run: |- - curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \ - BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \ - BOOTSTRAP_HASKELL_GHC_VERSION=8.4.3 \ - BOOTSTRAP_HASKELL_CABAL_VERSION=latest \ - BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 \ - BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 \ - BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - - name: Setup cabal (windows) - shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' - run: |- - PATH=/c/cabal/bin:/c/.ghcup/ghc-8.4.3/bin:/c/.ghcup/bin:$PATH - export PATH - cabal update - cabal install alex happy - cabal --store-dir="c:\\cabal\\store" --lib --force-reinstalls --package-env=- install extra-1.6.13 optparse-applicative-0.14.3.0 - if: matrix.os == 'windows' - - name: Setup cabal(unix) - shell: bash - run: |- - PATH="$HOME/.cabal/bin":"$HOME/.ghcup/ghc/8.4.3/bin":"$HOME/.ghcup/bin":"$PATH" - export PATH - cabal install alex happy - cabal --store-dir=$HOME/.cabal/store --lib --force-reinstalls --package-env=- install extra-1.6.13 optparse-applicative-0.14.3.0 - if: matrix.os == 'ubuntu' || matrix.os == 'macos' + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=8.4.3 BOOTSTRAP_HASKELL_CABAL_VERSION=latest BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh + echo "/c/ghcup/bin" >> $GITHUB_PATH + echo "/c/ghcup/8.4.3/bin" >> $GITHUB_PATH + echo "/c/cabal/bin" >> $GITHUB_PATH - name: Run CI.hs (windows) shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' - run: |- - PATH=/c/cabal/bin:/c/ghcup/ghc/8.4.3/bin:/c/ghcup/bin:/c/msys64/usr/bin:/c/mingw64/bin:"/c/program files/git/bin":"$PATH" - export PATH - MSYSTEM=CLANG64; export MSYSTEM - pacman -S autoconf automake-wrapper make patch python tar mintty --noconfirm - runghc --ghc-arg=-clear-package-db --ghc-arg=-global-package-db --ghc-arg=-user-package-db --ghc-arg=-package-db --ghc-arg=/c/cabal/store/$(ls /c/cabal/store)/package.db CI.hs --da + run: pacman -S autoconf automake-wrapper make patch python tar mintty --noconfirm && cabal run exe:ghc-lib-build-tool -- --da if: matrix.os == 'windows' - name: Run CI.hs (unix) shell: bash - run: |- - PATH="$HOME/.cabal/bin":"$HOME/.ghcup/ghc/8.4.3/bin":"$HOME/.ghcup/bin":"$PATH" - export PATH - runghc --ghc-arg=-clear-package-db --ghc-arg=-global-package-db --ghc-arg=-user-package-db --ghc-arg=-package-db --ghc-arg=$HOME/.cabal/store/$(ls $HOME/.cabal/store)/package.db CI.hs --da + run: cabal run exe:ghc-lib-build-tool -- --da if: matrix.os == 'ubuntu' || matrix.os == 'macos' diff --git a/.github/workflows/ghc-lib-ghc-9.10.1-ghc-9.8.2.yml b/.github/workflows/ghc-lib-ghc-9.10.1-ghc-9.8.2.yml index 801f99eb..72cbf274 100644 --- a/.github/workflows/ghc-lib-ghc-9.10.1-ghc-9.8.2.yml +++ b/.github/workflows/ghc-lib-ghc-9.10.1-ghc-9.8.2.yml @@ -31,36 +31,17 @@ jobs: BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 \ BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 \ BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - - name: Setup cabal (windows) - shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' - run: |- - PATH=/c/cabal/bin:/c/.ghcup/ghc-9.8.2/bin:/c/.ghcup/bin:$PATH - export PATH - cabal update - cabal install alex happy - cabal --store-dir="c:\\cabal\\store" --lib --force-reinstalls --package-env=- install extra-1.7.16 optparse-applicative-0.18.1.0 - if: matrix.os == 'windows' - - name: Setup cabal(unix) - shell: bash - run: |- - PATH="$HOME/.cabal/bin":"$HOME/.ghcup/ghc/9.8.2/bin":"$HOME/.ghcup/bin":"$PATH" - export PATH - cabal install alex happy - cabal --store-dir=$HOME/.cabal/store --lib --force-reinstalls --package-env=- install extra-1.7.16 optparse-applicative-0.18.1.0 - if: matrix.os == 'ubuntu' || matrix.os == 'macos' - name: Run CI.hs (windows) shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' run: |- - PATH=/c/cabal/bin:/c/ghcup/ghc/9.8.2/bin:/c/ghcup/bin:/c/msys64/usr/bin:/c/mingw64/bin:"/c/program files/git/bin":"$PATH" - export PATH + PATH=/c/cabal/bin:/c/ghcup/ghc/9.8.2/bin:/c/ghcup/bin:/c/msys64/usr/bin:/c/mingw64/bin:"/c/program files/git/bin":"$PATH"; export PATH MSYSTEM=CLANG64; export MSYSTEM pacman -S autoconf automake-wrapper make patch python tar mintty --noconfirm - runghc --ghc-arg=-clear-package-db --ghc-arg=-global-package-db --ghc-arg=-user-package-db --ghc-arg=-package-db --ghc-arg=/c/cabal/store/$(ls /c/cabal/store)/package.db CI.hs --ghc-flavor ghc-9.10.1 + cabal run exe:ghc-lib-build-tool -- --ghc-flavor ghc-9.10.1 if: matrix.os == 'windows' - name: Run CI.hs (unix) shell: bash run: |- - PATH="$HOME/.cabal/bin":"$HOME/.ghcup/ghc/9.8.2/bin":"$HOME/.ghcup/bin":"$PATH" - export PATH - runghc --ghc-arg=-clear-package-db --ghc-arg=-global-package-db --ghc-arg=-user-package-db --ghc-arg=-package-db --ghc-arg=$HOME/.cabal/store/$(ls $HOME/.cabal/store)/package.db CI.hs --ghc-flavor ghc-9.10.1 + PATH="$HOME/.cabal/bin":"$HOME/.ghcup/ghc/9.8.2/bin":"$HOME/.ghcup/bin":"$PATH"; export PATH + cabal run exe:ghc-lib-build-tool -- --ghc-flavor ghc-9.10.1 if: matrix.os == 'ubuntu' || matrix.os == 'macos' diff --git a/.github/workflows/ghc-lib-ghc-9.8.2-ghc-9.6.5.yml b/.github/workflows/ghc-lib-ghc-9.8.2-ghc-9.6.5.yml index 5562a12f..b66fc42d 100644 --- a/.github/workflows/ghc-lib-ghc-9.8.2-ghc-9.6.5.yml +++ b/.github/workflows/ghc-lib-ghc-9.8.2-ghc-9.6.5.yml @@ -31,36 +31,17 @@ jobs: BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 \ BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 \ BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - - name: Setup cabal (windows) - shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' - run: |- - PATH=/c/cabal/bin:/c/.ghcup/ghc-9.6.5/bin:/c/.ghcup/bin:$PATH - export PATH - cabal update - cabal install alex happy - cabal --store-dir="c:\\cabal\\store" --lib --force-reinstalls --package-env=- install extra-1.7.16 optparse-applicative-0.18.1.0 semaphore-compat-1.0.0 - if: matrix.os == 'windows' - - name: Setup cabal(unix) - shell: bash - run: |- - PATH=$HOME/.cabal/bin:$HOME/.ghcup/ghc/9.6.5/bin:$HOME/.ghcup/bin:"$PATH" - export PATH - cabal install alex happy - cabal --store-dir=$HOME/.cabal/store --lib --force-reinstalls --package-env=- install extra-1.7.16 optparse-applicative-0.18.1.0 semaphore-compat-1.0.0 - if: matrix.os == 'ubuntu' || matrix.os == 'macos' - name: Run CI.hs (windows) shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' run: |- - PATH=/c/cabal/bin:/c/ghcup/ghc/9.6.5/bin:/c/ghcup/bin:/c/msys64/usr/bin:/c/mingw64/bin:"/c/program files/git/bin":"$PATH" - export PATH + PATH=/c/cabal/bin:/c/ghcup/ghc/9.6.5/bin:/c/ghcup/bin:/c/msys64/usr/bin:/c/mingw64/bin:"/c/program files/git/bin":"$PATH"; export PATH MSYSTEM=CLANG64; export MSYSTEM pacman -S autoconf automake-wrapper make patch python tar mintty --noconfirm - runghc --ghc-arg=-clear-package-db --ghc-arg=-global-package-db --ghc-arg=-user-package-db --ghc-arg=-package-db --ghc-arg=/c/cabal/store/$(ls /c/cabal/store)/package.db CI.hs --ghc-flavor ghc-9.8.2 + cabal run exe:ghc-lib-build-tool --constraint="ghc-lib-gen +semaphore-compat" -- --ghc-flavor ghc-9.8.2 if: matrix.os == 'windows' - name: Run CI.hs (unix) shell: bash run: |- - PATH="$HOME/.cabal/bin":"$HOME/.ghcup/ghc/9.6.5/bin":"$HOME/.ghcup/bin":"$PATH" - export PATH - runghc --ghc-arg=-clear-package-db --ghc-arg=-global-package-db --ghc-arg=-user-package-db --ghc-arg=-package-db --ghc-arg=$HOME/.cabal/store/$(ls $HOME/.cabal/store)/package.db CI.hs --ghc-flavor ghc-9.8.2 + PATH="$HOME/.cabal/bin":"$HOME/.ghcup/ghc/9.6.5/bin":"$HOME/.ghcup/bin":"$PATH"; export PATH + cabal run exe:ghc-lib-build-tool --constraint="ghc-lib-gen +semaphore-compat" -- --ghc-flavor ghc-9.8.2 if: matrix.os == 'ubuntu' || matrix.os == 'macos' diff --git a/.github/workflows/ghc-lib-ghc-master-ghc-9.10.1.yml b/.github/workflows/ghc-lib-ghc-master-ghc-9.10.1.yml index 7cb01544..8f239a45 100644 --- a/.github/workflows/ghc-lib-ghc-master-ghc-9.10.1.yml +++ b/.github/workflows/ghc-lib-ghc-master-ghc-9.10.1.yml @@ -31,36 +31,17 @@ jobs: BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 \ BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1 \ BOOTSTRAP_HASKELL_ADJUST_BASHRC=N sh - - name: Setup cabal (windows) - shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' - run: |- - PATH=/c/cabal/bin:/c/.ghcup/ghc-9.10.1/bin:/c/.ghcup/bin:$PATH - export PATH - cabal update - cabal install alex happy - cabal --store-dir="c:\\cabal\\store" --lib --force-reinstalls --package-env=- install extra-1.7.16 optparse-applicative-0.18.1.0 - if: matrix.os == 'windows' - - name: Setup cabal(unix) - shell: bash - run: |- - PATH="$HOME/.cabal/bin":"$HOME/.ghcup/ghc/9.10.1/bin":"$HOME/.ghcup/bin":"$PATH" - export PATH - cabal install alex happy - cabal --store-dir=$HOME/.cabal/store --lib --force-reinstalls --package-env=- install extra-1.7.16 optparse-applicative-0.18.1.0 - if: matrix.os == 'ubuntu' || matrix.os == 'macos' - name: Run CI.hs (windows) shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}' run: |- - PATH=/c/cabal/bin:/c/ghcup/ghc/9.10.1/bin:/c/ghcup/bin:/c/mingw64/bin:/c/msys64/usr/bin:"/c/program files/git/bin":"$PATH" - export PATH + PATH=/c/cabal/bin:/c/ghcup/ghc/9.10.1/bin:/c/ghcup/bin:/c/mingw64/bin:/c/msys64/usr/bin:"/c/program files/git/bin":"$PATH"; export PATH MSYSTEM=CLANG64; export MSYSTEM pacman -S autoconf automake-wrapper make patch python tar mintty --noconfirm - runghc --ghc-arg=-clear-package-db --ghc-arg=-global-package-db --ghc-arg=-user-package-db --ghc-arg=-package-db --ghc-arg=/c/cabal/store/$(ls /c/cabal/store)/package.db CI.hs --ghc-flavor ghc-master + cabal run exe:ghc-lib-build-tool --constraint="ghc-lib-gen +semaphore-compat" -- --ghc-flavor ghc-master if: matrix.os == 'windows' - name: Run CI.hs (unix) shell: bash run: |- - PATH="$HOME/.cabal/bin":"$HOME/.ghcup/ghc/9.10.1/bin":"$HOME/.ghcup/bin":"$PATH" - export PATH - runghc --ghc-arg=-clear-package-db --ghc-arg=-global-package-db --ghc-arg=-user-package-db --ghc-arg=-package-db --ghc-arg=$HOME/.cabal/store/$(ls $HOME/.cabal/store)/package.db CI.hs --ghc-flavor ghc-master + PATH="$HOME/.cabal/bin":"$HOME/.ghcup/ghc/9.10.1/bin":"$HOME/.ghcup/bin":"$PATH"; export PATH + cabal run exe:ghc-lib-build-tool --constraint="ghc-lib-gen +semaphore-compat" -- --ghc-flavor ghc-master if: matrix.os == 'ubuntu' || matrix.os == 'macos' diff --git a/ghc-lib-gen.cabal b/ghc-lib-gen.cabal index 979474a8..37a3c439 100644 --- a/ghc-lib-gen.cabal +++ b/ghc-lib-gen.cabal @@ -1,6 +1,6 @@ cabal-version: 3.4 name: ghc-lib-gen -version: 0.1.0.0 +version: 0.20240715.0 synopsis: Cabal file generator for GHC as a library description: Generate a cabal file for a subset of GHC for use as a library. homepage:https://github.com/digital-asset/ghc-lib @@ -13,6 +13,11 @@ copyright: Digital Asset 2018-2024 category: Development build-type: Simple +flag semaphore-compat + default: False + manual: True + description: Install semaphore-compat from Hackage + common base default-language: Haskell2010 ghc-options: @@ -31,16 +36,26 @@ common lib library import: lib hs-source-dirs: ghc-lib-gen/src - exposed-modules: Ghclibgen - GhclibgenFlavor - GhclibgenOpts + exposed-modules: + Ghclibgen + GhclibgenFlavor + GhclibgenOpts other-modules: Paths_ghc_lib_gen autogen-modules: Paths_ghc_lib_gen -common cli - import: base - build-depends: directory, optparse-applicative, ghc-lib-gen - executable ghc-lib-gen - import: cli + import: base + build-depends: + directory, optparse-applicative, ghc-lib-gen + if flag(semaphore-compat) + build-depends: semaphore-compat main-is: ghc-lib-gen/src/Main.hs + +executable ghc-lib-build-tool + import: base + build-tool-depends: alex:alex, happy:happy + build-depends: + directory, filepath, time, extra, optparse-applicative + if flag(semaphore-compat) + build-depends: semaphore-compat + main-is: CI.hs diff --git a/ghc-lib-gen/src/Ghclibgen.hs b/ghc-lib-gen/src/Ghclibgen.hs index 67d0741c..18b21ddd 100644 --- a/ghc-lib-gen/src/Ghclibgen.hs +++ b/ghc-lib-gen/src/Ghclibgen.hs @@ -349,13 +349,6 @@ calcModuleDeps includeDirs _hsSrcDirs hsSrcIncludes ghcFlavor ghcPackagePath sem , "-package base" ] ++ [ "-package exceptions" | series == GHC_9_0 ] ++ - [ flag | series >= GHC_9_8 - , not semaphoreCompatBootExists - , flag <- - [ "-ignore-package os-string" ] ++ - [ "-package filepath" ]++ - [ "-package " ++ if not isWindows then "unix" else "Win32" ] - ] ++ ["-package semaphore-compat" | series >= GHC_9_8] ++ hsSrcIncludes ++ [ rootModulePath ]