Skip to content

Commit aaee425

Browse files
committed
Add extensionIn
1 parent 372622f commit aaee425

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Cabal/src/Distribution/Simple/GHC/Build/Utils.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,21 @@ withDynFLib flib =
7474
ForeignLibTypeUnknown ->
7575
cabalBug "unknown foreign lib type"
7676

77+
-- | Is the extension of the file in the list of extensions?
78+
extensionIn :: [String] -> FilePath -> Bool
79+
extensionIn exts fp = takeExtension fp `elem` exts
80+
7781
-- | Is this file a C++ source file, i.e. ends with .cpp, .cxx, or .c++?
7882
isCxx :: FilePath -> Bool
79-
isCxx fp = takeExtension fp `elem` [".cpp", ".cxx", ".c++"]
83+
isCxx = extensionIn [".cpp", ".cxx", ".c++"]
8084

8185
-- | Is this a C source file, i.e. ends with .c?
8286
isC :: FilePath -> Bool
83-
isC fp = takeExtension fp `elem` [".c"]
87+
isC = extensionIn [".c"]
8488

8589
-- | FilePath has a Haskell extension: .hs or .lhs
8690
isHaskell :: FilePath -> Bool
87-
isHaskell fp = takeExtension fp `elem` [".hs", ".lhs"]
91+
isHaskell = extensionIn [".hs", ".lhs"]
8892

8993
-- | Returns True if the modification date of the given source file is newer than
9094
-- the object file we last compiled for it, or if no object file exists yet.

Cabal/src/Distribution/Simple/GHCJS.hs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import Distribution.Simple.BuildPaths
6262
import Distribution.Simple.Compiler
6363
import Distribution.Simple.Errors
6464
import Distribution.Simple.Flag
65+
import Distribution.Simple.GHC.Build.Utils (isCxx, isHaskell)
6566
import Distribution.Simple.GHC.EnvironmentParser
6667
import Distribution.Simple.GHC.ImplInfo
6768
import qualified Distribution.Simple.GHC.Internal as Internal
@@ -1242,13 +1243,6 @@ gbuildSources verbosity mbWorkDir pkgId specVer tmpDir bm =
12421243
, inputSourceModules = foreignLibModules flib
12431244
}
12441245

1245-
isCxx :: FilePath -> Bool
1246-
isCxx fp = takeExtension fp `elem` [".cpp", ".cxx", ".c++"]
1247-
1248-
-- | FilePath has a Haskell extension: .hs or .lhs
1249-
isHaskell :: FilePath -> Bool
1250-
isHaskell fp = takeExtension fp `elem` [".hs", ".lhs"]
1251-
12521246
-- | Generic build function. See comment for 'GBuildMode'.
12531247
gbuild
12541248
:: Verbosity

0 commit comments

Comments
 (0)