llvm.org GIT mirror llvm / 45bbe61
Made a script to build docker images easier to use. Summary: - Removed double indirection via command-line args (i.e. two `--` options of `build_docker_image.sh`). - Added a comment on how to build 2-stage clang install into the `build_docker_image.sh`, it used to be only in the `docs/Docker.rst`. Reviewers: klimek, mehdi_amini Reviewed By: klimek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35050 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307256 91177308-0d34-0410-b5e6-96231b3b80d8 Ilya Biryukov 2 years ago
2 changed file(s) with 45 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
8787 ./llvm/utils/docker/build_docker_image.sh \
8888 --source debian8 \
8989 --docker-repository clang-debian8 --docker-tag "staging" \
90 -- \
9190 -p clang -i install-clang -i install-clang-headers \
9291 -- \
9392 -DCMAKE_BUILD_TYPE=Release
9493
95 Note there are two levels of ``--`` indirection. First one separates
96 ``build_docker_image.sh`` arguments from ``llvm/utils/build_install_llvm.sh``
97 arguments. Second one separates CMake arguments from ``build_install_llvm.sh``
98 arguments. Note that build like that doesn't use a 2-stage build process that
94 Note that a build like that doesn't use a 2-stage build process that
9995 you probably want for clang. Running a 2-stage build is a little more intricate,
10096 this command will do that:
10197
107103 ./build_docker_image.sh \
108104 --source debian8 \
109105 --docker-repository clang-debian8 --docker-tag "staging" \
110 -- \
111106 -p clang -i stage2-install-clang -i stage2-install-clang-headers \
112107 -- \
113108 -DLLVM_TARGETS_TO_BUILD=Native -DCMAKE_BUILD_TYPE=Release \
177172
178173 ./llvm/utils/docker/build_docker_image.sh \
179174 -s debian8 --d clang-debian8 -t "staging" \
180 -- \
181175 --branch branches/google/stable \
182176 -p clang -i install-clang -i install-clang-headers \
183177 -- \
1515
1616 function show_usage() {
1717 usage=$(cat << EOF
18 Usage: build_docker_image.sh [options] [-- [buildscript_args]...]
18 Usage: build_docker_image.sh [options] [-- [cmake_args]...]
1919
2020 Available options:
21 General:
22 -h|--help show this help message
23 Docker-specific:
2124 -s|--source image source dir (i.e. debian8, nvidia-cuda, etc)
2225 -d|--docker-repository docker repository for the image
2326 -t|--docker-tag docker tag for the image
24 Required options: --source and --docker-repository.
27 LLVM-specific:
28 -b|--branch svn branch to checkout, i.e. 'trunk',
29 'branches/release_40'
30 (default: 'trunk')
31 -r|--revision svn revision to checkout
32 -p|--llvm-project name of an svn project to checkout. Will also add the
33 project to a list LLVM_ENABLE_PROJECTS, passed to CMake.
34 For clang, please use 'clang', not 'cfe'.
35 Project 'llvm' is always included and ignored, if
36 specified.
37 Can be specified multiple times.
38 -i|--install-target name of a cmake install target to build and include in
39 the resulting archive. Can be specified multiple times.
2540
26 All options after '--' are passed to buildscript (see
27 scripts/build_install_llvm.sh).
41 Required options: --source and --docker-repository, at least one
42 --install-target.
43
44 All options after '--' are passed to CMake invocation.
2845
2946 For example, running:
3047 $ build_docker_image.sh -s debian8 -d mydocker/debian8-clang -t latest \
31 -- -p clang -i install-clang -i install-clang-headers
48 -p clang -i install-clang -i install-clang-headers
3249 will produce two docker images:
3350 mydocker/debian8-clang-build:latest - an intermediate image used to compile
3451 clang.
3754 doesn't override CMake defaults, which produces a Debug and non-boostrapped
3855 version of clang.
3956
40 For an example of a somewhat more useful build, search for 2-stage build
41 instructions in llvm/docs/Docker.rst.
57 To get a 2-stage clang build, you could use this command:
58 $ ./build_docker_image.sh -s debian8 -d mydocker/clang-debian8 -t "latest" \
59 -p clang -i stage2-install-clang -i stage2-install-clang-headers \
60 -- \
61 -DLLVM_TARGETS_TO_BUILD=Native -DCMAKE_BUILD_TYPE=Release \
62 -DBOOTSTRAP_CMAKE_BUILD_TYPE=Release \
63 -DCLANG_ENABLE_BOOTSTRAP=ON \
64 -DCLANG_BOOTSTRAP_TARGETS="install-clang;install-clang-headers"
4265 EOF
4366 )
4467 echo "$usage"
4568 }
4669
70 SEEN_INSTALL_TARGET=0
4771 while [[ $# -gt 0 ]]; do
4872 case "$1" in
4973 -h|--help)
6589 DOCKER_TAG="$1"
6690 shift
6791 ;;
92 -i|--install-target|-r|--revision|-b|--branch|-p|--llvm-project)
93 if [ "$1" == "-i" ] || [ "$1" == "--install-target" ]; then
94 SEEN_INSTALL_TARGET=1
95 fi
96 BUILDSCRIPT_ARGS="$BUILDSCRIPT_ARGS $1 $2"
97 shift 2
98 ;;
6899 --)
69100 shift
70 BUILDSCRIPT_ARGS="$*"
101 BUILDSCRIPT_ARGS="$BUILDSCRIPT_ARGS -- $*"
71102 shift $#
72103 ;;
73104 *)
90121
91122 if [ "$DOCKER_REPOSITORY" == "" ]; then
92123 echo "Required argument missing: --docker-repository"
124 exit 1
125 fi
126
127 if [ $SEEN_INSTALL_TARGET -eq 0 ]; then
128 echo "Please provide at least one --install-target"
93129 exit 1
94130 fi
95131