summaryrefslogtreecommitdiff
path: root/utils/docker
diff options
context:
space:
mode:
Diffstat (limited to 'utils/docker')
-rwxr-xr-xutils/docker/build_docker_image.sh54
-rwxr-xr-xutils/docker/scripts/build_install_llvm.sh12
2 files changed, 54 insertions, 12 deletions
diff --git a/utils/docker/build_docker_image.sh b/utils/docker/build_docker_image.sh
index 2ec07ab6da4b..33f690ad5c43 100755
--- a/utils/docker/build_docker_image.sh
+++ b/utils/docker/build_docker_image.sh
@@ -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.
-
-All options after '--' are passed to buildscript (see
-scripts/build_install_llvm.sh).
+ 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.
+
+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.
@@ -37,12 +54,21 @@ will produce two docker images:
Please note that this example produces a not very useful installation, since it
doesn't override CMake defaults, which produces a Debug and non-boostrapped
version of clang.
-For an example of a somewhat more useful build, see build_clang_image.sh.
+
+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)
@@ -64,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 $#
;;
*)
@@ -92,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"
diff --git a/utils/docker/scripts/build_install_llvm.sh b/utils/docker/scripts/build_install_llvm.sh
index 7e0e90657416..aef4e0cbca2c 100755
--- a/utils/docker/scripts/build_install_llvm.sh
+++ b/utils/docker/scripts/build_install_llvm.sh
@@ -65,6 +65,7 @@ while [[ $# -gt 0 ]]; do
-r|--revision)
shift
LLVM_SVN_REV="$1"
+ shift
;;
-b|--branch)
shift
@@ -79,7 +80,10 @@ while [[ $# -gt 0 ]]; do
fi
if ! contains_project "$PROJ" ; then
LLVM_PROJECTS="$LLVM_PROJECTS $PROJ"
- CMAKE_LLVM_ENABLE_PROJECTS="$CMAKE_LLVM_ENABLED_PROJECTS;$PROJ"
+ if [ "$CMAKE_LLVM_ENABLE_PROJECTS" != "" ]; then
+ CMAKE_LLVM_ENABLE_PROJECTS="$CMAKE_LLVM_ENABLE_PROJECTS;"
+ fi
+ CMAKE_LLVM_ENABLE_PROJECTS="$CMAKE_LLVM_ENABLED_PROJECTS$PROJ"
else
echo "Project '$PROJ' is already enabled, ignoring extra occurences."
fi
@@ -135,7 +139,7 @@ for LLVM_PROJECT in $LLVM_PROJECTS; do
SVN_PROJECT="$LLVM_PROJECT"
fi
- echo "Checking out http://llvm.org/svn/llvm-project/$SVN_PROJECT to $CLANG_BUILD_DIR/src/$LLVM_PROJECT"
+ echo "Checking out https://llvm.org/svn/llvm-project/$SVN_PROJECT to $CLANG_BUILD_DIR/src/$LLVM_PROJECT"
# FIXME: --trust-server-cert is required to workaround 'SSL issuer is not
# trusted' error. Using https seems preferable to http either way,
# albeit this is not secure.
@@ -144,11 +148,11 @@ for LLVM_PROJECT in $LLVM_PROJECTS; do
"$CLANG_BUILD_DIR/src/$LLVM_PROJECT"
done
-pushd "$CLANG_BUILD_DIR"
+mkdir "$CLANG_BUILD_DIR/build"
+pushd "$CLANG_BUILD_DIR/build"
# Run the build as specified in the build arguments.
echo "Running build"
-mkdir "$CLANG_BUILD_DIR/build"
cmake -GNinja \
-DCMAKE_INSTALL_PREFIX="$CLANG_INSTALL_DIR" \
-DLLVM_ENABLE_PROJECTS="$CMAKE_LLVM_ENABLE_PROJECTS" \