]> granicus.if.org Git - clang/commitdiff
[CMake] Add support for specifying arguments to the bootstrap build.
authorChris Bieneman <beanz@apple.com>
Fri, 20 Nov 2015 22:09:06 +0000 (22:09 +0000)
committerChris Bieneman <beanz@apple.com>
Fri, 20 Nov 2015 22:09:06 +0000 (22:09 +0000)
This adds support for three types of argument specifications for bootstrap builds:

(1) Arguments prefixed with BOOTSTRAP_* will be passed through with the leading BOOTSTRAP_ removed.
(2) CLANG_BOOTSTRAP_PASSTHROUGH can specify a list of variables to be passed through as they are set.
(3) BOOTSTRAP_DEFAULT_PASSTHROUGH is a list of some default passthrough variables that are always passed through. Those variables include the version string and should only specify variables that are always expected to be the same between the stage1 and stage2

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253721 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt

index bbc87510de3931e41b1d8cfd74e3feafe8433f78..bddc25034b8474e0d298dacac5b975ec105eb7f9 100644 (file)
@@ -652,6 +652,36 @@ if (CLANG_ENABLE_BOOTSTRAP)
     set(verbose -DCMAKE_VERBOSE_MAKEFILE=On)
   endif()
 
+  set(BOOTSTRAP_DEFAULT_PASSTHROUGH
+    PACKAGE_VERSION
+    LLVM_VERSION_MAJOR
+    LLVM_VERSION_MINOR
+    LLVM_VERSION_PATCH
+    LLVM_VERSION_SUFFIX
+    CLANG_REPOSITORY_STRING
+    CMAKE_MAKE_PROGRAM)
+
+  # Find all variables that start with BOOTSTRAP_ and populate a variable with
+  # them.
+  get_cmake_property(variableNames VARIABLES)
+  foreach(varaibleName ${variableNames})
+    if(varaibleName MATCHES "^BOOTSTRAP_")
+      string(SUBSTRING ${varaibleName} 10 -1 varName)
+      string(REPLACE ";" "\;" value "${${varaibleName}}")
+      list(APPEND PASSTHROUGH_VARIABLES
+        -D${varName}=${value})
+    endif()
+  endforeach()
+
+  # Populate the passthrough variables
+  foreach(varaibleName ${CLANG_BOOTSTRAP_PASSTHROUGH} ${BOOTSTRAP_DEFAULT_PASSTHROUGH})
+    if(${varaibleName})
+      string(REPLACE ";" "\;" value ${${varaibleName}})
+      list(APPEND PASSTHROUGH_VARIABLES
+        -D${varaibleName}=${value})
+    endif()
+  endforeach()
+
   ExternalProject_Add(bootstrap
     DEPENDS clang ${LTO_DEP}
     PREFIX bootstrap
@@ -664,6 +694,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
                 # seem to work, so instead I'm passing this through
                 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
                 ${CLANG_BOOTSTRAP_CMAKE_ARGS}
+                ${PASSTHROUGH_VARIABLES}
                 -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
                 -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
                 -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang