@@ -82,6 +82,7 @@ import qualified RIO.PrettyPrint as PP (Style (Module))
8282data Ctx = Ctx { ctxFile :: ! (Path Abs File )
8383 , ctxDistDir :: ! (Path Abs Dir )
8484 , ctxBuildConfig :: ! BuildConfig
85+ , ctxCabalVer :: ! Version
8586 }
8687
8788instance HasPlatform Ctx
@@ -219,9 +220,10 @@ packageFromPackageDescription packageConfig pkgFlags (PackageDescriptionPair pkg
219220 let pkgDir = parent cabalfp
220221 distDir <- distDirFromDir pkgDir
221222 bc <- view buildConfigL
223+ cabalVer <- view cabalVersionL
222224 (componentModules,componentFiles,dataFiles',warnings) <-
223225 runRIO
224- (Ctx cabalfp distDir bc)
226+ (Ctx cabalfp distDir bc cabalVer )
225227 (packageDescModulesAndFiles pkg)
226228 setupFiles <-
227229 if buildType pkg == Custom
@@ -795,13 +797,21 @@ resolveComponentFiles
795797resolveComponentFiles component build names = do
796798 dirs <- mapMaybeM resolveDirOrWarn (hsSourceDirs build)
797799 dir <- asks (parent . ctxFile)
800+ agdirs <- autogenDirs
798801 (modules,files,warnings) <-
799802 resolveFilesAndDeps
800803 component
801- (if null dirs then [dir] else dirs)
804+ (( if null dirs then [dir] else dirs) ++ agdirs )
802805 names
803806 cfiles <- buildOtherSources build
804807 return (modules, files <> cfiles, warnings)
808+ where
809+ autogenDirs = do
810+ cabalVer <- asks ctxCabalVer
811+ distDir <- asks ctxDistDir
812+ let compDir = componentAutogenDir cabalVer component distDir
813+ pkgDir = maybeToList $ packageAutogenDir cabalVer distDir
814+ return $ compDir : pkgDir
805815
806816-- | Get all C sources and extra source files in a build.
807817buildOtherSources :: BuildInfo -> RIO Ctx [DotCabalPath ]
0 commit comments