2 #===- llvm/utils/docker/scripts/build_install_llvm.sh ---------------------===//
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 #===-----------------------------------------------------------------------===//
12 function show_usage
() {
14 Usage: build_install_llvm.sh [options] -- [cmake-args]
16 Run cmake with the specified arguments. Used inside docker container.
17 Passes additional -DCMAKE_INSTALL_PREFIX and puts the build results into
18 the directory specified by --to option.
21 -h|--help show this help message
22 -i|--install-target name of a cmake install target to build and include in
23 the resulting archive. Can be specified multiple times.
24 --to destination directory where to install the targets.
25 Required options: --to, at least one --install-target.
27 All options after '--' are passed to CMake invocation.
32 CMAKE_INSTALL_TARGETS
=""
35 while [[ $# -gt 0 ]]; do
39 CMAKE_INSTALL_TARGETS
="$CMAKE_INSTALL_TARGETS $1"
44 CLANG_INSTALL_DIR
="$1"
57 echo "Unknown option: $1"
62 if [ "$CMAKE_INSTALL_TARGETS" == "" ]; then
63 echo "No install targets. Please pass one or more --install-target."
67 if [ "$CLANG_INSTALL_DIR" == "" ]; then
68 echo "No install directory. Please specify the --to argument."
72 CLANG_BUILD_DIR
=/tmp
/clang-build
74 mkdir
-p "$CLANG_INSTALL_DIR"
76 mkdir
-p "$CLANG_BUILD_DIR/build"
77 pushd "$CLANG_BUILD_DIR/build"
79 # Run the build as specified in the build arguments.
82 -DCMAKE_INSTALL_PREFIX="$CLANG_INSTALL_DIR" \
84 "$CLANG_BUILD_DIR/src/llvm"
85 ninja
$CMAKE_INSTALL_TARGETS
90 rm -rf "$CLANG_BUILD_DIR/build"