shake-c 0.3.0.0 → 0.4.0.0
raw patch · 2 files changed
+21/−18 lines, 2 filesdep +composition-preludePVP ok
version bump matches the API change (PVP)
Dependencies added: composition-prelude
API changes (from Hackage documentation)
- Development.Shake.C: GCC :: Maybe String -> CCompiler
+ Development.Shake.C: GCC :: Maybe String -> Maybe String -> CCompiler
Files
- shake-c.cabal +4/−4
- src/Development/Shake/C.hs +17/−14
shake-c.cabal view
@@ -1,13 +1,12 @@ cabal-version: 1.18 name: shake-c-version: 0.3.0.0+version: 0.4.0.0 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2018 Vanessa McHale maintainer: vanessa.mchale@iohk.io author: Vanessa McHale-homepage: https://github.com/vmchale/shake-c#readme-bug-reports: https://github.com/vmchale/atspkg/issues+bug-reports: https://hub.darcs.net/vmchale/ats/issues synopsis: Library for building C code with shake description: Facilities for building C libraries and binaries, and depending on C source files. Extends [shake](http://hackage.haskell.org/package/shake).@@ -35,7 +34,8 @@ build-depends: base >=4.3 && <5, shake >=0.14,- cdeps -any+ cdeps -any,+ composition-prelude -any if flag(development) ghc-options: -Werror
src/Development/Shake/C.hs view
@@ -30,9 +30,10 @@ , isCross ) where +import Control.Composition import Control.Monad import Data.List (isPrefixOf, isSuffixOf)-import Development.Shake+import Development.Shake hiding ((*>)) import Development.Shake.Classes import Development.Shake.FilePath import GHC.Generics (Generic)@@ -50,7 +51,7 @@ mkQualified pre suff = h [f suff, g pre] where g = maybe id mappend f = maybe id (flip mappend)- h = foldr fmap id+ h = thread -- | The target triple of the host machine. host :: String@@ -63,22 +64,22 @@ ccToString ICC = "icc" ccToString Clang = "clang" ccToString (Other s) = s-ccToString (GCC pre) = mkQualified pre Nothing "gcc"+ccToString (GCC pre suff) = mkQualified pre suff "gcc" ccToString (GHC pre suff) = mkQualified pre suff "ghc" ccToString CompCert = "ccomp" stripToString :: CCompiler -> String-stripToString (GCC pre) = mkQualified pre Nothing "strip"+stripToString (GCC pre _) = mkQualified pre Nothing "strip" stripToString (GHC pre _) = mkQualified pre Nothing "strip" stripToString _ = "strip" arToString :: CCompiler -> String-arToString (GCC pre) = mkQualified pre Nothing "ar"+arToString (GCC pre _) = mkQualified pre Nothing "ar" arToString (GHC pre _) = mkQualified pre Nothing "ar" arToString _ = "ar" isCross :: CCompiler -> Bool-isCross (GCC Just{}) = True+isCross (GCC Just{} _) = True isCross (GHC Just{} _) = True isCross _ = False @@ -86,20 +87,22 @@ -- fails. ccFromString :: String -> CCompiler ccFromString "icc" = ICC-ccFromString "gcc" = GCC Nothing+ccFromString "gcc" = GCC Nothing Nothing ccFromString "ccomp" = CompCert ccFromString "clang" = Clang ccFromString "ghc" = GHC Nothing Nothing ccFromString s- | "gcc" `isSuffixOf` s = GCC (Just (reverse . drop 3 . reverse $ s))+ | "gcc" `isSuffixOf` s = GCC (Just (reverse . drop 3 . reverse $ s)) Nothing | "ghc" `isSuffixOf` s = GHC (Just (reverse . drop 3 . reverse $ s)) Nothing | "ghc" `isPrefixOf` s = GHC Nothing (Just (drop 3 s))+ | "gcc" `isPrefixOf` s = GCC Nothing (Just (drop 3 s)) ccFromString _ = Other "cc" -- ALSO consider using Haskell -> C -> ICC ?? -- TODO ICC?? -- | A data type representing the C compiler to be used.-data CCompiler = GCC { _prefix :: Maybe String -- ^ Usually the target triple+data CCompiler = GCC { _prefix :: Maybe String -- ^ Usually the target triple+ , _postfix :: Maybe String -- ^ The compiler version } | Clang | GHC { _prefix :: Maybe String -- ^ The target triple@@ -159,7 +162,7 @@ -> CConfig -> Action r binaryA cc sources out cfg =- need sources >>+ need sources *> (command [EchoStderr False] (ccToString cc) . (("-o" : out : sources) ++) . cconfigToArgs) cfg -- | Generate compiler flags for a given configuration.@@ -177,7 +180,7 @@ -> Rules () dynLibR cc objFiles shLib cfg = shLib %> \out ->- need objFiles >>+ need objFiles *> command [EchoStderr False] (ccToString cc) ("-shared" : "-o" : out : objFiles ++ cconfigToArgs cfg) -- | These rules build an object file from a C source file.@@ -188,7 +191,7 @@ -> Rules () objectFileR cc cfg srcFile objFile = objFile %> \out ->- need [srcFile] >>+ need [srcFile] *> command [EchoStderr False] (ccToString cc) (srcFile : "-c" : "-fPIC" : "-o" : out : cconfigToArgs cfg) sharedLibA :: CmdResult r@@ -198,7 +201,7 @@ -> CConfig -> Action r sharedLibA cc objFiles shrLib _ =- need objFiles >>+ need objFiles *> command mempty (ccToString cc) ("-shared" : "-o" : shrLib : objFiles) staticLibA :: CmdResult r@@ -208,7 +211,7 @@ -> CConfig -> Action r staticLibA ar objFiles stalib _ =- need objFiles >>+ need objFiles *> command mempty (arToString ar) ("rcs" : stalib : objFiles) sharedLibR :: CCompiler