-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically build FoundationMacros for local CMake builds #844
Conversation
@swift-ci please test |
Full toolchain tests which cover the CMake changes passed in the linked PR |
message(STATUS "SwiftFoundation_MACRO not provided, building Foundation macros locally for host") | ||
# No path to Foundation macros was provided, so we must build it ourselves | ||
set(FoundationMacros_BuildLocalExecutable YES) | ||
FetchContent_Declare(FoundationMacros |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macros should build through ExternalProject. If we are cross-compiling Foundation, these macros will get built for the machine that we are cross-compiling to instead of the machine running the build, and therefore will not be usable.
# No path to Foundation macros was provided, so we must build it ourselves | ||
set(FoundationMacros_BuildLocalExecutable YES) | ||
FetchContent_Declare(FoundationMacros | ||
SOURCE_DIR ${CMAKE_SOURCE_DIR}/Sources/FoundationMacros) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't CMAKE_SOURCE_DIR
be the swift-corelibs-foundation
when this project is added as an external project from there? Would ${CMAKE_CURRENT_SOURCE_DIR}/../FoundationMacros
be more correct here?
When building this project via CMake as a standalone project (not as part of a toolchain build) we automatically check out and build some dependencies such as swift-collections and swift-foundation-icu. Now that we've separated the macro build into a separate build, we need to do the same for FoundationMacros. This updates the CMake files so that when
SwiftFoundation_MACROS
is not specified, we add the macro target to the build graph and build a copy of the macro for the host to use while building the rest of the project. This builds the macro as an executable just like SwiftPM rather than as a library so that the macro can be built with a different copy of swift-syntax than what the compiler has.While I was here, I also added some logging messages when checking out the dependencies to make it clear what build settings you can specify for local copies, as well as indicate why a cmake configuration was taking a while during git cloning