Commit 6719dd92 authored by Alex Washburn's avatar Alex Washburn Committed by recursion-ninja

Correcting whitespace/alignment issues. Adding main source in more principled manner.

parent 6c6f2886
...@@ -1138,29 +1138,36 @@ gbuildSources verbosity specVer tmpDir bm = ...@@ -1138,29 +1138,36 @@ gbuildSources verbosity specVer tmpDir bm =
return BuildSources { return BuildSources {
cSourcesFiles = cSources bnfo, cSourcesFiles = cSources bnfo,
cxxSourceFiles = cxxSources bnfo, cxxSourceFiles = cxxSources bnfo,
inputSourceFiles = [main], inputSourceFiles = [main],
inputSourceModules = filter (/= mainModName) $ exeModules exe inputSourceModules = filter (/= mainModName) $ exeModules exe
} }
else return BuildSources { else return BuildSources {
cSourcesFiles = cSources bnfo, cSourcesFiles = cSources bnfo,
cxxSourceFiles = cxxSources bnfo, cxxSourceFiles = cxxSources bnfo,
inputSourceFiles = [main], inputSourceFiles = [main],
inputSourceModules = exeModules exe inputSourceModules = exeModules exe
} }
else return BuildSources { else let (csf, cxxsf)
cSourcesFiles = main : cSources bnfo, | isCxx main = ( cSources bnfo, main : cxxSources bnfo)
cxxSourceFiles = main : cxxSources bnfo, -- if main is not a Haskell source
inputSourceFiles = [], -- and main is not a C++ source
inputSourceModules = exeModules exe -- then we assume that it is a C source
} | otherwise = (main : cSources bnfo, cxxSources bnfo)
in return BuildSources {
cSourcesFiles = csf,
cxxSourceFiles = cxxsf,
inputSourceFiles = [],
inputSourceModules = exeModules exe
}
flibSources :: ForeignLib -> BuildSources flibSources :: ForeignLib -> BuildSources
flibSources flib@ForeignLib{foreignLibBuildInfo = bnfo} = flibSources flib@ForeignLib{foreignLibBuildInfo = bnfo} =
BuildSources { BuildSources {
cSourcesFiles = cSources bnfo, cSourcesFiles = cSources bnfo,
cxxSourceFiles = cxxSources bnfo, cxxSourceFiles = cxxSources bnfo,
inputSourceFiles = [], inputSourceFiles = [],
inputSourceModules = foreignLibModules flib inputSourceModules = foreignLibModules flib
} }
...@@ -1168,6 +1175,9 @@ gbuildSources verbosity specVer tmpDir bm = ...@@ -1168,6 +1175,9 @@ gbuildSources verbosity specVer tmpDir bm =
isHaskell :: FilePath -> Bool isHaskell :: FilePath -> Bool
isHaskell fp = elem (takeExtension fp) [".hs", ".lhs"] isHaskell fp = elem (takeExtension fp) [".hs", ".lhs"]
isCxx :: FilePath -> Bool
isCxx fp = elem (takeExtension fp) [".cpp", ".cxx", ".c++"]
-- | Generic build function. See comment for 'GBuildMode'. -- | Generic build function. See comment for 'GBuildMode'.
gbuild :: Verbosity -> Cabal.Flag (Maybe Int) gbuild :: Verbosity -> Cabal.Flag (Maybe Int)
-> PackageDescription -> LocalBuildInfo -> PackageDescription -> LocalBuildInfo
......
...@@ -429,8 +429,10 @@ ppHsc2hs bi lbi clbi = ...@@ -429,8 +429,10 @@ ppHsc2hs bi lbi clbi =
-- and C++ functions are exported via a C -- and C++ functions are exported via a C
-- interface and wrapped in a C source file. -- interface and wrapped in a C source file.
-- Therefore we do not supply C++ flags -- Therefore we do not supply C++ flags
-- because there will not be C++ sources -- because there will not be C++ sources.
{- ++ PD.cxxOptions bi -} ] --
-- DO NOT add PD.cxxOptions unless this changes!
]
++ [ "--cflag=" ++ opt | opt <- ++ [ "--cflag=" ++ opt | opt <-
[ "-I" ++ autogenComponentModulesDir lbi clbi, [ "-I" ++ autogenComponentModulesDir lbi clbi,
"-I" ++ autogenPackageModulesDir lbi, "-I" ++ autogenPackageModulesDir lbi,
...@@ -445,8 +447,7 @@ ppHsc2hs bi lbi clbi = ...@@ -445,8 +447,7 @@ ppHsc2hs bi lbi clbi =
++ [ "--cflag=" ++ opt ++ [ "--cflag=" ++ opt
| pkg <- pkgs | pkg <- pkgs
, opt <- [ "-I" ++ opt | opt <- Installed.includeDirs pkg ] , opt <- [ "-I" ++ opt | opt <- Installed.includeDirs pkg ]
++ [ opt | opt <- Installed.ccOptions pkg ++ [ opt | opt <- Installed.ccOptions pkg ] ]
{- ++ Installed.cxxOptions pkg -} ] ]
++ [ "--lflag=" ++ opt ++ [ "--lflag=" ++ opt
| pkg <- pkgs | pkg <- pkgs
, opt <- [ "-L" ++ opt | opt <- Installed.libraryDirs pkg ] , opt <- [ "-L" ++ opt | opt <- Installed.libraryDirs pkg ]
...@@ -515,9 +516,10 @@ ppC2hs bi lbi clbi = ...@@ -515,9 +516,10 @@ ppC2hs bi lbi clbi =
-- and C++ functions are exported via a C -- and C++ functions are exported via a C
-- interface and wrapped in a C source file. -- interface and wrapped in a C source file.
-- Therefore we do not supply C++ flags -- Therefore we do not supply C++ flags
-- because there will not be C++ sources -- because there will not be C++ sources.
-- --
-- ++ Installed.cxxOptions pkg --
-- DO NOT add Installed.cxxOptions unless this changes!
, c `elem` "DIU" ] ] , c `elem` "DIU" ] ]
--TODO: install .chi files for packages, so we can --include --TODO: install .chi files for packages, so we can --include
-- those dirs here, for the dependencies -- those dirs here, for the dependencies
......
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