)
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
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)
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}
-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
)
# 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()