Skip to content
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

[cmake] Provide private extension points to the build #77507

Conversation

etcwilde
Copy link
Contributor

@etcwilde etcwilde commented Nov 9, 2024

This patch provides extension points on the build system so that vendors can keep vendor-specific build system settings private, without having to worry about merge conflicts haunting them for the rest of time.

The location of the extension modules is set with the SwiftCore_PRIVATE_MODULE_DIR variable. If it is not specified, the default location is under cmake/modules/private.

Currently, there are extension points for the default settings, and for the global settings.

Adding a macro to tie non-boolean variables into the defaulting
mechanism.
Adding documentation on the behavior of the `defaulted_option` and
`defaulted_set` macros.
@etcwilde
Copy link
Contributor Author

etcwilde commented Nov 9, 2024

@swift-ci please test

# Allowed extension points:
# - DefaultSettings.cmake
# - Settings.cmake
set(SwiftCore_PRIVATE_MODULE_DIR "${SwiftCore_CMAKE_MODULES_DIR}/private"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of SwiftCore_VENDOR_MODULE_DIR? This is the vendor specific settings and makes it clear when you concatenate them even if you don't know what it is (e.g. ${SwiftCore_VENDOR_MODULE_DIR}/DefaultSettings.cmake vs ${SwiftCore_PRIVATE_MODULE_DIR}/DefaultSettings.cmake).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds good to me

Adding vendor-specific extension points to the build system, giving
vendors a place to put their internal settings and defaults, without
having to modify the build directly. This helps reduce the chances of
merge conflicts and public changes breaking internal settings.

The location of the macros are set with `SwiftCore_PRIVATE_MODULE_DIR`,
so vendors can keep their private extensions in a separate location if
desired. Otherwise, it defaults to `cmake/modules/private`, which
intentionally does not exist at this time.

Currently, we have extensions for the default settings and global
settings.
@etcwilde etcwilde force-pushed the ewilde/stdlib-rebuild-private-extension-points branch from eb80255 to 2df8a18 Compare November 9, 2024 01:28
@etcwilde
Copy link
Contributor Author

etcwilde commented Nov 9, 2024

@swift-ci please smoke test

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@etcwilde
Copy link
Contributor Author

@swift-ci please smoke test Linux

@etcwilde etcwilde merged commit 8f81e1d into swiftlang:main Nov 12, 2024
3 checks passed
@etcwilde etcwilde deleted the ewilde/stdlib-rebuild-private-extension-points branch November 12, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants