Skip to content

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.
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants