diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-04-01 13:58:21 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-04-05 20:44:37 -0400 |
commit | 53cf2c047eb2c9251608d85dd0485b645d118ea9 (patch) | |
tree | 0f90d347c8c72f312218ba26034c4508d1010d99 /hadrian | |
parent | 836542409f8dcb6ec23bda485d01880d24bd3d93 (diff) | |
download | haskell-53cf2c047eb2c9251608d85dd0485b645d118ea9.tar.gz |
hadrian: Refactor hlint target
Not only does this eliminate some code duplication but we also
add a maximum core count to HLint's command-line, hopefully avoiding
issue #19600.
Diffstat (limited to 'hadrian')
-rw-r--r-- | hadrian/src/Rules/Lint.hs | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/hadrian/src/Rules/Lint.hs b/hadrian/src/Rules/Lint.hs index c0b8473aef..f02a63b6b0 100644 --- a/hadrian/src/Rules/Lint.hs +++ b/hadrian/src/Rules/Lint.hs @@ -22,6 +22,27 @@ lint lintAction = do else putFailure "| Please make sure you have the `hlint` executable in your $PATH" +runHLint :: [FilePath] -- ^ include directories + -> [String] -- ^ CPP defines + -> FilePath + -> Action () +runHLint includeDirs defines dir = do + threads <- shakeThreads <$> getShakeOptions + hostArch <- (<> "_HOST_ARCH") <$> setting HostArch + let hlintYaml = dir </> ".hlint.yaml" + defines' = [hostArch] ++ defines + cmdLine = unwords $ + [ "hlint" + , "-j" <> show threads + ] ++ + map ("--cpp-define=" <>) defines' ++ + map ("--cpp-include=" <>) includeDirs ++ + [ "-h" <> hlintYaml + , dir + ] + putBuild $ "| " <> cmdLine + cmd_ cmdLine + base :: Action () base = do buildDir <- buildRoot @@ -30,19 +51,13 @@ base = do let ghcautoconf = stage1Lib </> "ghcautoconf.h" let ghcplatform = stage1Lib </> "ghcplatform.h" need ["stage1:lib:base", ghcautoconf, ghcplatform, machDeps] - let include0 = "includes" - let include1 = "libraries/base/include" - let include2 = stage1Lib - let include3 = buildDir </> "stage1/libraries/base/build/include" - let hlintYaml = "libraries/base/.hlint.yaml" - hostArch <- (<> "_HOST_ARCH") <$> setting HostArch - let cmdLine = "hlint -j --cpp-define " <> hostArch <> " --cpp-include=" <> include0 <> - " --cpp-include=" <> include1 <> - " --cpp-include=" <> include2 <> - " --cpp-include=" <> include3 <> - " -h " <> hlintYaml <> " libraries/base" - putBuild $ "| " <> cmdLine - cmd_ cmdLine + let includeDirs = + [ "includes" + , "libraries/base/include" + , stage1Lib + , buildDir </> "stage1/libraries/base/build/include" + ] + runHLint includeDirs [] "libraries/base" compiler :: Action () compiler = do @@ -55,19 +70,14 @@ compiler = do let ghcautoconf = stage1Lib </> "ghcautoconf.h" let ghcplatform = stage1Lib </> "ghcplatform.h" need $ mconcat [[ghcautoconf, ghcplatform], hsIncls stage1Compiler, [machDeps, hsVersions]] - let include0 = "includes" - let include1 = stage1Lib - let hlintYaml = "compiler/.hlint.yaml" - hostArch <- (<> "_HOST_ARCH") <$> setting HostArch - let cmdLine = "hlint -j --cpp-define " <> hostArch <> - " --cpp-include=" <> include0 <> - " --cpp-include=" <> include1 <> - " --cpp-include=" <> compilerDir <> - " --cpp-include=" <> ghcplatform <> - " --cpp-include=" <> stage1Compiler <> - " -h " <> hlintYaml <> " compiler" - putBuild $ "| " <> cmdLine - cmd_ cmdLine + let includeDirs = + [ "includes" + , stage1Lib + , compilerDir + , ghcplatform + , stage1Compiler + ] + runHLint includeDirs [] "compiler" hsIncls :: FilePath -> [FilePath] hsIncls path = [ path </> "primop-vector-tycons.hs-incl" |