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
Add PackageDescription.Context API #3794
Conversation
Added unit test that exercises the serialization of |
98fdba0
to
48de506
Compare
I've tested this working on Linux and Windows too. Currently the unit test doesn't work on Windows (times out), but I've tried |
Thanks for your work on this @pcbeard! This is looking really good, I think, and it's mostly details to discuss. |
@swift-ci please smoke test |
4 similar comments
@swift-ci please smoke test |
@swift-ci please smoke test |
@swift-ci please smoke test |
@swift-ci please smoke test |
f63cdf6
to
c6aac8b
Compare
@swift-ci please smoke test |
This struct contains context information available to a package manifest at runtime. Initially, it contains the packageRoot : URL property.
ContextModel is the value type that gets serialized and wrapped by PackageDescription.Context. ContextModel copied into PackageDescription by symbolic link PackageModel.PackageContext. Add .environment property to PackageDescription.Context.
This checks that the directory contents is accessible.
usleep() isn't portable.
No need for a singleton instance.
Add Context.swift, ContextModel.swift to CMakeLists.txt
Return comma separated list of Temporary*.swift
c6aac8b
to
afc0588
Compare
@swift-ci please smoke test |
Thanks, @pcbeard! |
Create PackageDescription.Context, which encapsulates context information available only at runtime.
Motivation:
This will permit package manifests to access their source files, which supports dependency generation activities such as dynamic creation of exclusion paths.
Modifications:
Adds a new struct
Context
which provides two static properties:packageDirectory
, the path of the root directory of the current package; andenvironment
, aDictionary<String, String>
that contains a snapshot of the build-time environment variables. These properties are backed by an internal structContextModel
, which is serialized by the manifest loader as JSON, and passed as a command line argument-context
to the manifest process.Result:
Packages will be able to use
Context.packageDirectory
to determine their package source directory at runtime. Environment variables are accessed usingContext.environment
.