summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/ghci/ghci-wrapper.cabal.in1
-rw-r--r--hadrian/src/Hadrian/Haskell/Cabal/Parse.hs16
-rw-r--r--utils/hp2ps/hp2ps.cabal2
-rw-r--r--utils/touchy/touchy.cabal1
-rw-r--r--utils/unlit/unlit.cabal3
5 files changed, 16 insertions, 7 deletions
diff --git a/driver/ghci/ghci-wrapper.cabal.in b/driver/ghci/ghci-wrapper.cabal.in
index 2616223ada..5a422aab9b 100644
--- a/driver/ghci/ghci-wrapper.cabal.in
+++ b/driver/ghci/ghci-wrapper.cabal.in
@@ -24,6 +24,5 @@ Executable ghci
buildable: False
Include-Dirs: ../utils
C-Sources:
- ghci.c
-- the following get copied from ../utils by hadrian
getLocation.c isMinTTY.c cwrapper.c
diff --git a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
index 31e3fd70be..b017fb3701 100644
--- a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
+++ b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
@@ -194,6 +194,8 @@ registerPackage context@Context {..} = do
traced "cabal-register" $
C.defaultMainWithHooksNoReadArgs C.autoconfUserHooks gpd
[ "register", "--builddir", ctxPath, v ]
+-- | What type of file is Main
+data MainSourceType = HsMain | CppMain | CMain
-- | Parse the 'ContextData' of a given 'Context'.
resolveContextData :: Context -> Action ContextData
@@ -265,10 +267,18 @@ resolveContextData context@Context {..} = do
(buildInfo, modules, mainIs) = biModules pd'
+ classifyMain :: FilePath -> MainSourceType
+ classifyMain fp
+ | takeExtension fp `elem` [".hs", ".lhs"] = HsMain
+ | takeExtension fp `elem` [".cpp", ".cxx", ".c++"]= CppMain
+ | otherwise = CMain
+
+ main_src = fmap (first C.display) mainIs
+
in return $ ContextData
{ dependencies = deps
, componentId = C.localCompatPackageKey lbi'
- , mainIs = fmap (first C.display) mainIs
+ , mainIs = main_src
, modules = map C.display modules
, otherModules = map C.display $ C.otherModules buildInfo
, srcDirs =
@@ -284,8 +294,8 @@ resolveContextData context@Context {..} = do
, extraLibs = C.extraLibs buildInfo
, extraLibDirs = C.extraLibDirs buildInfo
, asmSrcs = C.asmSources buildInfo
- , cSrcs = C.cSources buildInfo
- , cxxSrcs = C.cxxSources buildInfo
+ , cSrcs = C.cSources buildInfo ++ [ ms | Just (_,ms) <- pure main_src, CMain <- pure (classifyMain ms)]
+ , cxxSrcs = C.cxxSources buildInfo ++ [ ms | Just (_,ms) <- pure main_src, CppMain <- pure (classifyMain ms)]
, cmmSrcs = C.cmmSources buildInfo
, hcOpts = C.programDefaultArgs ghcProg
++ C.hcOptions C.GHC buildInfo
diff --git a/utils/hp2ps/hp2ps.cabal b/utils/hp2ps/hp2ps.cabal
index 1b48694564..d317ac707d 100644
--- a/utils/hp2ps/hp2ps.cabal
+++ b/utils/hp2ps/hp2ps.cabal
@@ -15,7 +15,7 @@ Executable hp2ps
Main-Is: Main.c
extra-libraries: m
C-Sources:
- AreaBelow.c Curves.c Error.c Main.c
+ AreaBelow.c Curves.c Error.c
Reorder.c TopTwenty.c AuxFile.c Deviation.c
HpFile.c Marks.c Scale.c TraceElement.c
Axes.c Dimensions.c Key.c PsFile.c Shade.c
diff --git a/utils/touchy/touchy.cabal b/utils/touchy/touchy.cabal
index 21a774b1fa..5c28c664fc 100644
--- a/utils/touchy/touchy.cabal
+++ b/utils/touchy/touchy.cabal
@@ -13,4 +13,3 @@ build-type: Simple
Executable touchy
Default-Language: Haskell2010
Main-Is: touchy.c
- C-Sources: touchy.c
diff --git a/utils/unlit/unlit.cabal b/utils/unlit/unlit.cabal
index e49fd8558b..0707d5d95a 100644
--- a/utils/unlit/unlit.cabal
+++ b/utils/unlit/unlit.cabal
@@ -9,9 +9,10 @@ Synopsis: Literate program filter
Description: XXX
Category: Development
build-type: Simple
+extra-source-files: fs.h
Executable unlit
Default-Language: Haskell2010
Main-Is: unlit.c
- C-Sources: unlit.c, fs.c
+ C-Sources: fs.c
Includes: fs.h