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