Skip to content

Commit 1eb4198

Browse files
authored
Merge pull request #142 from phadej/gen-includes
Include `include-dirs` in build directory (for Configure generated headers)
2 parents 2a01753 + a7ede15 commit 1eb4198

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

cabal-docspec/Changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# 0.0.0.202312dd
1+
# 0.0.0.20231219
22

33
- Pass `default-language` flag to GHC
44
- Fix issue with CPP defines without an explicit value (i.e. `-DFOO`, not `-DBAR=42`)
5+
- Include `include-dirs` in build directory (for Configure generated headers)
56

67
# 0.0.0.20230406
78

cabal-docspec/src/CabalDocspec/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ testComponent tracer0 tracerTop dynOptsCli ghcInfo buildDir cabalCfg plan env pk
252252
-- first phase: read modules and extract the comments
253253
let pkgVer = C.packageVersion (pkgGpd pkg)
254254
modules <- for modulePaths $ \(modname, modpath) ->
255-
phase1 tracer ghcInfo pkgVer (pkgDir pkg) cppEnabled cppDirs pkgIds bi modname modpath
255+
phase1 tracer ghcInfo (Just buildDir) (C.packageName (pkgGpd pkg)) pkgVer (pkgDir pkg) cppEnabled cppDirs pkgIds bi modname modpath
256256

257257
-- extract doctests from the modules.
258258
let parsed :: [Module [Located DocTest]]
@@ -347,7 +347,7 @@ testComponentNo tracer0 tracerTop dynOptsCli ghcInfo cabalCfg dbG pkg = do
347347
-- first phase: read modules and extract the comments
348348
let pkgVer = C.packageVersion (pkgGpd pkg)
349349
modules <- for modulePaths $ \(modname, modpath) ->
350-
phase1 tracer ghcInfo pkgVer (pkgDir pkg) cppEnabled cppDirs pkgIds bi modname modpath
350+
phase1 tracer ghcInfo Nothing (C.packageName (pkgGpd pkg)) pkgVer (pkgDir pkg) cppEnabled cppDirs pkgIds bi modname modpath
351351

352352
-- extract doctests from the modules.
353353
let parsed :: [Module [Located DocTest]]

cabal-docspec/src/CabalDocspec/Phase1.hs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ import CabalDocspec.Trace
2222
phase1
2323
:: TracerPeu r Tr
2424
-> GhcInfo
25-
-> Version -- ^ package version
26-
-> Path Absolute -- ^ package directory
27-
-> Bool -- ^ cpp extension
28-
-> [Path Absolute] -- ^ additional include directories
29-
-> [PackageIdentifier] -- ^ dependencies
25+
-> Maybe (Path Absolute) -- ^ builddir
26+
-> PackageName -- ^ package name
27+
-> Version -- ^ package version
28+
-> Path Absolute -- ^ package directory
29+
-> Bool -- ^ cpp extension
30+
-> [Path Absolute] -- ^ additional include directories
31+
-> [PackageIdentifier] -- ^ dependencies
3032
-> C.BuildInfo
3133
-> C.ModuleName
3234
-> Path Absolute
3335
-> Peu r (Module (Located String))
34-
phase1 tracer ghcInfo pkgVer pkgDir cppEnabled cppDirs pkgIds bi modname modpath = do
36+
phase1 tracer ghcInfo mbuildDir pkgName_ pkgVer pkgDir cppEnabled cppDirs pkgIds bi modname modpath = do
3537
traceApp tracer $ TracePhase1 modname modpath
3638

3739
contents <- fromUTF8BS <$> readByteString modpath
@@ -59,7 +61,16 @@ phase1 tracer ghcInfo pkgVer pkgDir cppEnabled cppDirs pkgIds bi modname modpath
5961
-- so may break
6062
[ pkgDir </> fromUnrootedFilePath dir
6163
| dir <- C.includeDirs bi
62-
] ++ cppDirs
64+
] ++
65+
[ buildDir </>
66+
fromUnrootedFilePath "build" </>
67+
componentDir ghcInfo (PackageIdentifier pkgName_ pkgVer) </>
68+
fromUnrootedFilePath "build" </>
69+
fromUnrootedFilePath dir
70+
| buildDir <- toList mbuildDir
71+
, dir <- C.includeDirs bi
72+
] ++
73+
cppDirs
6374

6475
cppDefines :: [(String, String)]
6576
cppDefines =
@@ -70,6 +81,13 @@ phase1 tracer ghcInfo pkgVer pkgDir cppEnabled cppDirs pkgIds bi modname modpath
7081
, Just d' <- return (parseDefineFlag d)
7182
]
7283

84+
-- x86_64-linux/ghc-9.8.1/streamly-0.10.0
85+
componentDir :: GhcInfo -> PackageIdentifier -> Path Unrooted
86+
componentDir ghcInfo pid =
87+
fromUnrootedFilePath(ghcPlatform ghcInfo) </>
88+
fromUnrootedFilePath ("ghc-" ++ prettyShow (ghcVersion ghcInfo)) </>
89+
fromUnrootedFilePath (prettyShow pid)
90+
7391
cppGhcVersion :: Version -> String
7492
cppGhcVersion v = case C.versionNumbers v of
7593
[] -> "0"

0 commit comments

Comments
 (0)