Author: cbieneman Date: Wed Dec 16 14:17:07 2015 New Revision: 255813 URL: http://llvm.org/viewvc/llvm-project?rev=255813&view=rev Log: [CMake] Name the bootstrap stages stage[0-9]
When you start chaining bootstrap stages the CMake-generated targets get unwieldy. This change supports naming the bootstrap targets and creating wrapper targets in the top-level build file. Without this patch the default target generated for a second stage build was "bootstrap" with it the target is "stage2". Also with some CMake goop setting CLANG_BOOTSTRAP_TARGETS, you can expose third stage targets as "stage3" instead of "bootstrap-bootstrap" Modified: cfe/trunk/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=255813&r1=255812&r2=255813&view=diff ============================================================================== --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Wed Dec 16 14:17:07 2015 @@ -623,9 +623,24 @@ if (CLANG_ENABLE_BOOTSTRAP) ) set(cmake_3_4_USES_TERMINAL USES_TERMINAL 1) endif() + + if(NOT CLANG_STAGE) + set(CLANG_STAGE stage1) + message(STATUS "Setting current clang stage to: ${CLANG_STAGE}") + endif() + + string(REGEX MATCH "stage([0-9]*)" MATCHED_STAGE "${CLANG_STAGE}") + if(MATCHED_STAGE) + math(EXPR STAGE_NUM "${MATCHED_STAGE} + 1") + set(NEXT_CLANG_STAGE stage${STAGE_NUM}) + else() + set(NEXT_CLANG_STAGE bootstrap) + endif() + message(STATUS "Setting next clang stage to: ${NEXT_CLANG_STAGE}") - set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-stamps/) - set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-bins/) + + set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/) + set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/) # If on Darwin we need to make bootstrap depend on LTO and pass # DARWIN_LTO_LIBRARY so that -flto will work using the just-built compiler @@ -636,17 +651,17 @@ if (CLANG_ENABLE_BOOTSTRAP) set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib) endif() - add_custom_target(bootstrap-clear - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared + add_custom_target(${NEXT_CLANG_STAGE}-clear + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared ) add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared DEPENDS clang ${LTO_DEP} COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${STAMP_DIR} - COMMENT "Clobberring bootstrap build and stamp directories" + COMMENT "Clobberring ${NEXT_CLANG_STAGE} build and stamp directories" ) if(CMAKE_VERBOSE_MAKEFILE) @@ -687,9 +702,9 @@ if (CLANG_ENABLE_BOOTSTRAP) endif() endforeach() - ExternalProject_Add(bootstrap + ExternalProject_Add(${NEXT_CLANG_STAGE} DEPENDS clang ${LTO_DEP} ${RUNTIME_DEP} - PREFIX bootstrap + PREFIX ${NEXT_CLANG_STAGE} SOURCE_DIR ${CMAKE_SOURCE_DIR} STAMP_DIR ${STAMP_DIR} BINARY_DIR ${BINARY_DIR} @@ -703,6 +718,7 @@ if (CLANG_ENABLE_BOOTSTRAP) -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++ -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang + -DCLANG_STAGE=${NEXT_CLANG_STAGE} ${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB} ${verbose} INSTALL_COMMAND "" STEP_TARGETS configure build @@ -710,29 +726,34 @@ if (CLANG_ENABLE_BOOTSTRAP) ) # exclude really-install from main target - set_target_properties(bootstrap PROPERTIES _EP_really-install_EXCLUDE_FROM_MAIN On) - ExternalProject_Add_Step(bootstrap really-install + set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES _EP_really-install_EXCLUDE_FROM_MAIN On) + ExternalProject_Add_Step(${NEXT_CLANG_STAGE} really-install COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target install - COMMENT "Performing install step for 'bootstrap'" + COMMENT "Performing install step for '${NEXT_CLANG_STAGE}'" DEPENDEES build ${cmake_3_4_USES_TERMINAL} ) - ExternalProject_Add_StepTargets(bootstrap really-install) - add_custom_target(bootstrap-install DEPENDS bootstrap-really-install) + ExternalProject_Add_StepTargets(${NEXT_CLANG_STAGE} really-install) + add_custom_target(${NEXT_CLANG_STAGE}-install DEPENDS ${NEXT_CLANG_STAGE}-really-install) if(NOT CLANG_BOOTSTRAP_TARGETS) set(CLANG_BOOTSTRAP_TARGETS check-llvm check-clang check-all) endif() foreach(target ${CLANG_BOOTSTRAP_TARGETS}) # exclude from main target - set_target_properties(bootstrap PROPERTIES _EP_${target}_EXCLUDE_FROM_MAIN On) + set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES _EP_${target}_EXCLUDE_FROM_MAIN On) - ExternalProject_Add_Step(bootstrap ${target} + ExternalProject_Add_Step(${NEXT_CLANG_STAGE} ${target} COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target ${target} - COMMENT "Performing ${target} for 'bootstrap'" + COMMENT "Performing ${target} for '${NEXT_CLANG_STAGE}'" DEPENDEES configure ${cmake_3_4_USES_TERMINAL} ) - ExternalProject_Add_StepTargets(bootstrap ${target}) + + if(target MATCHES "^stage[0-9]*") + add_custom_target(${target} DEPENDS ${NEXT_CLANG_STAGE}-${target}) + endif() + + ExternalProject_Add_StepTargets(${NEXT_CLANG_STAGE} ${target}) endforeach() endif() _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits