Skip to content

refactor how plugins call the build system when using the CLI #4185

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 1 commit into from
Mar 1, 2022

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Mar 1, 2022

motivation: consolidate use of build operation construction which is important for cancellation support

changes:

  • use the general purpose function to create a build operation
  • small refactoring of how build plan is extracted after the build is complete

motivation: consolidate use of build operation construction which is important for cancellation support

changes:
* use the general purpose function to create a build operation
* small refactoring of how build plan is extracted after the build is complete
@tomerd
Copy link
Contributor Author

tomerd commented Mar 1, 2022

@abertelrud this is a breakout PR for a cleanup required by #4173

observabilityScope: self.swiftTool.observabilityScope
customBuildParameters: buildParameters,
customOutputStream: outputStream,
customLogLevel: logLevel
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the key change - basically use the generic swiftTool.createBuildOperation which will record things with the cancellation utility which is less error prone than doing it manually

Copy link
Contributor

Choose a reason for hiding this comment

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

This is great.


// Get the build plan used
guard let buildPlan = buildOperation.buildPlan else {
throw InternalError("invalid state, buildPlan is undefined")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the above is just a small cleanup

Copy link
Contributor

Choose a reason for hiding this comment

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

This is better than the !. Thanks for cleaning it up! In practice, should never happen but still.

return false
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can also use observabilityScope.trap instead of this, but this preserved the previous behavior exactly

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there was only one call site for this. Do you think there will be more, or would it be better to keep this do/catch at the one callsite?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

normally you want to do something with the error, but in this case the code only seems to care about the end result.

@tomerd tomerd added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Mar 1, 2022
@tomerd
Copy link
Contributor Author

tomerd commented Mar 1, 2022

@swift-ci please smoke test

@tomerd tomerd merged commit 016b67b into swiftlang:main Mar 1, 2022
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