-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support for executableTarget in the manifest, to allow use of @main in package targets
#3045
Conversation
executableTarget in the manifest, in service of supporting @mainexecutableTarget in the manifest, as a step toward supporting @main
|
@swift-ci please smoke test |
|
this looks very nice 👍 |
|
We should also consider whether |
8ec9ca6
to
dea8190
Compare
|
Updated to main and resolved conflicts. |
|
@swift-ci please smoke test |
dea8190
to
ece7af3
Compare
executableTarget in the manifest, as a step toward supporting @mainexecutableTarget in the manifest, to allow use of @main in package targets
|
@swift-ci please smoke test |
…will allow executable package targets to use `@main`, since the targets will no longer be required to have a source file named `main.swift`.
…till recognize `.target()`s with main sources as executable targets in `.vNext`, but emit a warning asking to change to `.executableTarget()`. This should make it much clearer instead of just silently interpreting the target as a library.
…TABLE_TARGETS so we can land this and test it out even before the proposal is adopted. In practice this just gates the warning about use of `target()` for executables in post-5.3 manifests, since it's not possible to gate the availability of the new API for .vNext clients on an environment variable, and not really important to do so (it remains unavailable for 5.3 and earlier).
ece7af3
to
f007f63
Compare
|
@swift-ci please smoke test |
|
The evolution proposal runs until Dec 13, but I added support for a temporary environment variable SWIFTPM_ENABLE_EXECUTABLE_TARGETS so we could in theory land this and start testing it for real. There is no easy way to gate the availability of the API in the package manifest on the env var (it can be done but that's a lot more change that then has to be unwound again), so in practice this just enables the warning about implicitly discovered executable targets. The API changes are anyway gated on using the |
|
What remains is a Swift test fixture that uses |
|
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
…n` in package targets (swiftlang#3045) * Correct the naming of the PackageDescription5_3LoadingTests test suite. * Implement support for `executableTarget` in PackageDescription. This will allow executable package targets to use `@main`, since the targets will no longer be required to have a source file named `main.swift`. * In response to evolution proposal feedback, change the semantics to still recognize `.target()`s with main sources as executable targets in `.vNext`, but emit a warning asking to change to `.executableTarget()`. This should make it much clearer instead of just silently interpreting the target as a library. * Gated support for executable products on env var SWIFTPM_ENABLE_EXECUTABLE_TARGETS so we can land this and test it out even before the proposal is adopted. In practice this just gates the warning about use of `target()` for executables in post-5.3 manifests, since it's not possible to gate the availability of the new API for .vNext clients on an environment variable, and not really important to do so (it remains unavailable for 5.3 and earlier). * Added test fixture with use of `@main` and a unit test that tests that it builds.
|
Does this address an issue I raised over at the following Forum regarding unnecessary dependencies being pulled? Edit: Just read through the source and I can see that this probably doesn't fix this issue. Looks good though! As you can see, I am wondering around GitHub like a nomad, trying to find out more. You guys know if this issue has been raised already? |
|
I posted an answer back on the forums. |
Implementation of support for
executableTargetin the manifest. This allows use of@mainby having targets be explicitly declared as executable rather than by looking for particular file names.One preliminary change compared with the evolution proposal is that, in order to make the upgrading from tools version 5.3 smoother, regular targets containing
main.swiftetc are still supported but cause a warning that the target declaration should be changed toexecutableTargetif the tools version is newer than 5.3. This is a bit more clear than silently treating the target as a library once the tools version is upgraded.Motivation:
See https://forums.swift.org/t/se-0294-declaring-executable-targets-in-package-manifests/42404
Changes:
Implements the evolution proposal (including the warning mentioned above) but temporarily adds a guard on the environment variable SWIFTPM_ENABLE_EXECUTABLE_TARGETS until the proposal has been accepted.