Skip to content

Commit db233bc

Browse files
committed
Hook new build into existing Swift project
Setting `SWIFT_ENABLE_NEW_RUNTIME_BUILD` to `ON` will build and run the new standard library build in addition to using the old build. This is primarily for basic smoke testing at the moment. Once we're confident, we can start running tests against the stdlib built with the new build system. The mechanism will build the stdlib for each of the same platforms that the old build system would build for, but emitting a separate build directory with a separate CMake invocation for each configuration. This will use the just-built compiler if the compiler was not cross-compiled. If the compiler were cross-compiled, it will use the compiler from the toolchain that is known to work on the builder.
1 parent e2b878b commit db233bc

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,3 +1579,45 @@ if(XCODE)
15791579
add_custom_target(Miscellaneous
15801580
SOURCES ${SWIFT_TOPLEVEL_HEADERS})
15811581
endif()
1582+
1583+
# New standard library build
1584+
option(SWIFT_ENABLE_NEW_RUNTIME_BUILD "Build Swift runtimes with new build system" OFF)
1585+
if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
1586+
foreach(sdk ${SWIFT_SDKS})
1587+
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
1588+
# Provide a mechanism to skip building one of these runtimes
1589+
if(SWIFT_SKIP_${sdk}_${arch}_RUNTIME)
1590+
message(STATUS "Skipping: ${arch}-${sdk} runtime build")
1591+
continue()
1592+
endif()
1593+
set(stdlib_target "swift-stdlib-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
1594+
if(${SWIFT_SDK_${sdk}_${arch}_CACHE})
1595+
set(stdlib_cache_file_flag -C ${SWIFT_SDK_${sdk}_${arch}_CACHE})
1596+
endif()
1597+
ExternalProject_Add("${stdlib_target}-core"
1598+
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Core"
1599+
# TODO: Add this once we're ready to start swapping out the libraries
1600+
# for testing
1601+
# INSTALL_DIR "${CMAKE_BINARY_DIR}/"
1602+
CMAKE_ARGS
1603+
-DCMAKE_INSTALL_LIBDIR:FILEPATH=lib/swift/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}
1604+
# Compiler will see mismatched swift modules and fail initial checks
1605+
-DCMAKE_Swift_COMPILER_WORKS:BOOLEAN=YES
1606+
-DBUILD_SHARED_LIBS:BOOLEAN=YES # TODO: Make this configurable
1607+
${stdlib_cache_file_flag}
1608+
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
1609+
-DCMAKE_INSTALL_PREFIX:FILEPATH=<INSTALL_DIR>
1610+
-DCMAKE_Swift_COMPILER:FILEPATH=$<IF:$<BOOL:${CMAKE_CROSSCOMPILING}>,${CMAKE_Swift_COMPILER},$<PATH:REPLACE_FILENAME,$<TARGET_FILE:swift-frontend>,swiftc>>
1611+
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
1612+
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
1613+
-DCMAKE_COLOR_DIAGNOSTICS:BOOLEAN=${CMAKE_COLOR_DIAGNOSTICS})
1614+
if(NOT ${CMAKE_CROSSCOMPILING})
1615+
add_dependencies("${stdlib_target}" swift-frontend)
1616+
endif()
1617+
endforeach()
1618+
endforeach()
1619+
1620+
# Materialize sources in the new build
1621+
execute_process(COMMAND
1622+
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Resync.cmake")
1623+
endif()

0 commit comments

Comments
 (0)