Skip to content

Commit

Permalink
more tests, simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
shayne-fletcher committed Jul 22, 2024
1 parent 6fe98c9 commit 3fe20f1
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ghc-lib-da-ghc-8.4.3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
jobs:
runhaskell:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows]
os: [ubuntu-latest, macos-13, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/setup@v2
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/ghc-lib-ghc-9.0.2-ghc-8.10.7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ghc-lib-ghc-9.0.2-ghc-8.10.7
on:
push:
jobs:
runhaskell:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: 8.10.7
cabal-version: 'latest'
- name: Install build tools (macOS)
run: brew install automake
if: matrix.os == 'macos'
- name: Configure msys2 (windows)
shell: bash
run: |-
echo "MSYSTEM=CLANG64" >> $GITHUB_ENV
echo "/c/mingw64/usr/bin" >> $GITHUB_PATH
echo "/c/msys64/usr/bin" >> $GITHUB_PATH
if: matrix.os == 'windows'
- name: Run CI.hs (windows)
shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}'
run: |-
pacman -S autoconf automake-wrapper make patch python tar mintty --noconfirm
cabal run exe:ghc-lib-build-tool --constraint=any."happy==1.19.12" --constraint="any.alex==3.2.7.3" -- --ghc-flavor ghc-9.0.2
if: matrix.os == 'windows'
- name: Run CI.hs (unix)
shell: bash
run: cabal run exe:ghc-lib-build-tool --constraint="any.happy==1.19.12" --constraint="any.alex==3.2.7.3" -- --ghc-flavor ghc-9.0.2
if: matrix.os == 'ubuntu' || matrix.os == 'macos'
38 changes: 38 additions & 0 deletions .github/workflows/ghc-lib-ghc-9.4.8-ghc-9.0.2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ghc-lib-ghc-9.4.8-ghc-9.0.2
on:
push:
jobs:
runhaskell:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: 9.0.2
cabal-version: 'latest'
- name: Install build tools (macOS)
run: brew install automake
if: matrix.os == 'macos'
- name: Configure msys2 (windows)
shell: bash
run: |-
echo "MSYSTEM=CLANG64" >> $GITHUB_ENV
echo "/c/mingw64/usr/bin" >> $GITHUB_PATH
echo "/c/msys64/usr/bin" >> $GITHUB_PATH
if: matrix.os == 'windows'
- name: Run CI.hs (windows)
shell: C:\msys64\usr\bin\bash.exe --noprofile --norc -e -o pipefail '{0}'
run: |-
pacman -S autoconf automake-wrapper make patch python tar mintty --noconfirm
cabal run exe:ghc-lib-build-tool -- --ghc-flavor ghc-9.4.8
if: matrix.os == 'windows'
- name: Run CI.hs (unix)
shell: bash
run: cabal run exe:ghc-lib-build-tool -- --ghc-flavor ghc-9.4.8
if: matrix.os == 'ubuntu' || matrix.os == 'macos'
52 changes: 17 additions & 35 deletions ghc-lib-gen/src/Ghclibgen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ cabalPackageDb ghcNumericVersion = do
case Map.lookup "Project Unit Id" ghcInfoMap of
Just projectUnitId -> projectUnitId -- e.g. ghc-9.10.1-2e29
Nothing -> "ghc-" ++ ghcNumericVersion
msg <- systemOutput_ $ "bash -c 'echo \"cabal store contents: \" && ls " ++ cabalStoreDir ++ "'"
putStrln msg
pure $ cabalStoreDir ++ "/" ++ ghcDir ++ "/package.db"

ghcPackageDb :: String -> IO String
Expand All @@ -327,12 +329,7 @@ ghcPackageDb _ghcNumericVersion = do

ghcPackagePath :: String -> String -> String -> IO String
ghcPackagePath ghcPackageDb cabalPackageDb ghcNumericVersion =
pure $ "GHC_PACKAGE_PATH=" ++ cabalPackageDb ++
(if not isWindows then
":"
else
":" ++ ghcPackageDb
)
pure $ "GHC_PACKAGE_PATH=" ++ cabalPackageDb ++ ":" ++ ghcPackageDb

semaphoreCompatBootExists :: IO Bool
semaphoreCompatBootExists =
Expand Down Expand Up @@ -361,34 +358,21 @@ setupModuleDepsPlaceholders _ = do
createDirectoryIfMissing True dir
copyFile file new_p

calcModuleDeps :: [FilePath] -> [FilePath] -> [FilePath] -> GhcFlavor -> String -> Bool -> String -> String
calcModuleDeps includeDirs _hsSrcDirs hsSrcIncludes ghcFlavor ghcPackagePath semaphoreCompatBootExists ghcMakeModeOutputFile = do
let series = ghcSeries ghcFlavor
rootModulePath = placeholderModulesDir </> "Main.hs"
cmd = unwords $
[ "ghc" ] ++
[ "-optP -DGHCI" | series < GHC_8_10 ] ++
[ "-optP -DSTAGE=2" | series < GHC_8_10 ] ++
[ "-optP -DGHC_IN_GHCI" | series < GHC_9_2 ] ++
[ "-dep-suffix ''"
, "-dep-makefile " ++ ghcMakeModeOutputFile
, "-M"
] ++
calcModuleDeps :: [FilePath] -> [FilePath] -> [FilePath] -> GhcFlavor -> String -> String -> String
calcModuleDeps includeDirs _hsSrcDirs hsSrcIncludes ghcFlavor ghcPackagePath ghcMakeModeOutputFile = do
let cmd = unwords $
[ "ghc", "-M"] ++
[ "-dep-suffix ''", "-dep-makefile " ++ ghcMakeModeOutputFile ] ++
[ optP | optP <- [ "-optP -DGHCI", "-optP -DSTAGE=2" ], series < GHC_8_10 ] ++ [ "-optP -DGHC_IN_GHCI" | series < GHC_9_2 ] ++
includeDirs ++
[ "-ignore-package ghc"
, "-ignore-package ghci"
, "-package base"
] ++
[ "-package exceptions" | series == GHC_9_0 ] ++
[ "-package semaphore-compat" | series >= GHC_9_8 ] ++
[ pkg | pkg <- [ "-package base" ] ++ [ "-package semaphore-compat" | series >= GHC_9_8 ] ] ++
hsSrcIncludes ++
[ rootModulePath ]
cmd' =
if series < GHC_9_8 || semaphoreCompatBootExists then
cmd
else
"bash -c \"" ++ ghcPackagePath ++ " " ++ cmd ++ "\""
cmd' = "bash -c \"" ++ ghcPackagePath ++ " " ++ cmd ++ "\""
in cmd'
where
series = ghcSeries ghcFlavor
rootModulePath = placeholderModulesDir </> "Main.hs"

readGhcMakeModeOutputFile :: FilePath -> [FilePath] -> IO [String]
readGhcMakeModeOutputFile file hsSrcDirs = do
Expand Down Expand Up @@ -422,17 +406,16 @@ ghcPackagePath' = do

calcParserModules :: GhcFlavor -> IO [String]
calcParserModules ghcFlavor = do
let rootModulePath = placeholderModulesDir </> "Main.hs"
let rootModulePath = placeholderModulesDir </> "Main.hs"
series = ghcSeries ghcFlavor

Check failure on line 410 in ghc-lib-gen/src/Ghclibgen.hs

View workflow job for this annotation

GitHub Actions / ubuntu

parse error on input ‘=’

Check failure on line 410 in ghc-lib-gen/src/Ghclibgen.hs

View workflow job for this annotation

GitHub Actions / ubuntu

parse error on input ‘=’

Check failure on line 410 in ghc-lib-gen/src/Ghclibgen.hs

View workflow job for this annotation

GitHub Actions / ubuntu

parse error on input ‘=’

Check failure on line 410 in ghc-lib-gen/src/Ghclibgen.hs

View workflow job for this annotation

GitHub Actions / ubuntu

parse error on input ‘=’

Check failure on line 410 in ghc-lib-gen/src/Ghclibgen.hs

View workflow job for this annotation

GitHub Actions / macos

parse error on input ‘=’

Check failure on line 410 in ghc-lib-gen/src/Ghclibgen.hs

View workflow job for this annotation

GitHub Actions / macos

parse error on input ‘=’
mainFile = "../ghc-lib-gen/ghc-lib-parser" </> show series </> "Main.hs"
copyFile mainFile rootModulePath
lib <- mapM readCabalFile (cabalFileLibraries ghcFlavor)
ghcPackagePath <- ghcPackagePath'
semaphoreCompatBootExists <- semaphoreCompatBootExists
let includeDirs = map ("-I" ++ ) (ghcLibParserIncludeDirs ghcFlavor)
hsSrcDirs = placeholderModulesDir : ghcLibParserHsSrcDirs True ghcFlavor lib
hsSrcIncludes = map ("-i" ++ ) hsSrcDirs
cmd' = calcModuleDeps includeDirs hsSrcDirs hsSrcIncludes ghcFlavor ghcPackagePath semaphoreCompatBootExists ".parser-depends"
cmd' = calcModuleDeps includeDirs hsSrcDirs hsSrcIncludes ghcFlavor ghcPackagePath ".parser-depends"
putStrLn "# Generating 'ghc/.parser-depends'..."
putStrLn $ "\n\n# Running: " ++ cmd'
system_ cmd'
Expand All @@ -446,11 +429,10 @@ calcLibModules ghcFlavor = do
copyFile mainFile rootModulePath
lib <- mapM readCabalFile (cabalFileLibraries ghcFlavor)
ghcPackagePath <- ghcPackagePath'
semaphoreCompatBootExists <- semaphoreCompatBootExists
let includeDirs = map ("-I" ++ ) (ghcLibIncludeDirs ghcFlavor)
hsSrcDirs = placeholderModulesDir : ghcLibHsSrcDirs True ghcFlavor lib
hsSrcIncludes = map ("-i" ++ ) hsSrcDirs
cmd' = calcModuleDeps includeDirs hsSrcDirs hsSrcIncludes ghcFlavor ghcPackagePath semaphoreCompatBootExists ".lib-depends"
cmd' = calcModuleDeps includeDirs hsSrcDirs hsSrcIncludes ghcFlavor ghcPackagePath ".lib-depends"
putStrLn "# Generating 'ghc/.lib-depends'..."
putStrLn $ "\n\n# Running: " ++ cmd'
system_ cmd'
Expand Down

0 comments on commit 3fe20f1

Please sign in to comment.