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

[vcpkg] Enable reentrant vcpkg calls #13751

Merged
merged 4 commits into from
Oct 6, 2020

Conversation

ras0219
Copy link
Contributor

@ras0219 ras0219 commented Sep 26, 2020

This PR enables the vcpkg executable to support limited reentrancy. This potentially allows the tool to provide certain services to the inner package builds, such as downloading, locking, and more.

This is analogous to the common CMake pattern of

execute_process(
    COMMAND "${CMAKE_COMMAND}" -E <tool> <arg1>
)

except it will use

execute_process(
    COMMAND "$ENV{VCPKG_COMMAND}" <function> <arg1>
)

To minimize maintenance burden on intermediate callers, any information that needs to be exchanged between the outer vcpkg process and the inner reentrant call is piped through a JSON document stored in the environment variable $VCPKG_X_RECURSIVE_DATA. Intermediate callers must not examine or modify this document in any way.

Additional notes about this v1 implementation:

  • Multiple reentrancy is strictly disallowed; we set $VCPKG_X_RECURSIVE_DATA to poison after the first reentrance ensuring that further reentrancies will fail fast
  • This version does not implement an explicit allow-list of valid reentrant commands
  • In a future version, $VCPKG_FORCE_SYSTEM_BINARIES should be reorganized into $VCPKG_X_RECURSIVE_DATA once all references are moved into reentrant services. At the time of this PR, there is a reference to this environment variable in vcpkg_configure_cmake()

Via envvars VCPKG_COMMAND and VCPKG_X_RECURSIVE_DATA. Child processes can call vcpkg via "$VCPKG_COMMAND <args>" in limited internal circumstances.
@PhoebeHui PhoebeHui self-assigned this Sep 27, 2020
@PhoebeHui PhoebeHui added category:code-cleanup This PR cleans up code, without fixing any existing bugs nor adding any features. info:internal This PR or Issue was filed by the vcpkg team. labels Sep 27, 2020
toolsrc/include/vcpkg/base/optional.h Outdated Show resolved Hide resolved
toolsrc/include/vcpkg/base/optional.h Outdated Show resolved Hide resolved
@ras0219 ras0219 changed the title [vcpkg] Enable recursive vcpkg calls [vcpkg] Enable reentrant vcpkg calls Oct 1, 2020
@ras0219-msft ras0219-msft merged commit 8fe1851 into microsoft:master Oct 6, 2020
strega-nil pushed a commit to strega-nil/vcpkg that referenced this pull request May 5, 2021
* [vcpkg] Enable recursive vcpkg calls

Via envvars VCPKG_COMMAND and VCPKG_X_RECURSIVE_DATA. Child processes can call vcpkg via "$VCPKG_COMMAND <args>" in limited internal circumstances.

* [vcpkg] Address CR comments

* [vcpkg] Do not move through Optional<&> into Optional<T>

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:code-cleanup This PR cleans up code, without fixing any existing bugs nor adding any features. info:internal This PR or Issue was filed by the vcpkg team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants