MyNixOS website logo
Description

Utility for building Shake build systems using Cabal sandboxes.

This utility allows to build Shake build systems using Cabal sandboxes. It automatically installs and updates a build system's dependencies, either from Hackage or from a local source directory. See the homepage for more information.

shake-cabal-build

Build systems written in Shake normally need to be compiled, see the Shake manual for more information. shake is a simple Haskell script that takes care of all the details. Using the Cabal infrastructure, build scripts are compiled on the fly for execution and also be reused as library components.

The only prerequisite for running the script is the latest Haskell platform.

Installation and usage

Copy or link the script to your source folder. You can also install shake-cabal-build from Hackage with cabal install. The executable is called shake-cabal-build in order to avoid a clash with a different executable installed by Shake, you can create an alias with a different name if you want.

Write a file shakefile.hs containing Shake rule definitions and create a file shakefile.cabal with the following contents:

Name: hearhearme-shakefile
Version: 0.1.0
Cabal-Version: >= 1.2
Build-Type: Simple

Executable hearhearme-shakefile
  Main-Is: shakefile.hs
  Ghc-Options: -rtsopts -with-rtsopts=-I0
  Build-Depends:
      base == 4.*
    , shake

If you're using shake-language-c, add it to the dependencies as well. Refer to the Cabal manual for more information about configuration file features. cabal init is another way of creating the Cabal file. It can automatically pick up the dependencies referenced from package imports in your shakefile.hs (if it exists already).

./shake .update creates a Cabal sandbox, installs the dependencies and compiles your build system script.

./shake .scrub calls your build script's clean target and removes the Cabal sandbox and all build products.

./shake .init initialises the sandbox and configures your package. This might be necessary sometimes but usually you don't need that command.

Running ./shake with any argument not starting with a . runs your build script with the arguments passed on the command line, usually Shake options and targets to build.

Cabal file extensions

The shake script supports the custom Cabal configuration setting x-shake-package-dirs. It allows to specify Cabal source packages that should be added to the sandbox with cabal add-source, for example:

X-Shake-Package-Dirs:
  external_libraries/methcla/external_libraries/shake
  external_libraries/methcla/external_libraries/shake-language-c
  external_libraries/methcla

Add this setting before the Executable section containing your build script. See here for an example of a production configuration file that also exports a library.

Tips and tricks

Since Shake includes some high-level profiling features, usually you don't need to do low-level profiling of the build system. Creating a file cabal.config in the top source directory with a line

Library-Profiling: False

can significantly decrease the time needed for updating the build system.

Metadata

Version

0.1.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows