shake-language-c

Utilities for cross-compiling with Shake

https://github.com/samplecount/shake-language-c

Version on this page:0.10.1
LTS Haskell 22.43:0.12.0
Stackage Nightly 2023-12-26:0.12.0
Latest on Hackage:0.12.0

See all snapshots shake-language-c appears in

Apache-2.0 licensed
Maintained by [email protected]
This version can be pinned in stack with:shake-language-c-0.10.1@sha256:13460f56735c4d0306211019ca3d95180b49d0b9cdca980da03d2097b5cda9bf,3031

shake-language-c

Hackage version Stackage LTS Stackage Nightly 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.10.1

  • Add support for Linux ARMv7

v0.10.0

  • Add mkConfig function that caches dependencies

v0.9.1

  • Fix host architecture detection on Windows 10

v0.9.0

  • Add support for the Android arm64-v8a target architecture and drop support for specifying the toolchain version; this API breaking change requires a minimum Android NDK revision 11c

v0.8.6

  • Fix Windows host target
  • Get host architecture from environment on Windows

v0.8.3

  • Allow to set linker command via LD environment variable

v0.8.2

  • Fix compiler and linker commands for Clang toolchain on Linux

v0.8.1

  • Use -I compiler flag for the userIncludes of BuildFlags and -isystem for systemIncludes; semantics should be as before for gcc and clang but -isystem suppresses warnings in system headers

v0.8.0

  • Refactor NMF file creation in NaCl module

v0.7.1

  • Fix compilation error with GHC 7.10 in test suite (#25)

v0.7.0

  • Add arm64 ARM version
  • Add support for arm64 to OSX toolchains
  • Fix compilation error with GHC 7.10 (#25)

v0.6.4

  • Fix Android toolchain definition for x86 architecture

v0.6.3

  • 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.