Skip to content

Fix indentation and remove trailing whitespace of test files #2

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
Dec 3, 2015

Conversation

juliangrosshauser
Copy link
Contributor

Since most parts of the files were using spaces I converted all of them to use spaces as tabs.

ddunbar added a commit that referenced this pull request Dec 3, 2015
Fix indentation and remove trailing whitespace of test files
@ddunbar ddunbar merged commit 8850b7a into swiftlang:master Dec 3, 2015
@ddunbar
Copy link
Contributor

ddunbar commented Dec 3, 2015

Thanks!

aciidgh referenced this pull request in aciidgh/swift-package-manager Sep 20, 2017
aciidgh referenced this pull request in aciidgh/swift-package-manager Jan 11, 2019
[Ninja] Support -j (jobs) parameter to Ninja.
sergiocampama pushed a commit that referenced this pull request Apr 20, 2020
Sync with SwiftPM trunk
MaxDesiatov pushed a commit to MaxDesiatov/swift-package-manager that referenced this pull request Jul 6, 2020
DougGregor pushed a commit that referenced this pull request Aug 25, 2024
…wift identifier (#7764)

Executing `swift package add-target my-target --type executable` breaks
the updated package because the executable target name is not a valid
Swift identifier.

### Motivation:
After executing `swift package add-target my-target --type executable`,
I expect the generated stub to not break the modified package. However,
in this case, the resulting stub file would contain invalid Swift code:
```swift
@main
struct my-targetMain {
    static func main() {
        print("Hello, world")
    }
}
```
The same issue applies to `macro` and `test` target types. It's also
important to note that `dash case` is quite often used for target names,
like e.g. in
[swift-argument-parser](https://github.com/apple/swift-argument-parser/blob/main/Package.swift#L65-L68).

Additionaly, when `AddTarget` is consumed via an API (as opposed to the
CLI), the following parsing error is thrown into `stdout`:

<img width="796" alt="Screenshot 2024-07-08 at 08 40 51"
src="https://github.com/swiftlang/swift-package-manager/assets/1008612/c2696127-3e34-47a2-aa60-a843cfb64bda">

### Modifications:

I believe there are at least two ways to solve this issue:
1. Use a predefined type name in the generated stub, such as `struct
ExampleMain`, so it doesn't depend on the target name.
2. Introduce a sanitizer function to ensure that the target name is
always a valid Swift identifier. For example, a function that would
convert "$my-target-name%" into "myTargetName".

For the sake of simplicity, I opted for approach `#1` in the proposed
PR. However, if it's necessary to preserve target names in the generated
stubs, we can certainly go with approach `#2`.

### Result:

`swift package add-target my-target --type executable`
```swift
@main
struct ExampleMain {
    static func main() {
        print("Hello, world")
    }
}
```
bkhouri added a commit to bkhouri/swift-package-manager that referenced this pull request Apr 7, 2025
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