Commit 7e27ae7c authored by Oleg Grenrus's avatar Oleg Grenrus

Add autogen-includes field

autogen-includes aren't searched nor packages by `sdist`.

This is relatively small code patch, but there are
- change in file-format
- short documentation of the field
- `cabal check`
- test-suite noise due new field in `BuildInfo`
parent 5dd260a8
......@@ -270,6 +270,12 @@ checkLibrary pkg lib =
"An 'autogen-module' is neither on 'exposed-modules' or "
++ "'other-modules'."
-- check that all autogen-includes appear on includes or install-includes
, check
(not $ and $ map (flip elem (allExplicitIncludes lib)) (view L.autogenIncludes lib)) $
PackageBuildImpossible $
"An include in 'autogen-includes' is neither in 'includes' or "
++ "'install-includes'."
]
where
......@@ -282,6 +288,9 @@ checkLibrary pkg lib =
moduleDuplicates = dups (explicitLibModules lib ++
map moduleReexportName (reexportedModules lib))
allExplicitIncludes :: L.HasBuildInfo a => a -> [FilePath]
allExplicitIncludes x = view L.includes x ++ view L.installIncludes x
checkExecutable :: PackageDescription -> Executable -> [PackageCheck]
checkExecutable pkg exe =
catMaybes [
......@@ -315,6 +324,11 @@ checkExecutable pkg exe =
PackageBuildImpossible $
"On executable '" ++ prettyShow (exeName exe) ++ "' an 'autogen-module' is not "
++ "on 'other-modules'"
-- check that all autogen-includes appear on includes
, check
(not $ and $ map (flip elem (view L.includes exe)) (view L.autogenIncludes exe)) $
PackageBuildImpossible "An include in 'autogen-includes' is not in 'includes'."
]
where
moduleDuplicates = dups (exeModules exe)
......@@ -355,13 +369,15 @@ checkTestSuite pkg test =
-- check that all autogen-modules appear on other-modules
, check
(not $ and $ map
(flip elem (testModules test))
(testModulesAutogen test)
) $
(not $ and $ map (flip elem (testModules test)) (testModulesAutogen test)) $
PackageBuildImpossible $
"On test suite '" ++ prettyShow (testName test) ++ "' an 'autogen-module' is not "
++ "on 'other-modules'"
-- check that all autogen-includes appear on includes
, check
(not $ and $ map (flip elem (view L.includes test)) (view L.autogenIncludes test)) $
PackageBuildImpossible "An include in 'autogen-includes' is not in 'includes'."
]
where
moduleDuplicates = dups $ testModules test
......@@ -404,13 +420,15 @@ checkBenchmark _pkg bm =
-- check that all autogen-modules appear on other-modules
, check
(not $ and $ map
(flip elem (benchmarkModules bm))
(benchmarkModulesAutogen bm)
) $
(not $ and $ map (flip elem (benchmarkModules bm)) (benchmarkModulesAutogen bm)) $
PackageBuildImpossible $
"On benchmark '" ++ prettyShow (benchmarkName bm) ++ "' an 'autogen-module' is "
++ "not on 'other-modules'"
-- check that all autogen-includes appear on includes
, check
(not $ and $ map (flip elem (view L.includes bm)) (view L.autogenIncludes bm)) $
PackageBuildImpossible "An include in 'autogen-includes' is not in 'includes'."
]
where
moduleDuplicates = dups $ benchmarkModules bm
......
......@@ -427,6 +427,8 @@ buildInfoFieldGrammar = BuildInfo
<*> monoidalFieldAla "extra-lib-dirs" (alaList' FSep FilePathNT) L.extraLibDirs
<*> monoidalFieldAla "include-dirs" (alaList' FSep FilePathNT) L.includeDirs
<*> monoidalFieldAla "includes" (alaList' FSep FilePathNT) L.includes
<*> monoidalFieldAla "autogen-includes" (alaList' FSep FilePathNT) L.autogenIncludes
^^^ availableSince CabalSpecV3_0 []
<*> monoidalFieldAla "install-includes" (alaList' FSep FilePathNT) L.installIncludes
<*> optionsFieldGrammar
<*> profOptionsFieldGrammar
......
......@@ -226,12 +226,13 @@ listPackageSourcesOrdinary verbosity pkg_descr pps =
-- License file(s).
, return (licenseFiles pkg_descr)
-- Install-include files.
-- Install-include files, without autogen-include files
, fmap concat
. withAllLib $ \ l -> do
let lbi = libBuildInfo l
let lbi = libBuildInfo l
incls = filter (`notElem` autogenIncludes lbi) (installIncludes lbi)
relincdirs = "." : filter isRelative (includeDirs lbi)
traverse (fmap snd . findIncludeFile verbosity relincdirs) (installIncludes lbi)
traverse (fmap snd . findIncludeFile verbosity relincdirs) incls
-- Setup script, if it exists.
, fmap (maybe [] (\f -> [f])) $ findSetupFile ""
......
......@@ -94,6 +94,7 @@ data BuildInfo = BuildInfo {
extraLibDirs :: [String],
includeDirs :: [FilePath], -- ^directories to find .h files
includes :: [FilePath], -- ^ The .h files to be found in includeDirs
autogenIncludes :: [FilePath], -- ^ The .h files to be generated (e.g. by @autoconf@)
installIncludes :: [FilePath], -- ^ .h files to install with the package
options :: PerCompilerFlavor [String],
profOptions :: PerCompilerFlavor [String],
......@@ -147,6 +148,7 @@ instance Monoid BuildInfo where
extraLibDirs = [],
includeDirs = [],
includes = [],
autogenIncludes = [],
installIncludes = [],
options = mempty,
profOptions = mempty,
......@@ -194,6 +196,7 @@ instance Semigroup BuildInfo where
extraLibDirs = combineNub extraLibDirs,
includeDirs = combineNub includeDirs,
includes = combineNub includes,
autogenIncludes = combineNub autogenIncludes,
installIncludes = combineNub installIncludes,
options = combine options,
profOptions = combine profOptions,
......
......@@ -160,6 +160,10 @@ class HasBuildInfo a where
includes = buildInfo . includes
{-# INLINE includes #-}
autogenIncludes :: Lens' a [FilePath]
autogenIncludes = buildInfo . autogenIncludes
{-# INLINE autogenIncludes #-}
installIncludes :: Lens' a [FilePath]
installIncludes = buildInfo . installIncludes
{-# INLINE installIncludes #-}
......@@ -299,6 +303,9 @@ instance HasBuildInfo BuildInfo where
includes f s = fmap (\x -> s { T.includes = x }) (f (T.includes s))
{-# INLINE includes #-}
autogenIncludes f s = fmap (\x -> s { T.autogenIncludes = x }) (f (T.autogenIncludes s))
{-# INLINE autogenIncludes #-}
installIncludes f s = fmap (\x -> s { T.installIncludes = x }) (f (T.installIncludes s))
{-# INLINE installIncludes #-}
......
......@@ -3326,8 +3326,8 @@ is to distinguish ``Cabal < 2.0`` from ``Cabal >= 2.0``.
Autogenerated modules
---------------------
Autogenerated modules and includes
----------------------------------
Modules that are built automatically at setup, created with a custom
setup script, must appear on :pkg-field:`other-modules` for the library,
......@@ -3372,6 +3372,13 @@ Right now :pkg-field:`executable:main-is` modules are not supported on
autogen-modules:
MyExeHelperModule
.. pkg-field:: autogen-includes: filename list
:since: 3.0
A list of header files from this package which are autogenerated
(e.g. by a ``configure`` script). Autogenerated header files are not
packaged by ``sdist`` command.
Accessing data files from package code
--------------------------------------
......
......@@ -66,6 +66,9 @@ relative to the respective preceding *published* version.
* Wildcards are disallowed in :pkg-field:`pkgconfig-depends`,
Yet the pkgconfig format is relaxed to accept e.g. versions like ``1.1.0h``.
* New :pkg-field:`autogen-includes` for specifying :pkg-field:`install-includes`
which are autogenerated (e.g. by a ``configure`` script).
``cabal-version: 2.4``
----------------------
......
......@@ -24,6 +24,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -113,6 +114,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -206,6 +208,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -23,6 +23,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -99,6 +100,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -174,6 +176,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -237,6 +240,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -308,6 +312,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -379,6 +384,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -454,6 +460,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -528,6 +535,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -14,6 +14,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -76,6 +77,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -19,6 +19,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -95,6 +96,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -176,6 +178,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -253,6 +256,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -337,6 +341,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -408,6 +413,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -475,6 +481,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -546,6 +553,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -14,6 +14,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -86,6 +87,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -19,6 +19,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -82,6 +83,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -19,6 +19,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -84,6 +85,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -147,6 +149,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -212,6 +215,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -275,6 +279,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -17,6 +17,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -23,6 +23,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -112,6 +113,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -193,6 +195,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -258,6 +261,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -354,6 +358,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -498,6 +503,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -579,6 +585,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -14,6 +14,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -11,6 +11,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -11,6 +11,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -11,6 +11,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -14,6 +14,7 @@ GenericPackageDescription
{buildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -81,6 +82,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -144,6 +146,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -11,6 +11,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -42,6 +42,7 @@ GenericPackageDescription
{buildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -157,6 +158,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -250,6 +252,7 @@ GenericPackageDescription
{testBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [`ExeDependency (PackageName "tasty-discover") (UnqualComponentName "tasty-discover") (MajorBoundVersion (mkVersion [4,2,1]))`],
buildTools = [],
......
......@@ -41,6 +41,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -34,6 +34,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......
......@@ -23,6 +23,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -103,6 +104,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -183,6 +185,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],
autogenModules = [],
buildToolDepends = [],
buildTools = [],
......@@ -243,6 +246,7 @@ GenericPackageDescription
libBuildInfo = BuildInfo
{asmOptions = [],
asmSources = [],
autogenIncludes = [],