Skip to content

Run prebuild commands provided by plugins before the build starts #3307

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 2, 2021

Conversation

abertelrud
Copy link
Contributor

@abertelrud abertelrud commented Feb 25, 2021

Add support for running plugin-provided prebuild commands.

Motivation:

This is further progress on an implementation of the Extensible Build Tools proposal (SE-0303). This adds support for prebuild commands, which are commands that always run before each build and that can produce arbitrary outputs that get added as source files to the target to which they are applied (this differs from build tool commands, which are incorporated into the build graph and only run when necessary, but which can only be used when the names of the output paths can be known ahead of time).

Modifications:

Add SPMBuildCore facilities for running prebuild commands and collecting outputs
Modified BuildOperation to run the prebuild commands emitted by plugins
Modified BuildPlan to keep track of the output paths from these commands
Modified LLBuildManifestBuilder to include output directories in the set of paths that should trigger replanning
Made other smaller changes to the PackagePlugin API to bring it in line with SE-0303
Modified the test fixtures to include prebuild commands in addition to build tool commands

To Do:

Some things left to do are:

  • better diagnostics
  • support for other kinds of outputs that .swift source files
  • better unit tests that confirm that changes take effect

These improvements can be made in additional PRs that build on top of this one.

@abertelrud abertelrud self-assigned this Feb 25, 2021
@abertelrud abertelrud marked this pull request as draft February 25, 2021 03:23
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud abertelrud force-pushed the extension-prebuild-commands branch from 318dca5 to b9a6499 Compare February 26, 2021 08:58
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud abertelrud changed the title WIP: Support for running extension-provided prebuild commands WIP: Run prebuild commands provided by plugins before the build starts Feb 26, 2021
@abertelrud abertelrud force-pushed the extension-prebuild-commands branch 2 times, most recently from f628728 to ea4892e Compare March 1, 2021 06:30
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud abertelrud force-pushed the extension-prebuild-commands branch from ea4892e to 842e519 Compare March 1, 2021 06:42
@abertelrud abertelrud marked this pull request as ready for review March 1, 2021 06:47
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud abertelrud changed the title WIP: Run prebuild commands provided by plugins before the build starts Run prebuild commands provided by plugins before the build starts Mar 1, 2021
These commands run before the build starts, and can specify directories whose contents should be considered as inputs to the build planning.  The contents of the directories are added as derived sources to the build, and are expected to be compatible with the kind of target for which they are generating sources (e.g. .swift files for Swift targets).  The diagnostics for this are currently missing, resulting in a compilation failure rather than a better diagnostics, but will be added.  Also, resource files should be treated as resources, etc — this tool will be added.

The directories into which outputs are written are added to the set of directories whose contents should affect the build plan, so that changes to the set of generated source files are taken into account when constructing the build plan.
@abertelrud abertelrud force-pushed the extension-prebuild-commands branch from 842e519 to c7bab23 Compare March 1, 2021 20:45
@abertelrud
Copy link
Contributor Author

@swift-ci please smoke test

@abertelrud abertelrud merged commit 5e59c9f into swiftlang:main Mar 2, 2021
@abertelrud abertelrud deleted the extension-prebuild-commands branch March 2, 2021 02:11
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.

2 participants