Skip to content
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

Allow sources anywhere in ./Sources when only one target is present #6294

Conversation

bitjammer
Copy link
Contributor

After getting some feedback about the added path argument for executable packages generated with swift package init (#6144), this change allows a target's sources to occupy the entire sources directory when there is only one target in the package. All package types can benefit from this.

When there is more than one target in a package, the existing requirements for target sources still apply.

This change should be compatible with existing layouts as well. If there is only a single target in a package, then sources can of course continue to exist in ./Sources/<target>.

Amend the executable template's generated manifest to not include the path argument anymore.

rdar://106829666

@bitjammer bitjammer force-pushed the acgarland/rdar-106829666-allow-sources-dir-for-single-target branch 3 times, most recently from 09a61c9 to 60c3e7b Compare March 16, 2023 23:41
@bitjammer
Copy link
Contributor Author

@swift-ci Please smoke test

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.

Love this change

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Should this also be mentioned in CHANGELOG.md?

@neonichu
Copy link
Contributor

Do we need a matching behavior for tests?

@bitjammer bitjammer force-pushed the acgarland/rdar-106829666-allow-sources-dir-for-single-target branch from 60c3e7b to 15360c5 Compare March 17, 2023 20:43
@bitjammer
Copy link
Contributor Author

Added to the change log.

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Thanks!

@MaxDesiatov
Copy link
Contributor

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor

@swift-ci test windows

@bitjammer bitjammer force-pushed the acgarland/rdar-106829666-allow-sources-dir-for-single-target branch from 15360c5 to a02f461 Compare March 20, 2023 21:54
@bitjammer
Copy link
Contributor Author

@swift-ci Please smoke test

@bitjammer bitjammer force-pushed the acgarland/rdar-106829666-allow-sources-dir-for-single-target branch from a02f461 to 44b00a1 Compare March 20, 2023 22:02
After getting some feedback about the added `path` argument for executable
packages generated with `swift package init` (swiftlang#6144), this change allows a
target's sources to occupy the entire "predefined sources directory" (e.g.
`Sources`, `Tests`, or `Plugins`) when there is only one target of a specific
kind occupying one of those directories in the package. All package types can
benefit from this.

For example, if there is only one library target and one test target, one can
put sources directly in `./Sources` and `./Tests`. Adding another library means
that one has to put the sources for TargetA in `./Sources/TargetA` and the
sources for TargetB in `./Sources/TargetB`, and so on.

When there is more than one target of a type in a package, the existing
requirements for target sources still apply.

This change should be compatible with existing layouts as well. If there is
only a single target in a package, then sources can of course continue to exist
exclusively in `./Sources/<target>`, or `./Tests/<testTarget>`, etc.

Amend the `executable` and `tool` template's generated manifest to not include
the `path` argument anymore as it is no longer needed.

With this change, the `library` template type can also put its sources and tests
directly in the `./Sources` and `./Tests` directories respectively.

All of the above only takes place when the tools version is set to 5.9 or
higher in the manifest.

rdar://106829666
@bitjammer bitjammer force-pushed the acgarland/rdar-106829666-allow-sources-dir-for-single-target branch from 44b00a1 to aab4c83 Compare March 20, 2023 23:06
@bitjammer
Copy link
Contributor Author

@swift-ci Please smoke test

@bitjammer
Copy link
Contributor Author

@swift-ci Please test Windows platform

@bitjammer bitjammer merged commit 98bfe78 into swiftlang:main Mar 21, 2023
@bitjammer bitjammer deleted the acgarland/rdar-106829666-allow-sources-dir-for-single-target branch March 21, 2023 20:56
kkebo added a commit to kkebo/DevToys.swiftpm that referenced this pull request Nov 27, 2023
We can now unwrap a target folder when there's only one target since
Swift 5.9's [this
change](swiftlang/swift-package-manager#6294).
kkebo added a commit to kkebo/ConsolePad.swiftpm that referenced this pull request Nov 27, 2023
We can now unwrap a target folder when there's only one target since
Swift 5.9's [this
change](swiftlang/swift-package-manager#6294).
kkebo added a commit to kkebo/CoreMLDemos.swiftpm that referenced this pull request Nov 27, 2023
We can now unwrap a target folder when there's only one target since
Swift 5.9's [this
change](swiftlang/swift-package-manager#6294).
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.

4 participants