-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[docs] Add Authoring-script-ports.md #22396
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Authoring Script Ports | ||
|
|
||
| Ports can expose functions for other ports to consume during their build. For | ||
| example, the `vcpkg-cmake` helper port exposes the `vcpkg_cmake_configure()` | ||
| helper function. Packaging common scripts into a shared helper port makes | ||
| maintenance easier because all consumers can be updated from a single place. | ||
| Because the scripts come from a port, they can be versioned and depended upon | ||
| via all the same mechanisms as any other port. | ||
|
|
||
| Script ports are implemented via the `vcpkg-port-config.cmake` extension | ||
| mechanism. Before invoking the `portfile.cmake` of a port, vcpkg will first | ||
| import `share/<port>/vcpkg-port-config.cmake` from each direct dependency. If | ||
| the direct dependency is a host dependency, the import will be performed in the | ||
| host installed tree (e.g. | ||
| `${HOST_INSTALLED_DIR}/share/<port>/vcpkg-port-config.cmake`). | ||
|
|
||
| Only direct dependencies are considered for `vcpkg-port-config.cmake` inclusion. | ||
| This means that if a script port relies on another script port, it must | ||
| explicitly import the `vcpkg-port-config.cmake` of its dependency. | ||
|
|
||
| Script-to-script dependencies should not be marked as host. The dependency from | ||
| a target port to a script should be marked host, which means that scripts should | ||
| always already be natively compiling. By making script-to-script dependencies | ||
| `"host": false`, it ensures that one script can depend upon the other being in | ||
| its same install directory. | ||
|
|
||
| Ports should never provide a `vcpkg-port-config.cmake` file under a different | ||
| `share/` subdirectory than the current port (`${PORT}`). | ||
|
|
||
| ## Example | ||
|
|
||
| ```cmake | ||
| # ${CURRENT_PACKAGES_DIR}/share/my-helper/vcpkg-port-config.cmake | ||
|
|
||
| # This include guard ensures the file will be loaded only once | ||
| include_guard(GLOBAL) | ||
|
|
||
| # This is how you could pull in a transitive dependency | ||
| include("${CMAKE_CURRENT_LIST_DIR}/../my-other-helper/vcpkg-port-config.cmake") | ||
|
|
||
| # Finally, it is convention to put each public function into a separate file with a matching name | ||
| include("${CMAKE_CURRENT_LIST_DIR}/my_helper_function_01.cmake") | ||
| include("${CMAKE_CURRENT_LIST_DIR}/my_helper_function_02.cmake") | ||
| include("${CMAKE_CURRENT_LIST_DIR}/my_helper_function_03.cmake") | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You should probably add some information on docs; there's a list in
docs/regenerate.ps1that one should update when adding a new script port.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.
I would prefer to merge this PR as-is; then that content can be easily added separately.