Unverified Commit f5f8d933 authored by Oleg Grenrus's avatar Oleg Grenrus Committed by GitHub
Browse files

Merge pull request #7087 from phadej/pr-6295-hsc2hs-options

PR #6295: hsc2hs options
parents e38b457e 64f0b043
......@@ -514,6 +514,8 @@ buildInfoFieldGrammar = BuildInfo
<*> monoidalFieldAla "cxx-options" (alaList' NoCommaFSep Token') L.cxxOptions
^^^ availableSince CabalSpecV2_2 []
<*> monoidalFieldAla "ld-options" (alaList' NoCommaFSep Token') L.ldOptions
<*> monoidalFieldAla "hsc2hs-options" (alaList' NoCommaFSep Token') L.hsc2hsOptions
^^^ availableSince CabalSpecV3_6 []
<*> monoidalFieldAla "pkgconfig-depends" (alaList CommaFSep) L.pkgconfigDepends
<*> monoidalFieldAla "frameworks" (alaList' FSep Token) L.frameworks
<*> monoidalFieldAla "extra-framework-dirs" (alaList' FSep FilePathNT) L.extraFrameworkDirs
......
......@@ -395,7 +395,7 @@ ppHsc2hs bi lbi clbi =
let isCross = hostPlatform lbi /= buildPlatform
prependCrossFlags = if isCross then ("-x":) else id
let hsc2hsSupportsResponseFiles = hsc2hsVersion >= mkVersion [0,68,4]
pureArgs = genPureArgs gccProg inFile outFile
pureArgs = genPureArgs hsc2hsVersion gccProg inFile outFile
if hsc2hsSupportsResponseFiles
then withResponseFile
verbosity
......@@ -411,13 +411,10 @@ ppHsc2hs bi lbi clbi =
where
-- Returns a list of command line arguments that can either be passed
-- directly, or via a response file.
genPureArgs :: ConfiguredProgram -> String -> String -> [String]
genPureArgs gccProg inFile outFile =
[ "--cc=" ++ programPath gccProg
, "--ld=" ++ programPath gccProg ]
genPureArgs :: Version -> ConfiguredProgram -> String -> String -> [String]
genPureArgs hsc2hsVersion gccProg inFile outFile =
-- Additional gcc options
++ [ "--cflag=" ++ opt | opt <- programDefaultArgs gccProg
[ "--cflag=" ++ opt | opt <- programDefaultArgs gccProg
++ programOverrideArgs gccProg ]
++ [ "--lflag=" ++ opt | opt <- programDefaultArgs gccProg
++ programOverrideArgs gccProg ]
......@@ -475,7 +472,24 @@ ppHsc2hs bi lbi clbi =
, opt <- Installed.libraryDirs pkg ]
++ [ "-l" ++ opt | opt <- Installed.extraLibraries pkg ]
++ [ opt | opt <- Installed.ldOptions pkg ] ]
++ preccldFlags
++ hsc2hsOptions bi
++ postccldFlags
++ ["-o", outFile, inFile]
where
-- hsc2hs flag parsing was wrong
-- (see -- https://github.com/haskell/hsc2hs/issues/35)
-- so we need to put -- --cc/--ld *after* hsc2hsOptions,
-- for older hsc2hs (pre 0.68.8) so that they can be overridden.
ccldFlags =
[ "--cc=" ++ programPath gccProg
, "--ld=" ++ programPath gccProg
]
(preccldFlags, postccldFlags)
| hsc2hsVersion >= mkVersion [0,68,8] = (ccldFlags, [])
| otherwise = ([], ccldFlags)
hacked_index = packageHacks (installedPkgs lbi)
-- Look only at the dependencies of the current component
......
......@@ -56,6 +56,7 @@ data BuildInfo = BuildInfo {
ccOptions :: [String], -- ^ options for C compiler
cxxOptions :: [String], -- ^ options for C++ compiler
ldOptions :: [String], -- ^ options for linker
hsc2hsOptions :: [String], -- ^ options for hsc2hs
pkgconfigDepends :: [PkgconfigDependency], -- ^ pkg-config packages that are used
frameworks :: [String], -- ^support frameworks for Mac OS X
extraFrameworkDirs:: [String], -- ^ extra locations to find frameworks.
......@@ -123,6 +124,7 @@ instance Monoid BuildInfo where
ccOptions = [],
cxxOptions = [],
ldOptions = [],
hsc2hsOptions = [],
pkgconfigDepends = [],
frameworks = [],
extraFrameworkDirs = [],
......@@ -171,6 +173,7 @@ instance Semigroup BuildInfo where
ccOptions = combine ccOptions,
cxxOptions = combine cxxOptions,
ldOptions = combine ldOptions,
hsc2hsOptions = combine hsc2hsOptions,
pkgconfigDepends = combine pkgconfigDepends,
frameworks = combineNub frameworks,
extraFrameworkDirs = combineNub extraFrameworkDirs,
......
......@@ -60,6 +60,10 @@ class HasBuildInfo a where
ldOptions = buildInfo . ldOptions
{-# INLINE ldOptions #-}
hsc2hsOptions :: Lens' a [String]
hsc2hsOptions = buildInfo . hsc2hsOptions
{-# INLINE hsc2hsOptions #-}
pkgconfigDepends :: Lens' a [PkgconfigDependency]
pkgconfigDepends = buildInfo . pkgconfigDepends
{-# INLINE pkgconfigDepends #-}
......@@ -228,6 +232,9 @@ instance HasBuildInfo BuildInfo where
ldOptions f s = fmap (\x -> s { T.ldOptions = x }) (f (T.ldOptions s))
{-# INLINE ldOptions #-}
hsc2hsOptions f s = fmap (\x -> s { T.hsc2hsOptions = x }) (f (T.hsc2hsOptions s))
{-# INLINE hsc2hsOptions #-}
pkgconfigDepends f s = fmap (\x -> s { T.pkgconfigDepends = x }) (f (T.pkgconfigDepends s))
{-# INLINE pkgconfigDepends #-}
......
......@@ -48,6 +48,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -143,6 +144,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -247,6 +249,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -38,6 +38,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -35,6 +35,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -49,6 +49,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -134,6 +135,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -216,6 +218,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -282,6 +285,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -358,6 +362,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -436,6 +441,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -522,6 +528,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -605,6 +612,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -38,6 +38,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -103,6 +104,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -45,6 +45,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -124,6 +125,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -215,6 +217,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -296,6 +299,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -391,6 +395,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -469,6 +474,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -541,6 +547,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -615,6 +622,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -38,6 +38,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -113,6 +114,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -45,6 +45,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -111,6 +112,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -43,6 +43,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -111,6 +112,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -177,6 +179,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -245,6 +248,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -311,6 +315,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -40,6 +40,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -51,6 +51,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -153,6 +154,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -244,6 +246,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -309,6 +312,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -440,6 +444,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["src"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -562,6 +567,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["test"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -648,6 +654,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["test"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -48,6 +48,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["exe"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -143,6 +144,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["exe"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -234,6 +236,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["exe"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -321,6 +324,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["exe"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -402,6 +406,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -560,6 +565,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -719,6 +725,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -988,6 +995,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["utils"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -1345,6 +1353,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -3453,6 +3462,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -3604,6 +3614,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["utils", "src"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -5116,6 +5127,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -6495,6 +6507,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -6667,6 +6680,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["utils", "src"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -8102,6 +8116,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -8502,6 +8517,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -8909,6 +8925,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -9542,6 +9559,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = ["tests"],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......@@ -38,6 +38,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -35,6 +35,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -35,6 +35,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
......@@ -35,6 +35,7 @@ GenericPackageDescription
extraLibs = [],
frameworks = [],
hsSourceDirs = [],
hsc2hsOptions = [],
includeDirs = [],
includes = [],
installIncludes = [],
......
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