]> git.ipfire.org Git - thirdparty/ccache.git/blob - misc/build-in-docker
fix: Don't crash on full disk when recompressing the cache
[thirdparty/ccache.git] / misc / build-in-docker
1 #!/bin/bash
2 #
3 # This script runs ci/build in a Docker container.
4
5 if [ $# -eq 0 ] || [ ${1:-} = -h ] || [ ${1:-} = --help ]; then
6 cat <<EOF
7 Usage: build-in-docker NAME [ARGUMENTS]
8
9 NAME: Subdirectory name in the dockerfiles directory.
10 ARGUMENTS: Arguments that will be passed to ci/build.
11 EOF
12 exit 1
13 fi
14
15 set -eu
16
17 if [ -n "${VERBOSE:-}" ]; then
18 set -x
19 fi
20
21 name=${1}
22 shift
23
24 tag="ccache-build:$name"
25 command="${COMMAND:-/source/ci/build}"
26 interactive="${INTERACTIVE:+--interactive --tty}"
27
28 # Build (if not exists):
29 docker build -t "$tag" "dockerfiles/$name"
30
31 # Cache compilation across docker sessions
32 mkdir -p build-in-docker
33 mkdir -p build-in-docker/docker-ccache
34
35 docker run \
36 --rm \
37 --volume "$PWD:/source" \
38 --volume "$PWD/build-in-docker/docker-ccache:/ccache" \
39 --tmpfs /builddir:rw,exec \
40 --workdir /builddir \
41 --env ASAN_OPTIONS="${ASAN_OPTIONS:-}" \
42 --env EXTRA_CMAKE_BUILD_FLAGS="${EXTRA_CMAKE_BUILD_FLAGS:-}" \
43 --env CC="${CC:-}" \
44 --env CCACHE_DIR=/ccache \
45 --env CCACHE_LOC="/source" \
46 --env CFLAGS="${CFLAGS:-}" \
47 --env CMAKE_PARAMS="${CMAKE_PARAMS:-}" \
48 --env CXX="${CXX:-}" \
49 --env CXXFLAGS="${CXXFLAGS:-}" \
50 --env LDFLAGS="${LDFLAGS:-}" \
51 --env NO_TEST="${NO_TEST:-}" \
52 --env SCAN_BUILD="${SCAN_BUILD:-}" \
53 --env SPECIAL="${SPECIAL:-}" \
54 --env VERBOSE="${VERBOSE:-}" \
55 $interactive \
56 "$tag" \
57 "$command" "$@"