Apache-2.0 licensed
Maintained by [email protected]
This version can be pinned in stack with:shake-language-c-0.6.4@sha256:7a97dab9a8e55e607c71a98220a4b44c20cc3fc74afa46c076cd33b7966c219a,3033

shake-language-c

Build Status

shake-language-c is a cross-platform build system based on the Shake Haskell library. The focus is on cross-compilation of C, C++ and Objective C source code to various target platforms. Currently supported target platforms are iOS, Android NDK, Google Portable Native Client, MacOS X, Linux and Windows (MinGW). Supported host platforms are MacOS X, Linux and Windows.

Documentation

Please see the package documentation. Feel free to open an issue or send a pull request if there’s anything missing that you want to see covered.

Examples

Here’s an iOS example that compiles all .cpp files in the src directory. The resulting static library libexample.a can then be used e.g. from an XCode project.

import Control.Applicative
import Control.Arrow
import Development.Shake
import Development.Shake.FilePath
import Development.Shake.Language.C
import qualified Development.Shake.Language.C.Target.OSX as OSX

main :: IO ()
main = shakeArgs shakeOptions { shakeFiles = "build/" } $ do
  let target = OSX.target OSX.iPhoneOS (Arm Armv7s)
      toolChain = OSX.toolChain
                    <$> OSX.getSDKRoot
                    <*> (maximum <$> OSX.getPlatformVersions (targetPlatform target))
                    <*> pure target

  lib <- staticLibrary toolChain
          ("build" </> toBuildPrefix target </> "libexample.a")
          (return $ 
               append compilerFlags [(Just Cpp, ["-std=c++11"])]
           >>> append compilerFlags [(Nothing, ["-O3"])]
           >>> append userIncludes ["include"] )
          (getDirectoryFiles "" ["src//*.cpp"])

  want [lib]

A more complex build script is used by the Methcla sound engine library. It defines Shake rules for building the library on various platforms and also exports functions for transparently including the library into other build systems. The build script makes extensive use of Shake configuration files.

Changes

Changelog for shake-language-c

v0.6.4

  • Fix Android toolchain definition for x86 architecture

v0.6.3

Changed

  • Fix bug in Development.Shake.Language.C.Target.OSX: getPlatformVersionsWithRoot works correctly now with SDK directories without version number, as introduced by Xcode 6

v0.6.2

Bug fix release.

v0.6.1

Bug fix release.

v0.6.0

Added

  • Add Data.Default.Class.Default instances for some data types; add dependency on package data-default-class.

Changed

  • Don’t export the entire module Development.Shake.Language.C.ToolChain from Development.Shake.Language.C; expose Development.Shake.Language.C.ToolChain for toolchain writers.
  • Export Development.Shake.Language.C.Language.Language from Development.Shake.Language.C.BuildFlags instead of Development.Shake.Language.C.
  • Export Development.Shake.Language.C.Rules from Development.Shake.Language.C; hide Development.Shake.Language.C.Rules in Cabal file.
  • Android: Add libcxxabi include directory instead of gabi++ to include path when compiling with libcxx. Fixes error: no member named '__cxa_demangle' in namespace '__cxxabiv1'.

Removed

  • Remove libppapi, libppapi_cpp, libnacl_io, libppapi_simple from Development.Shake.Language.C.Target.NaCl.
  • Remove Development.Shake.Language.C.Target.archString.

v0.5.0

First released version.