Skip to content

Commit

Permalink
Separate image creation and Haskell cache build
Browse files Browse the repository at this point in the history
Signed-off-by: Hannu Lyytinen <[email protected]>
  • Loading branch information
hlyytine committed Jul 13, 2023
1 parent 9996183 commit 923b455
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ all:
DOCKER_EXPORT = CAMKES_VM_APP
export DOCKER_EXPORT

build_cache:
@scripts/build_cache.sh

build_camkes: .config
@scripts/build_camkes.sh

Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ host% <b>echo 'export YOCTO_SOURCE_MIRROR_DIR='${YOCTO_SOURCE_MIRROR_DIR} >> ~/.
host% <b>mkdir ${YOCTO_SOURCE_MIRROR_DIR}</b>
</pre>

## Configure build cache directory

Compiling Haskell packages takes quite a long time, several minutes on a power machine.
The ```make``` equivalent, ```stack```, is able to cache the build results and because the
Haskell sources stay the same for most of the time (versions used are configured in
```capdl.git```), it is advisable to export a host directory to container to store
the cached build results across containers. Note that for CI purposes you need to judge
yourself when to enable the cache.

<pre>
host% <b>export BUILD_CACHE_DIR=~/.tii_sel4_build</b>
host% <b>echo 'export BUILD_CACHE_DIR='${BUILD_CACHE_DIR} >> ~/.bashrc</b>
host% <b>mkdir ${BUILD_CACHE_DIR}</b>
</pre>

## Check out sources
<pre>
# Choose a working directory, this will be visible in the container at /workspace
Expand All @@ -87,6 +102,11 @@ host% <b>repo sync</b>
host% <b>make docker</b>
</pre>

## Prepopulate build cache
<pre>
host% <b>make build_cache</b>
</pre>

## Use it!

<pre>
Expand Down
12 changes: 0 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@ RUN pip3 install \
pyfdt \
pyyaml

# Let's build all the capdl's dependencies. Downloading, compiling and
# installing the correct GHC version and all of the dependencies takes
# lots of time and we don't want to redo that everytime we restart the
# container.

RUN \
git clone https://github.com/seL4/capdl.git /home/build/capdl && \
cd /home/build/capdl/capDL-tool && \
stack build --only-dependencies && \
cd /home/build && \
rm -rf /home/build/capdl

ENV WORKSPACE=/workspace

WORKDIR /workspace
1 change: 1 addition & 0 deletions docker/enter_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ exec ${CONTAINER_ENGINE} run --rm ${INTERACTIVE} \
-v "${DIR}:/workspace:z" \
${YOCTO_SOURCE_MIRROR_DIR:+--env YOCTO_SOURCE_MIRROR_DIR=/workspace/downloads} \
${YOCTO_SOURCE_MIRROR_DIR:+-v "${YOCTO_SOURCE_MIRROR_DIR}":/workspace/downloads:z} \
${BUILD_CACHE_DIR:+-v "${BUILD_CACHE_DIR}"/stack:/home/build/.stack:z} \
-v "${HOME}/.ssh:/home/build/.ssh:z" \
-v "${HOME}/.gitconfig:/home/build/.gitconfig:z" \
${CONTAINER_ENGINE_OPTS} \
Expand Down
13 changes: 13 additions & 0 deletions scripts/build_cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/sh

set -e

. ${0%/*}/functions.sh

TMPDIR=`mktemp -d ${HOME}/capdl.XXXXXX`

git clone https://github.com/seL4/capdl.git ${TMPDIR}/capdl
cd ${TMPDIR}/capdl/capDL-tool
stack build --only-dependencies
cd ${HOME}
rm -rf ${TMPDIR}

0 comments on commit 923b455

Please sign in to comment.