Skip to content

Extend LLBuildManifestWriter to let shell commands specify environment and initial working directory #3332

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

Conversation

abertelrud
Copy link
Contributor

Extend LLBuildManifestWriter to let shell commands specify environment and initial working directory.

Motivation:

Plugin build tool commands can specify an environment and initial working directory, and we need LLBuildManifestWriter support for this.

Modifications:

  • add parameters to addShellCmd()
  • add support for writing out dictionaries to the llbuild manifest
  • add unit test for shell command writing

@abertelrud abertelrud self-assigned this Mar 8, 2021
@abertelrud abertelrud added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Mar 8, 2021
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@@ -96,13 +96,17 @@ public struct BuildManifest {
inputs: [Node],
outputs: [Node],
args: [String],
environ: [String: String] = [:],
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: environ -> environment (more swifty)

Copy link
Contributor Author

@abertelrud abertelrud Mar 8, 2021

Choose a reason for hiding this comment

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

Agreed. I was trying to follow the style of "args" above. I could change this but would probably also want to change 'args etc. Let's do that in a follow-up where we can clean them all up.

@@ -134,6 +134,16 @@ public final class ManifestToolStream {
stream <<< " \(key): " <<< Format.asJSON(newValue) <<< "\n"
}
}

public subscript(key: String) -> [String: String] {
get { fatalError() }
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be better to use a func instead of subscript so we don't have this potential runtime issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree in general but figured it was better to stay with the existing approach for this PR, i.e. the cognitive cost of something completely different for this one case would be more than the benefit. Seems to me that we should redo all of these at some point.

Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

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

couple of nit

@abertelrud
Copy link
Contributor Author

couple of nit

Thanks for pointing them out. Replied about staying with the current approach for the [String:String] case, where I feel we should rework all of this in a cleanup rather than do a different implementation for this one case.

@abertelrud abertelrud merged commit 1bc50ad into swiftlang:main Mar 8, 2021
@abertelrud abertelrud deleted the pass-environ-and-workdir-to-shell-cmds branch March 8, 2021 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Author believes the PR is ready to be merged & any feedback has been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants