[llvm] r307256 - Made a script to build docker images easier to use.
Ilya Biryukov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 6 05:46:51 PDT 2017
Author: ibiryukov
Date: Thu Jul 6 05:46:51 2017
New Revision: 307256
URL: http://llvm.org/viewvc/llvm-project?rev=307256&view=rev
Log:
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
Modified:
llvm/trunk/docs/Docker.rst
llvm/trunk/utils/docker/build_docker_image.sh
Modified: llvm/trunk/docs/Docker.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/Docker.rst?rev=307256&r1=307255&r2=307256&view=diff
==============================================================================
--- llvm/trunk/docs/Docker.rst (original)
+++ llvm/trunk/docs/Docker.rst Thu Jul 6 05:46:51 2017
@@ -88,15 +88,11 @@ compiled by the system compiler in the d
./llvm/utils/docker/build_docker_image.sh \
--source debian8 \
--docker-repository clang-debian8 --docker-tag "staging" \
- -- \
-p clang -i install-clang -i install-clang-headers \
-- \
-DCMAKE_BUILD_TYPE=Release
-Note there are two levels of ``--`` indirection. First one separates
-``build_docker_image.sh`` arguments from ``llvm/utils/build_install_llvm.sh``
-arguments. Second one separates CMake arguments from ``build_install_llvm.sh``
-arguments. Note that build like that doesn't use a 2-stage build process that
+Note that a build like that doesn't use a 2-stage build process that
you probably want for clang. Running a 2-stage build is a little more intricate,
this command will do that:
@@ -108,7 +104,6 @@ this command will do that:
./build_docker_image.sh \
--source debian8 \
--docker-repository clang-debian8 --docker-tag "staging" \
- -- \
-p clang -i stage2-install-clang -i stage2-install-clang-headers \
-- \
-DLLVM_TARGETS_TO_BUILD=Native -DCMAKE_BUILD_TYPE=Release \
@@ -178,7 +173,6 @@ debian8-based image using the latest ``g
./llvm/utils/docker/build_docker_image.sh \
-s debian8 --d clang-debian8 -t "staging" \
- -- \
--branch branches/google/stable \
-p clang -i install-clang -i install-clang-headers \
-- \
Modified: llvm/trunk/utils/docker/build_docker_image.sh
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/docker/build_docker_image.sh?rev=307256&r1=307255&r2=307256&view=diff
==============================================================================
--- llvm/trunk/utils/docker/build_docker_image.sh (original)
+++ llvm/trunk/utils/docker/build_docker_image.sh Thu Jul 6 05:46:51 2017
@@ -16,20 +16,37 @@ BUILDSCRIPT_ARGS=""
function show_usage() {
usage=$(cat << EOF
-Usage: build_docker_image.sh [options] [-- [buildscript_args]...]
+Usage: build_docker_image.sh [options] [-- [cmake_args]...]
Available options:
+ General:
+ -h|--help show this help message
+ Docker-specific:
-s|--source image source dir (i.e. debian8, nvidia-cuda, etc)
-d|--docker-repository docker repository for the image
-t|--docker-tag docker tag for the image
-Required options: --source and --docker-repository.
+ LLVM-specific:
+ -b|--branch svn branch to checkout, i.e. 'trunk',
+ 'branches/release_40'
+ (default: 'trunk')
+ -r|--revision svn revision to checkout
+ -p|--llvm-project name of an svn project to checkout. Will also add the
+ project to a list LLVM_ENABLE_PROJECTS, passed to CMake.
+ For clang, please use 'clang', not 'cfe'.
+ Project 'llvm' is always included and ignored, if
+ specified.
+ Can be specified multiple times.
+ -i|--install-target name of a cmake install target to build and include in
+ the resulting archive. Can be specified multiple times.
-All options after '--' are passed to buildscript (see
-scripts/build_install_llvm.sh).
+Required options: --source and --docker-repository, at least one
+ --install-target.
+
+All options after '--' are passed to CMake invocation.
For example, running:
$ build_docker_image.sh -s debian8 -d mydocker/debian8-clang -t latest \
- -- -p clang -i install-clang -i install-clang-headers
+ -p clang -i install-clang -i install-clang-headers
will produce two docker images:
mydocker/debian8-clang-build:latest - an intermediate image used to compile
clang.
@@ -38,13 +55,20 @@ Please note that this example produces a
doesn't override CMake defaults, which produces a Debug and non-boostrapped
version of clang.
-For an example of a somewhat more useful build, search for 2-stage build
-instructions in llvm/docs/Docker.rst.
+To get a 2-stage clang build, you could use this command:
+$ ./build_docker_image.sh -s debian8 -d mydocker/clang-debian8 -t "latest" \
+ -p clang -i stage2-install-clang -i stage2-install-clang-headers \
+ -- \
+ -DLLVM_TARGETS_TO_BUILD=Native -DCMAKE_BUILD_TYPE=Release \
+ -DBOOTSTRAP_CMAKE_BUILD_TYPE=Release \
+ -DCLANG_ENABLE_BOOTSTRAP=ON \
+ -DCLANG_BOOTSTRAP_TARGETS="install-clang;install-clang-headers"
EOF
)
echo "$usage"
}
+SEEN_INSTALL_TARGET=0
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
@@ -66,9 +90,16 @@ while [[ $# -gt 0 ]]; do
DOCKER_TAG="$1"
shift
;;
+ -i|--install-target|-r|--revision|-b|--branch|-p|--llvm-project)
+ if [ "$1" == "-i" ] || [ "$1" == "--install-target" ]; then
+ SEEN_INSTALL_TARGET=1
+ fi
+ BUILDSCRIPT_ARGS="$BUILDSCRIPT_ARGS $1 $2"
+ shift 2
+ ;;
--)
shift
- BUILDSCRIPT_ARGS="$*"
+ BUILDSCRIPT_ARGS="$BUILDSCRIPT_ARGS -- $*"
shift $#
;;
*)
@@ -94,6 +125,11 @@ if [ "$DOCKER_REPOSITORY" == "" ]; then
exit 1
fi
+if [ $SEEN_INSTALL_TARGET -eq 0 ]; then
+ echo "Please provide at least one --install-target"
+ exit 1
+fi
+
cd $(dirname $0)
if [ ! -d $IMAGE_SOURCE ]; then
echo "No sources for '$IMAGE_SOURCE' were found in $PWD"
More information about the llvm-commits
mailing list