haskell: use stack to obtain suitable GHC and cabal

This commit is contained in:
Matthew Brecknell 2017-02-01 17:14:31 +11:00
parent 7a8f2b8980
commit aee13996a6
6 changed files with 62 additions and 10 deletions

View File

@ -51,6 +51,7 @@ internal/*
spec/haskell/cabal.sandbox.config
spec/haskell/.cabal-sandbox/*
spec/haskell/.stack-work/*
spec/haskell/Setup.hs
spec/haskell/configure
spec/haskell/dist/*

View File

@ -16,5 +16,6 @@
# cabal dependencies
/.stack-work/
/.cabal-sandbox/
/cabal.sandbox.config

View File

@ -10,28 +10,48 @@
BOOT_MODULES = Kernel/CSpace Kernel/Thread Kernel/FaultHandler \
Kernel/VSpace Kernel/Init Model/PSpace Object/TCB Object/CNode \
Kernel/VSpace Kernel/Init Model/PSpace Object/TCB Object/CNode \
Object/ObjectType Object/Endpoint Object/Interrupt
BOOT_FILES=$(BOOT_MODULES:%=src/SEL4/%.lhs-boot)
GHC=ghc
# We use the cabal executable that we installed via stack,
# and use the PATH from `stack exec` to find it.
# However, cabal refuses to run when the GHC_PACKAGE_PATH
# variable is set, so we use `stack-path` to clear
# GHC_PACKAGE_PATH first.
CABAL=stack exec -- ./stack-path cabal
all: build pdf
build: $(BOOT_FILES)
cabal sandbox init
cabal install --dependencies-only -w "$(GHC)"
cabal configure --configure-option="arm-kzm" -w "$(GHC)"
cabal build
build: .stack-work $(BOOT_FILES)
$(CABAL) sandbox init
$(CABAL) install --dependencies-only
$(CABAL) configure --configure-option="arm-kzm"
$(CABAL) build
pdf:
cd doc && make
# We assume that if the .stack-work directory exists,
# we don't need to install ghc, cabal, nor fetch the cabal
# package database.
# We make this assumption to avoid hitting the network on
# every build.
# However, this means that if .stack-work exists, but the
# cabal package database is missing, the build will fail.
.stack-work:
stack --install-ghc build cabal-install
$(CABAL) update
%.lhs-boot: %.lhs mkhsboot.pl
perl mkhsboot.pl -l < $< > $@
clean:
rm -f $(BOOT_FILES)
cabal clean
$(CABAL) clean
.PHONY: all build pdf clean
realclean:
rm -rf $(BOOT_FILES) dist .stack-work .cabal-sandbox cabal.sandbox.config
.PHONY: all build pdf clean realclean

View File

@ -8,7 +8,7 @@
-- @TAG(GD_GPL)
--
name: SEL4-ARM
name: SEL4
version: 1.4-pre
cabal-version: >= 1.18
build-type: Custom

15
spec/haskell/stack-path Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
# Copyright 2017, Data61, CSIRO
#
# This software may be distributed and modified according to the terms of
# the GNU General Public License version 2. Note that NO WARRANTY is provided.
# See "LICENSE_GPLv2.txt" for details.
#
# @TAG(DATA61_GPL)
# Running cabal inside `stack exec` fails, because older versions of cabal
# refuse to run with GHC_PACKAGE_PATH set.
unset GHC_PACKAGE_PATH
exec "$@"

15
spec/haskell/stack.yaml Normal file
View File

@ -0,0 +1,15 @@
# Copyright 2017, Data61, CSIRO
#
# This software may be distributed and modified according to the terms of
# the GNU General Public License version 2. Note that NO WARRANTY is provided.
# See "LICENSE_GPLv2.txt" for details.
#
# @TAG(DATA61_GPL)
resolver: lts-2.22
packages: []
extra-deps: []
flags: {}
extra-package-dbs: []