Skip to content

Init template cleanup #6144

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Swift Next
}
```


Swift 5.9
-----------

Expand All @@ -29,6 +28,9 @@ Swift 5.9

Support for building plugin dependencies for the host when cross-compiling.

* [#6144]

Remove the `system-module` and `manifest` templates and clean up the remaining `empty`, `library`, and `executable` templates so they include the minimum information needed to get started, with links to documentation in the generated library, executable, and test content.

Swift 5.8
-----------
Expand Down
12 changes: 6 additions & 6 deletions Documentation/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ initialize it as a package that builds a system module:
example$ cd ..
$ mkdir Clibgit
$ cd Clibgit
Clibgit$ swift package init --type system-module
Clibgit$ swift package init --type empty

This creates `Package.swift` and `module.modulemap` files in the directory.
This creates a `Package.swift` file in the directory.
Edit `Package.swift` and add `pkgConfig` parameter:

```swift
Expand All @@ -181,7 +181,7 @@ parameter you can pass the path of a directory containing the library using the

example$ swift build -Xlinker -L/usr/local/lib/

Edit `module.modulemap` so it consists of the following:
Create a `module.modulemap` file so it consists of the following:

module Clibgit [system] {
header "/usr/local/include/git2.h"
Expand Down Expand Up @@ -258,10 +258,10 @@ initialize it as a package that builds a system module:
example$ cd ..
$ mkdir CJPEG
$ cd CJPEG
CJPEG$ swift package init --type system-module
CJPEG$ swift package init --type empty

This creates `Package.swift` and `module.modulemap` files in the directory.
Edit `module.modulemap` so it consists of the following:
This creates `Package.swift` file in the directory.
Create a `module.modulemap` file so it consists of the following:

module CJPEG [system] {
header "shim.h"
Expand Down
6 changes: 3 additions & 3 deletions IntegrationTests/Tests/IntegrationTests/BasicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ final class BasicTests: XCTestCase {
try localFileSystem.createDirectory(packagePath)
try sh(swiftPackage, "--package-path", packagePath, "init", "--type", "executable")
// delete any files generated
for entry in try localFileSystem.getDirectoryContents(packagePath.appending(components: "Sources", "secho")) {
try localFileSystem.removeFileTree(packagePath.appending(components: "Sources", "secho", entry))
for entry in try localFileSystem.getDirectoryContents(packagePath.appending(components: "Sources")) {
try localFileSystem.removeFileTree(packagePath.appending(components: "Sources", entry))
}
try localFileSystem.writeFileContents(
packagePath.appending(components: "Sources", "secho", "main.swift"),
packagePath.appending(components: "Sources", "secho.swift"),
bytes: ByteString(encodingAsUTF8: """
import Foundation
print(CommandLine.arguments.dropFirst().joined(separator: " "))
Expand Down
6 changes: 3 additions & 3 deletions IntegrationTests/Tests/IntegrationTests/SwiftPMTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ final class SwiftPMTests: XCTestCase {
try localFileSystem.createDirectory(packagePath)
try sh(swiftPackage, "--package-path", packagePath, "init", "--type", "executable")
// delete any files generated
for entry in try localFileSystem.getDirectoryContents(packagePath.appending(components: "Sources", "foo")) {
try localFileSystem.removeFileTree(packagePath.appending(components: "Sources", "foo", entry))
for entry in try localFileSystem.getDirectoryContents(packagePath.appending(components: "Sources")) {
try localFileSystem.removeFileTree(packagePath.appending(components: "Sources", entry))
}
try localFileSystem.writeFileContents(AbsolutePath(validating: "Sources/foo/main.m", relativeTo: packagePath)) {
try localFileSystem.writeFileContents(AbsolutePath(validating: "Sources/main.m", relativeTo: packagePath)) {
$0 <<< "int main() {}"
}
let archs = ["x86_64", "arm64"]
Expand Down
13 changes: 7 additions & 6 deletions Sources/Commands/PackageTools/Init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ extension SwiftPackageTool {

@Option(
name: .customLong("type"),
help: ArgumentHelp("Package type: empty | library | executable | system-module | manifest", discussion: """
empty - Create an empty package
library - Create a package that contains a library
executable - Create a package that contains a binary executable
system-module - Create a package that contains a system module
manifest - Create a Package.swift file
help: ArgumentHelp("Package type:", discussion: """
library - A package with a library.
executable - A package with an executable.
tool - A package with an executable that uses
Swift Argument Parser. Use this template if you
plan to have a rich set of command-line arguments.
empty - An empty package with a Package.swift manifest.
"""))
var initMode: InitPackage.PackageType = .library

Expand Down
Loading