Commit b9571abc authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Address review comments in #3158.

* Renamed to 'extra-framework-dirs'.
* Added 'extra-framework-dirs' to ConfigFlags.
* Added some checks.
* Updated changelog.
parent 1da9b353
......@@ -812,7 +812,7 @@ data BuildInfo = BuildInfo {
ldOptions :: [String], -- ^ options for linker
pkgconfigDepends :: [Dependency], -- ^ pkg-config packages that are used
frameworks :: [String], -- ^support frameworks for Mac OS X
frameworkDirs :: [String],
extraFrameworkDirs:: [String], -- ^ extra locations to find frameworks.
cSources :: [FilePath],
jsSources :: [FilePath],
hsSourceDirs :: [FilePath], -- ^ where to look for the Haskell module hierarchy
......@@ -845,68 +845,68 @@ instance Binary BuildInfo
instance Monoid BuildInfo where
mempty = BuildInfo {
buildable = True,
buildTools = [],
cppOptions = [],
ccOptions = [],
ldOptions = [],
pkgconfigDepends = [],
frameworks = [],
frameworkDirs = [],
cSources = [],
jsSources = [],
hsSourceDirs = [],
otherModules = [],
defaultLanguage = Nothing,
otherLanguages = [],
defaultExtensions = [],
otherExtensions = [],
oldExtensions = [],
extraLibs = [],
extraGHCiLibs = [],
extraLibDirs = [],
includeDirs = [],
includes = [],
installIncludes = [],
options = [],
profOptions = [],
sharedOptions = [],
customFieldsBI = [],
targetBuildDepends = [],
buildable = True,
buildTools = [],
cppOptions = [],
ccOptions = [],
ldOptions = [],
pkgconfigDepends = [],
frameworks = [],
extraFrameworkDirs = [],
cSources = [],
jsSources = [],
hsSourceDirs = [],
otherModules = [],
defaultLanguage = Nothing,
otherLanguages = [],
defaultExtensions = [],
otherExtensions = [],
oldExtensions = [],
extraLibs = [],
extraGHCiLibs = [],
extraLibDirs = [],
includeDirs = [],
includes = [],
installIncludes = [],
options = [],
profOptions = [],
sharedOptions = [],
customFieldsBI = [],
targetBuildDepends = [],
targetBuildRenaming = Map.empty
}
mappend = (Semi.<>)
instance Semigroup BuildInfo where
a <> b = BuildInfo {
buildable = buildable a && buildable b,
buildTools = combine buildTools,
cppOptions = combine cppOptions,
ccOptions = combine ccOptions,
ldOptions = combine ldOptions,
pkgconfigDepends = combine pkgconfigDepends,
frameworks = combineNub frameworks,
frameworkDirs = combineNub frameworkDirs,
cSources = combineNub cSources,
jsSources = combineNub jsSources,
hsSourceDirs = combineNub hsSourceDirs,
otherModules = combineNub otherModules,
defaultLanguage = combineMby defaultLanguage,
otherLanguages = combineNub otherLanguages,
defaultExtensions = combineNub defaultExtensions,
otherExtensions = combineNub otherExtensions,
oldExtensions = combineNub oldExtensions,
extraLibs = combine extraLibs,
extraGHCiLibs = combine extraGHCiLibs,
extraLibDirs = combineNub extraLibDirs,
includeDirs = combineNub includeDirs,
includes = combineNub includes,
installIncludes = combineNub installIncludes,
options = combine options,
profOptions = combine profOptions,
sharedOptions = combine sharedOptions,
customFieldsBI = combine customFieldsBI,
targetBuildDepends = combineNub targetBuildDepends,
buildable = buildable a && buildable b,
buildTools = combine buildTools,
cppOptions = combine cppOptions,
ccOptions = combine ccOptions,
ldOptions = combine ldOptions,
pkgconfigDepends = combine pkgconfigDepends,
frameworks = combineNub frameworks,
extraFrameworkDirs = combineNub extraFrameworkDirs,
cSources = combineNub cSources,
jsSources = combineNub jsSources,
hsSourceDirs = combineNub hsSourceDirs,
otherModules = combineNub otherModules,
defaultLanguage = combineMby defaultLanguage,
otherLanguages = combineNub otherLanguages,
defaultExtensions = combineNub defaultExtensions,
otherExtensions = combineNub otherExtensions,
oldExtensions = combineNub oldExtensions,
extraLibs = combine extraLibs,
extraGHCiLibs = combine extraGHCiLibs,
extraLibDirs = combineNub extraLibDirs,
includeDirs = combineNub includeDirs,
includes = combineNub includes,
installIncludes = combineNub installIncludes,
options = combine options,
profOptions = combine profOptions,
sharedOptions = combine sharedOptions,
customFieldsBI = combine customFieldsBI,
targetBuildDepends = combineNub targetBuildDepends,
targetBuildRenaming = combineMap targetBuildRenaming
}
where
......
......@@ -91,7 +91,7 @@ data PackageCheck =
| PackageDistSuspicious { explanation :: String }
-- | Like PackageDistSuspicious but will only display warnings
-- rather than causing abnormal exit.
-- rather than causing abnormal exit when you run 'cabal check'.
| PackageDistSuspiciousWarn { explanation :: String }
-- | An issue that is OK in the author's environment but is almost
......@@ -669,6 +669,14 @@ checkGhcOptions pkg =
, checkAlternatives "ghc-options" "extra-lib-dirs"
[ (flag, dir) | flag@('-':'L':dir) <- all_ghc_options ]
, checkAlternatives "ghc-options" "frameworks"
[ (flag, fmwk) | (flag@"-framework", fmwk) <-
zip all_ghc_options (safeTail all_ghc_options) ]
, checkAlternatives "ghc-options" "extra-framework-dirs"
[ (flag, dir) | (flag@"-framework-path", dir) <-
zip all_ghc_options (safeTail all_ghc_options) ]
]
where
......@@ -912,6 +920,13 @@ checkCabalVersion pkg =
++ ". To use this new syntax, the package needs to specify at least"
++ "'cabal-version: >= 1.21'."
-- check use of 'extra-framework-dirs' field
, checkVersion [1,23] (any (not . null) (buildInfoField extraFrameworkDirs)) $
-- Just a warning, because this won't break on old Cabal versions.
PackageDistSuspiciousWarn $
"To use the 'extra-framework-dirs' field the package needs to specify"
++ " at least 'cabal-version: >= 1.23'."
-- check use of default-extensions field
-- don't need to do the equivalent check for other-extensions
, checkVersion [1,10] (any (not . null) (buildInfoField defaultExtensions)) $
......@@ -1568,6 +1583,8 @@ checkLocalPathsExist ops pkg = do
| bi <- allBuildInfo pkg
, (dir, kind) <-
[ (dir, "extra-lib-dirs") | dir <- extraLibDirs bi ]
++ [ (dir, "extra-framework-dirs")
| dir <- extraFrameworkDirs bi ]
++ [ (dir, "include-dirs") | dir <- includeDirs bi ]
++ [ (dir, "hs-source-dirs") | dir <- hsSourceDirs bi ]
, isRelative dir ]
......
......@@ -405,9 +405,9 @@ binfoFieldDescrs =
, listField "frameworks"
showToken parseTokenQ
frameworks (\val binfo -> binfo{frameworks=val})
, listField "framework-dirs"
, listField "extra-framework-dirs"
showToken parseFilePathQ
frameworkDirs (\val binfo -> binfo{frameworkDirs=val})
extraFrameworkDirs (\val binfo -> binfo{extraFrameworkDirs=val})
, listFieldWithSep vcat "c-sources"
showFilePath parseFilePathQ
cSources (\paths binfo -> binfo{cSources=paths})
......
......@@ -864,6 +864,7 @@ configureFinalizedPackage verbosity cfg
where
addExtraIncludeLibDirs pkg_descr =
let extraBi = mempty { extraLibDirs = configExtraLibDirs cfg
, extraFrameworkDirs = configExtraFrameworkDirs cfg
, PD.includeDirs = configExtraIncludeDirs cfg}
modifyLib l = l{ libBuildInfo = libBuildInfo l
`mappend` extraBi }
......
......@@ -552,7 +552,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ghcOptLinkFrameworks = toNubListR $
PD.frameworks libBi,
ghcOptLinkFrameworkDirs = toNubListR $
PD.frameworkDirs libBi,
PD.extraFrameworkDirs libBi,
ghcOptInputFiles = toNubListR
[libTargetDir </> x | x <- cObjs]
}
......@@ -727,7 +727,8 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ghcOptLinkLibs = toNubListR $ extraLibs libBi,
ghcOptLinkLibPath = toNubListR $ extraLibDirs libBi,
ghcOptLinkFrameworks = toNubListR $ PD.frameworks libBi,
ghcOptLinkFrameworkDirs = toNubListR $ PD.frameworkDirs libBi,
ghcOptLinkFrameworkDirs =
toNubListR $ PD.extraFrameworkDirs libBi,
ghcOptRPaths = rpaths
}
......@@ -856,7 +857,7 @@ buildOrReplExe forRepl verbosity numJobs _pkg_descr lbi
ghcOptLinkFrameworks = toNubListR $
PD.frameworks exeBi,
ghcOptLinkFrameworkDirs = toNubListR $
PD.frameworkDirs exeBi,
PD.extraFrameworkDirs exeBi,
ghcOptInputFiles = toNubListR
[exeDir </> x | x <- cObjs]
}
......
......@@ -339,8 +339,8 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
-- We don't want cc-options to be propagated
-- to C compilations in other packages.
IPI.ldOptions = ldOptions bi,
IPI.frameworkDirs = frameworkDirs bi,
IPI.frameworks = frameworks bi,
IPI.frameworkDirs = extraFrameworkDirs bi,
IPI.haddockInterfaces = [haddockdir installDirs </> haddockName pkg],
IPI.haddockHTMLs = [htmldir installDirs],
IPI.pkgRoot = Nothing
......
......@@ -346,6 +346,8 @@ data ConfigFlags = ConfigFlags {
-- paths
configScratchDir :: Flag FilePath,
configExtraLibDirs :: [FilePath], -- ^ path to search for extra libraries
configExtraFrameworkDirs :: [FilePath], -- ^ path to search for extra
-- frameworks (OS X only)
configExtraIncludeDirs :: [FilePath], -- ^ path to search for header files
configIPID :: Flag String, -- ^ explicit IPID to be used
......@@ -624,6 +626,12 @@ configureOptions showOrParseArgs =
configExtraLibDirs (\v flags -> flags {configExtraLibDirs = v})
(reqArg' "PATH" (\x -> [x]) id)
,option "" ["extra-framework-dirs"]
"A list of directories to search for external frameworks (OS X only)"
configExtraFrameworkDirs
(\v flags -> flags {configExtraFrameworkDirs = v})
(reqArg' "PATH" (\x -> [x]) id)
,option "" ["extra-prog-path"]
"A list of directories to search for required programs (in addition to the normal search locations)"
configProgramPathExtra (\v flags -> flags {configProgramPathExtra = v})
......@@ -818,6 +826,7 @@ instance Monoid ConfigFlags where
configStripExes = mempty,
configStripLibs = mempty,
configExtraLibDirs = mempty,
configExtraFrameworkDirs = mempty,
configConstraints = mempty,
configDependencies = mempty,
configExtraIncludeDirs = mempty,
......@@ -867,6 +876,7 @@ instance Semigroup ConfigFlags where
configStripExes = combine configStripExes,
configStripLibs = combine configStripLibs,
configExtraLibDirs = combine configExtraLibDirs,
configExtraFrameworkDirs = combine configExtraFrameworkDirs,
configConstraints = combine configConstraints,
configDependencies = combine configDependencies,
configExtraIncludeDirs = combine configExtraIncludeDirs,
......
......@@ -137,6 +137,7 @@ module Distribution.Simple.Utils (
listUnionRight,
ordNub,
ordNubRight,
safeTail,
wrapText,
wrapLine,
) where
......@@ -1473,6 +1474,11 @@ listUnionRight a b = ordNubRight (filter (`Set.notMember` bSet) a) ++ b
where
bSet = Set.fromList b
-- | A total variant of 'tail'.
safeTail :: [a] -> [a]
safeTail [] = []
safeTail (_:xs) = xs
equating :: Eq a => (b -> a) -> b -> b -> Bool
equating p x y = p x == p y
......
-*-change-log-*-
1.23.x.x (current development version)
* Support GHC 8.
* Deal with extra C sources from preprocessors (#238).
* Include cabal_macros.h when running c2hs (#2600).
* Don't recompile C sources unless needed (#2601).
......@@ -21,6 +22,9 @@
* Improved the './Setup configure' solver (#3082, #3076).
* The '--allow-newer' option can be now used with './Setup
configure' (#3163).
* Added a way to specify extra locations to find OS X frameworks
in ('extra-framework-dirs'). Can be used both in .cabal files and
as an argument to './Setup configure' (#3158).
1.22.0.0 Johan Tibell <johan.tibell@gmail.com> January 2015
* Support GHC 7.10.
......
......@@ -1255,12 +1255,12 @@ pass to `cabal bench`.
### Build information ###
The following fields may be optionally present in a library or
executable section, and give information for the building of the
The following fields may be optionally present in a library, executable, test
suite or benchmark section, and give information for the building of the
corresponding library or executable. See also the sections on
[system-dependent parameters](#system-dependent-parameters) and
[configurations](#configurations) for a way to supply system-dependent
values for these fields.
[configurations](#configurations) for a way to supply system-dependent values
for these fields.
`build-depends:` _package list_
: A list of packages needed to build this one. Each package can be
......@@ -1467,7 +1467,7 @@ values for these fields.
developer documentation for more details on frameworks. This entry
is ignored on all other platforms.
`frameworks-dirs:` _directory list_
`extra-frameworks-dirs:` _directory list_
: On Darwin/MacOS X, a list of directories to search for frameworks.
This entry is ignored on all other platforms.
......
......@@ -932,6 +932,10 @@ be controlled with the following command line options.
: An extra directory to search for system libraries files. You can use
this flag multiple times to get a list of directories.
`--extra-framework-dirs`[=_dir_]
: An extra directory to search for frameworks (OS X only). You can use this
flag multiple times to get a list of directories.
You might need to use this flag if you have standard system
libraries in a non-standard location that is not mentioned in the
package's `.cabal` file. Using this option has the same affect as
......
......@@ -306,6 +306,8 @@ instance Semigroup SavedConfig where
-- TODO: NubListify
configExtraLibDirs = lastNonEmpty configExtraLibDirs,
-- TODO: NubListify
configExtraFrameworkDirs = lastNonEmpty configExtraFrameworkDirs,
-- TODO: NubListify
configExtraIncludeDirs = lastNonEmpty configExtraIncludeDirs,
configIPID = combine configIPID,
configDistPref = combine configDistPref,
......
......@@ -44,6 +44,9 @@
(#2877).
* The '--allow-newer' option now works as expected when specified
multiple times (#2588).
* New config file field: 'extra-framework-dirs' (extra locations
to find OS X frameworks in). Can be also specified as an argument
for 'install' and 'configure' commands (#3158).
1.22.0.0 Johan Tibell <johan.tibell@gmail.com> January 2015
* New command: user-config (#2159).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment