shake-ext 2.8.0.0 → 2.9.0.1
raw patch · 3 files changed
+29/−7 lines, 3 files
Files
- shake-ext.cabal +1/−1
- src/Development/Shake/C.hs +27/−5
- src/Development/Shake/Version.hs +1/−1
shake-ext.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: shake-ext-version: 2.8.0.0+version: 2.9.0.1 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2018 Vanessa McHale
src/Development/Shake/C.hs view
@@ -13,9 +13,11 @@ , cBin , cToLib -- * Actions+ , pkgConfig , binaryA , staticLibA , sharedLibA+ , stripA -- * Helper functions , cconfigToArgs , ccToString@@ -31,6 +33,15 @@ import System.Directory (removeFile) import System.Info +-- cmake?? make (??)++-- | Given a package name or path to a @.pc@ file, output flags for C compiler.+pkgConfig :: String -> Action [String]+pkgConfig pkg = do+ (Stdout o) <- command [] "pkg-config" ["--cflags", pkg]+ (Stdout o') <- command [] "pkg-config" ["--libs", pkg]+ pure (words o <> words o')+ -- | Given C source code, return a list of included files. This writes to a file -- and then makes a call to either @clang@ or @gcc@, so it should be used -- sparingly.@@ -71,6 +82,11 @@ ccToString (GHC pre suff) = mkQualified pre suff "ghc" ccToString CompCert = "ccomp" +stripToString :: CCompiler -> String+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 (GHC pre _) = mkQualified pre Nothing "ar"@@ -132,13 +148,19 @@ -> Rules () cBin cc sources bin cfg = bin %> \out -> binaryA cc sources out cfg +stripA :: CmdResult r+ => FilePath -- ^ Build product to be stripped+ -> CCompiler -- ^ C compiler+ -> Action r+stripA out cc = command mempty (stripToString cc) [out]+ -- | This action builds an executable. binaryA :: CmdResult r- => CCompiler- -> [FilePath] -- ^ Source files- -> FilePath -- ^ Executable output- -> CConfig- -> Action r+ => CCompiler+ -> [FilePath] -- ^ Source files+ -> FilePath -- ^ Executable output+ -> CConfig+ -> Action r binaryA cc sources out cfg = need sources >> (command [EchoStderr False] (ccToString cc) . (("-o" : out : sources) <>) . cconfigToArgs) cfg
src/Development/Shake/Version.hs view
@@ -12,6 +12,6 @@ ghcVersion :: Action String ghcVersion = do ~(Stdout o) <- command mempty "ghc" ["--numeric-version"]- pure o+ pure (head (lines o)) $(mkVersions ["pandoc", "cabal"])