diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 0c6147d693e..660768f35cc 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -12,29 +12,62 @@ concurrency: cancel-in-progress: true jobs: - tests: - name: Test + tests-using-native: + needs: [soundness] + strategy: + fail-fast: false + matrix: + buildSystem: ["native", "swiftbuild"] + linuxSwiftVersion: ['["nightly-main", "nightly-6.2"]', '["nightly-main"]'] + enable_windows_checks: [true] + exclude: + - buildSystem: "swiftbuild" + linuxSwiftVersion: '["nightly-main", "nightly-6.2"]' + - buildSystem: "swiftbuild" + enable_windows_checks: true + - buildSystem: "native" + linuxSwiftVersion: '["nightly-main"]' + name: Test (${{ matrix.buildSystem }}) + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.1 + with: + linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]' + linux_swift_versions: ${{ matrix.linuxSwiftVersion }} + linux_pre_build_command: ./.github/scripts/prebuild.sh + linux_build_command: 'swift run swift-build --build-tests --build-system ${{ matrix.buildSystem}}' + windows_swift_versions: '["nightly-main"]' + windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1' + windows_build_command: 'Invoke-Program swift run swift-build --build-tests --build-system ${{ matrix.buildSystem}}' + enable_windows_checks: ${{ matrix.enable_windows_checks }} + enable_ios_checks: true + enable_macos_checks: true + macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]" + macos_build_command: 'swift run swift-build --build-tests --build-system ${{ matrix.buildSystem}}' + + tests-using-swiftbuild: + name: Test (all SwiftBuild) + needs: [soundness] uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.1 with: linux_os_versions: '["amazonlinux2", "bookworm", "noble", "jammy", "rhel-ubi9"]' linux_swift_versions: '["nightly-main"]' linux_pre_build_command: ./.github/scripts/prebuild.sh - linux_build_command: 'swift build' + linux_build_command: 'swift run --build-system swiftbuild swift-build --build-tests --build-system swiftbuild' + enable_windows_checks: false windows_swift_versions: '["nightly-main"]' windows_pre_build_command: 'Invoke-Program .\.github\scripts\prebuild.ps1' - windows_build_command: 'Invoke-Program swift build' + windows_build_command: 'Invoke-Program swift run --build-system swiftbuild swift-build --build-tests --build-system swiftbuild' enable_ios_checks: true enable_macos_checks: true macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.3\"}, {\"xcode_version\": \"16.4\"}]" - macos_build_command: 'swift build' + macos_build_command: 'swift run --build-system swiftbuild swift-build --build-tests --build-system swiftbuild' soundness: name: Soundness uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.1 with: license_header_check_project_name: "Swift" - license_header_check_enabled: false - unacceptable_language_check_enabled: false + license_header_check_enabled: true + unacceptable_language_check_enabled: true api_breakage_check_enabled: false format_check_enabled: false shell_check_enabled: false diff --git a/.licenseignore b/.licenseignore index e7babf0caf4..70a6487374c 100644 --- a/.licenseignore +++ b/.licenseignore @@ -6,5 +6,24 @@ .dir-locals.el .editorconfig .swift-version +.swiftformat +.pep8 +.mailmap +.mailfilter CODEOWNERS Package.swift +Fixtures/**/*.* +**/*.pc +**/*.cer +**/*.zip +**/*.tar +**/*.tgz +**/*.gz +**/*.svg +**/*.bat +**/*.xctestplan +**/processInputs/** +Utilities/bootstrap +Utilities/build-using-self +Utilities/new-bootstrap +Utilities/test-toolchain diff --git a/Benchmarks/Benchmarks/PackageGraphBenchmarks/PackageGraphBenchmarks.swift b/Benchmarks/Benchmarks/PackageGraphBenchmarks/PackageGraphBenchmarks.swift index 09460dbd7e5..79c099e05a8 100644 --- a/Benchmarks/Benchmarks/PackageGraphBenchmarks/PackageGraphBenchmarks.swift +++ b/Benchmarks/Benchmarks/PackageGraphBenchmarks/PackageGraphBenchmarks.swift @@ -1,3 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + @_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly) import Basics import Benchmark @@ -103,8 +115,8 @@ let benchmarks = { ) ) { benchmark in try syntheticModulesGraph( - benchmark, - modulesGraphDepth: modulesGraphDepth, + benchmark, + modulesGraphDepth: modulesGraphDepth, modulesGraphWidth: modulesGraphWidth, includeMacros: true ) @@ -112,9 +124,9 @@ let benchmarks = { } func syntheticModulesGraph( - _ benchmark: Benchmark, - modulesGraphDepth: Int, - modulesGraphWidth: Int, + _ benchmark: Benchmark, + modulesGraphDepth: Int, + modulesGraphWidth: Int, includeMacros: Bool = false ) throws { // If macros are included, modules are split in three parts: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 13763291b95..213aa89ae6e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ There are several types of contributions one can make. Bug fixes, documentation and enhancements that do not materially change the user facing semantics of Swift Package Manager should be submitted directly as PR. -Larger changes that do materially change the semantics of Swift Package Manager (e.g. changes to the manifest format or behavior) are required to go through [Swift Evolution Process](https://github.com/swiftlang/swift-evolution/blob/master/process.md). +Larger changes that do materially change the semantics of Swift Package Manager (e.g. changes to the manifest format or behavior) are required to go through [Swift Evolution Process](https://github.com/swiftlang/swift-evolution/blob/main/process.md). To see how previous evolution decisions for SwiftPM have been made and have some direction for the development of future features please check out the [Community Proposals](https://forums.swift.org/tag/packagemanager). @@ -16,7 +16,7 @@ Fill the following fields: * `Title`: A one line summary of the problem you're facing. * `Description`: The complete description of the problem. Be specific. -* `Expected behavior`: How you expect SwiftPM to behave. +* `Expected behavior`: How you expect SwiftPM to behave. * `Actual behavior` : What actually happens. * `Steps to reproduce`: Be specific, provide steps to reproduce the bug. * `Swift Package Manager version/commit hash` : With which version are you testing. @@ -510,5 +510,5 @@ Make sure to update your TSC (Tools Support Core): ```bash $> swift package update ``` -Alternatively, if you are using Xcode, you can update to the latest version of all packages: +Alternatively, if you are using Xcode, you can update to the latest version of all packages: **Xcode App** > *File* > *Swift Packages* > *Update to Latest Package Versions* diff --git a/Documentation/Design/EvolutionIdeas.md b/Documentation/Design/EvolutionIdeas.md index cd445c4f1c4..61903902d2d 100644 --- a/Documentation/Design/EvolutionIdeas.md +++ b/Documentation/Design/EvolutionIdeas.md @@ -13,7 +13,7 @@ If you're interested in participating in a particular evolution idea, please familiarize yourself with the existing discussion on that topic and start participating in the discussion thread of that idea. If a thread doesn't exist for that idea, please start one with a [draft -proposal](https://github.com/swiftlang/swift-evolution/blob/master/proposal-templates/0000-swiftpm-template.md) +proposal](https://github.com/swiftlang/swift-evolution/blob/main/proposal-templates/0000-swiftpm-template.md) that can be used as a starting point. **Important Note**: This list is not in any particular order. I plan to keep diff --git a/Documentation/PackageRegistry/Registry.md b/Documentation/PackageRegistry/Registry.md index b428dce6c9e..93afc3513a1 100644 --- a/Documentation/PackageRegistry/Registry.md +++ b/Documentation/PackageRegistry/Registry.md @@ -186,11 +186,11 @@ Valid `Accept` header field values are described by the following rules: ``` A server MUST set the `Content-Type` header field -with the corresponding content type of the response. +with the corresponding content type of the response. A server MUST set the `Content-Version` header field -with the API version number of the response, unless -explicitly stated otherwise. +with the API version number of the response, unless +explicitly stated otherwise. ```http HTTP/1.1 200 OK @@ -523,11 +523,11 @@ with a given combination of `name` and `type` values. #### 4.2.2. Package release metadata standards -[Appendix B](#appendix-b---package-release-metadata-json-schema) +[Appendix B](#appendix-b---package-release-metadata-json-schema) defines the JSON schema for package release metadata that gets submitted as part of the ["create a package release"](#endpoint-6) -request. A server MAY allow and/or populate additional metadata by -expanding the schema. The `metadata` key in the +request. A server MAY allow and/or populate additional metadata by +expanding the schema. The `metadata` key in the ["fetch information about a package release "](#endpoint-2) API response will hold the user-provided as well as the server populated metadata. @@ -717,7 +717,7 @@ It is RECOMMENDED for clients and servers to support range requests as described by [RFC 7233] and caching as described by [RFC 7234]. -If a release is signed, a server MUST include +If a release is signed, a server MUST include `X-Swift-Package-Signature-Format` and `X-Swift-Package-Signature` headers in the response. @@ -777,7 +777,7 @@ Digest: sha-256=a2ac54cf25fbc1ad0028f03f0aa4b96833b83bb05a14e510892bb27dea4dc812 A client MUST validate the signature of a signed archive according to the signature format and configuration. Signing -information can alternatively be found in the associated +information can alternatively be found in the associated `source-archive` resource in the response to `GET /{scope}/{name}/{version}`, as described in [4.2.1](#421-package-release-resources). @@ -830,12 +830,12 @@ caching as described by [RFC 7234]. #### 4.5.1 URL to package identifier mappings As part of the [package release metadata](#422-package-release-metadata-standards) -JSON object, the `repositoryURLs` array can be used to specify -URLs associated with a package identifier. This is one way -through which a server can obtain URL to package identifier -mappings for this API. +JSON object, the `repositoryURLs` array can be used to specify +URLs associated with a package identifier. This is one way +through which a server can obtain URL to package identifier +mappings for this API. -A server MAY choose other mechanism(s) for package authors +A server MAY choose other mechanism(s) for package authors to specify these mappings. A server SHOULD validate the package author's ownership claim @@ -859,19 +859,19 @@ with the following sections: | `metadata` | `application/json` | Additional information about the release. | OPTIONAL | | `metadata-signature` | `application/octet-stream` | The signature of the metadata. | OPTIONAL | -A client MUST set a `Content-Type` header with the value +A client MUST set a `Content-Type` header with the value `multipart/form-data`. `boundary` can be any string. A client MAY use any valid value (e.g., `binary`) for the `Content-Transfer-Encoding` header. -A client SHOULD set the `Content-Length` header with +A client SHOULD set the `Content-Length` header with the total size of the body in bytes. A client SHOULD set the `Accept` header with the value `application/vnd.swift.registry.v1+json`. -A client MUST set a `X-Swift-Package-Signature-Format` header +A client MUST set a `X-Swift-Package-Signature-Format` header with the signature format if the source archive is signed. ```http @@ -1079,7 +1079,7 @@ Content-Language: en { "detail": "invalid JSON provided for release metadata" } -``` +``` #### 4.6.3. Synchronous and asynchronous publication @@ -1262,13 +1262,13 @@ See [registry.openapi.yaml](./registry.openapi.yaml). ## Appendix B - Package Release Metadata JSON Schema -The `metadata` section of the [create package release request](#46-create-a-package-release) +The `metadata` section of the [create package release request](#46-create-a-package-release) must be a JSON object of type [`PackageRelease`](#packagerelease-type), as defined in the JSON schema below.
-Expand to view JSON schema +Expand to view JSON schema ```json { @@ -1282,52 +1282,52 @@ JSON schema below. "type": "object", "properties": { "name": { - "type": "string", + "type": "string", "description": "Name of the author." - }, + }, "email": { "type": "string", "format": "email", "description": "Email address of the author." - }, + }, "description": { - "type": "string", + "type": "string", "description": "A description of the author." }, "organization": { "type": "object", "properties": { "name": { - "type": "string", + "type": "string", "description": "Name of the organization." - }, + }, "email": { "type": "string", - "format": "email", + "format": "email", "description": "Email address of the organization." - }, + }, "description": { - "type": "string", + "type": "string", "description": "A description of the organization." - }, + }, "url": { "type": "string", - "format": "uri", + "format": "uri", "description": "URL of the organization." - }, + }, }, "required": ["name"] - }, + }, "url": { - "type": "string", - "format": "uri", + "type": "string", + "format": "uri", "description": "URL of the author." - }, + }, }, "required": ["name"] }, "description": { - "type": "string", + "type": "string", "description": "A description of the package release." }, "licenseURL": { @@ -1342,7 +1342,7 @@ JSON schema below. }, "readmeURL": { "type": "string", - "format": "uri", + "format": "uri", "description": "URL of the README specifically for the package release or broadly for the package." }, "repositoryURLs": { @@ -1351,7 +1351,7 @@ JSON schema below. "items": { "type": "string", "description": "Code repository URL." - } + } } } } @@ -1427,6 +1427,6 @@ JSON schema below. [thundering herd effect]: https://en.wikipedia.org/wiki/Thundering_herd_problem "Thundering herd problem" [offline cache]: https://yarnpkg.com/features/offline-cache "Offline Cache | Yarn - Package Manager" [XCFramework]: https://developer.apple.com/videos/play/wwdc2019/416/ "WWDC 2019 Session 416: Binary Frameworks in Swift" -[SE-0272]: https://github.com/swiftlang/swift-evolution/blob/master/proposals/0272-swiftpm-binary-dependencies.md "Package Manager Binary Dependencies" +[SE-0272]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0272-swiftpm-binary-dependencies.md "Package Manager Binary Dependencies" [Swift tools version]: https://github.com/swiftlang/swift-package-manager/blob/9b9bed7eaf0f38eeccd0d8ca06ae08f6689d1c3f/Documentation/Usage.md#swift-tools-version-specification "Swift Tools Version Specification" [ISO 8601]: https://www.iso.org/iso-8601-date-and-time-format.html "ISO 8601 Date and Time Format" diff --git a/Documentation/libSwiftPM.md b/Documentation/libSwiftPM.md index 7ea9c64621e..2a0d768dc04 100644 --- a/Documentation/libSwiftPM.md +++ b/Documentation/libSwiftPM.md @@ -10,7 +10,7 @@ A subset of `libSwiftPM` that includes only the data model (without SwiftPM's build system) is available as `libSwiftPMDataModel`. Any one client should depend on one or the other, but not both. -The SwiftPM repository contains an [example](https://github.com/swiftlang/swift-package-manager/tree/master/Examples/package-info) that demonstrates the use of +The SwiftPM repository contains an [example](https://github.com/swiftlang/swift-package-manager/tree/main/Examples/package-info) that demonstrates the use of `libSwiftPM` in a Swift package. Use the following commands to run the example package: diff --git a/Examples/package-info/Sources/package-info/example.swift b/Examples/package-info/Sources/package-info/example.swift index 579a5331e25..3cffb7fbbf1 100644 --- a/Examples/package-info/Sources/package-info/example.swift +++ b/Examples/package-info/Sources/package-info/example.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2022 - 2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics import Workspace diff --git a/Fixtures/Collections/GitHub/license.json b/Fixtures/Collections/GitHub/license.json index 4e56f156b95..98cced18802 100644 --- a/Fixtures/Collections/GitHub/license.json +++ b/Fixtures/Collections/GitHub/license.json @@ -3,17 +3,17 @@ "path": "LICENSE", "sha": "401c59dcc4570b954dd6d345e76199e1f4e76266", "size": 1077, - "url": "https://api.github.com/repos/benbalter/gman/contents/LICENSE?ref=master", - "html_url": "https://github.com/benbalter/gman/blob/master/LICENSE", + "url": "https://api.github.com/repos/benbalter/gman/contents/LICENSE?ref=main", + "html_url": "https://github.com/benbalter/gman/blob/main/LICENSE", "git_url": "https://api.github.com/repos/benbalter/gman/git/blobs/401c59dcc4570b954dd6d345e76199e1f4e76266", - "download_url": "https://raw.githubusercontent.com/benbalter/gman/master/LICENSE?lab=true", + "download_url": "https://raw.githubusercontent.com/benbalter/gman/main/LICENSE?lab=true", "type": "file", "content": "VGhlIE1JVCBMaWNlbnNlIChNSVQpCgpDb3B5cmlnaHQgKGMpIDIwMTMgQmVu\nIEJhbHRlcgoKUGVybWlzc2lvbiBpcyBoZXJlYnkgZ3JhbnRlZCwgZnJlZSBv\nZiBjaGFyZ2UsIHRvIGFueSBwZXJzb24gb2J0YWluaW5nIGEgY29weSBvZgp0\naGlzIHNvZnR3YXJlIGFuZCBhc3NvY2lhdGVkIGRvY3VtZW50YXRpb24gZmls\nZXMgKHRoZSAiU29mdHdhcmUiKSwgdG8gZGVhbCBpbgp0aGUgU29mdHdhcmUg\nd2l0aG91dCByZXN0cmljdGlvbiwgaW5jbHVkaW5nIHdpdGhvdXQgbGltaXRh\ndGlvbiB0aGUgcmlnaHRzIHRvCnVzZSwgY29weSwgbW9kaWZ5LCBtZXJnZSwg\ncHVibGlzaCwgZGlzdHJpYnV0ZSwgc3VibGljZW5zZSwgYW5kL29yIHNlbGwg\nY29waWVzIG9mCnRoZSBTb2Z0d2FyZSwgYW5kIHRvIHBlcm1pdCBwZXJzb25z\nIHRvIHdob20gdGhlIFNvZnR3YXJlIGlzIGZ1cm5pc2hlZCB0byBkbyBzbywK\nc3ViamVjdCB0byB0aGUgZm9sbG93aW5nIGNvbmRpdGlvbnM6CgpUaGUgYWJv\ndmUgY29weXJpZ2h0IG5vdGljZSBhbmQgdGhpcyBwZXJtaXNzaW9uIG5vdGlj\nZSBzaGFsbCBiZSBpbmNsdWRlZCBpbiBhbGwKY29waWVzIG9yIHN1YnN0YW50\naWFsIHBvcnRpb25zIG9mIHRoZSBTb2Z0d2FyZS4KClRIRSBTT0ZUV0FSRSBJ\nUyBQUk9WSURFRCAiQVMgSVMiLCBXSVRIT1VUIFdBUlJBTlRZIE9GIEFOWSBL\nSU5ELCBFWFBSRVNTIE9SCklNUExJRUQsIElOQ0xVRElORyBCVVQgTk9UIExJ\nTUlURUQgVE8gVEhFIFdBUlJBTlRJRVMgT0YgTUVSQ0hBTlRBQklMSVRZLCBG\nSVRORVNTCkZPUiBBIFBBUlRJQ1VMQVIgUFVSUE9TRSBBTkQgTk9OSU5GUklO\nR0VNRU5ULiBJTiBOTyBFVkVOVCBTSEFMTCBUSEUgQVVUSE9SUyBPUgpDT1BZ\nUklHSFQgSE9MREVSUyBCRSBMSUFCTEUgRk9SIEFOWSBDTEFJTSwgREFNQUdF\nUyBPUiBPVEhFUiBMSUFCSUxJVFksIFdIRVRIRVIKSU4gQU4gQUNUSU9OIE9G\nIENPTlRSQUNULCBUT1JUIE9SIE9USEVSV0lTRSwgQVJJU0lORyBGUk9NLCBP\nVVQgT0YgT1IgSU4KQ09OTkVDVElPTiBXSVRIIFRIRSBTT0ZUV0FSRSBPUiBU\nSEUgVVNFIE9SIE9USEVSIERFQUxJTkdTIElOIFRIRSBTT0ZUV0FSRS4K\n", "encoding": "base64", "_links": { - "self": "https://api.github.com/repos/benbalter/gman/contents/LICENSE?ref=master", + "self": "https://api.github.com/repos/benbalter/gman/contents/LICENSE?ref=main", "git": "https://api.github.com/repos/benbalter/gman/git/blobs/401c59dcc4570b954dd6d345e76199e1f4e76266", - "html": "https://github.com/benbalter/gman/blob/master/LICENSE" + "html": "https://github.com/benbalter/gman/blob/main/LICENSE" }, "license": { "key": "mit", diff --git a/Fixtures/Collections/GitHub/metadata.json b/Fixtures/Collections/GitHub/metadata.json index 7e55c325e73..52433b326f4 100644 --- a/Fixtures/Collections/GitHub/metadata.json +++ b/Fixtures/Collections/GitHub/metadata.json @@ -77,7 +77,7 @@ "watchers_count": 80, "watchers": 80, "size": 108, - "default_branch": "master", + "default_branch": "main", "open_issues_count": 0, "open_issues": 0, "is_template": true, @@ -215,7 +215,7 @@ "stargazers_count": 80, "watchers_count": 80, "size": 108, - "default_branch": "master", + "default_branch": "main", "open_issues_count": 0, "is_template": true, "topics": [ @@ -337,7 +337,7 @@ "stargazers_count": 80, "watchers_count": 80, "size": 108, - "default_branch": "master", + "default_branch": "main", "open_issues_count": 0, "is_template": true, "topics": [ diff --git a/Fixtures/Collections/GitHub/readme.json b/Fixtures/Collections/GitHub/readme.json index 34a6f61254c..3fd3aa8b60d 100644 --- a/Fixtures/Collections/GitHub/readme.json +++ b/Fixtures/Collections/GitHub/readme.json @@ -8,11 +8,11 @@ "sha": "3d21ec53a331a6f037a91c368710b99387d012c1", "url": "https://api.github.com/repos/octokit/octokit.rb/contents/README.md", "git_url": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1", - "html_url": "https://github.com/octokit/octokit.rb/blob/master/README.md", - "download_url": "https://raw.githubusercontent.com/octokit/octokit.rb/master/README.md", + "html_url": "https://github.com/octokit/octokit.rb/blob/main/README.md", + "download_url": "https://raw.githubusercontent.com/octokit/octokit.rb/main/README.md", "_links": { "git": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1", "self": "https://api.github.com/repos/octokit/octokit.rb/contents/README.md", - "html": "https://github.com/octokit/octokit.rb/blob/master/README.md" + "html": "https://github.com/octokit/octokit.rb/blob/main/README.md" } } diff --git a/Fixtures/Collections/GitHub/releases.json b/Fixtures/Collections/GitHub/releases.json index feefea7bbc3..bc091ac1655 100644 --- a/Fixtures/Collections/GitHub/releases.json +++ b/Fixtures/Collections/GitHub/releases.json @@ -9,7 +9,7 @@ "id": 1, "node_id": "MDc6UmVsZWFzZTE=", "tag_name": "v2.0.0", - "target_commitish": "master", + "target_commitish": "main", "name": "2.0.0", "body": "Description of the release", "draft": false, @@ -72,7 +72,7 @@ } } ] - }, + }, { "url": "https://api.github.com/repos/octocat/Hello-World/releases/1", "html_url": "https://github.com/octocat/Hello-World/releases/v1.0.0", @@ -83,7 +83,7 @@ "id": 1, "node_id": "MDc6UmVsZWFzZTE=", "tag_name": "1.0.0", - "target_commitish": "master", + "target_commitish": "main", "name": "1.0.0", "body": "Description of the release", "draft": false, diff --git a/Fixtures/Miscellaneous/VersionSpecificManifest/Foo.swift b/Fixtures/Miscellaneous/VersionSpecificManifest/Foo.swift new file mode 100644 index 00000000000..ad5e70131a1 --- /dev/null +++ b/Fixtures/Miscellaneous/VersionSpecificManifest/Foo.swift @@ -0,0 +1,3 @@ +public func foo() { + {}() +} diff --git a/Fixtures/Miscellaneous/VersionSpecificManifest/Package.swift b/Fixtures/Miscellaneous/VersionSpecificManifest/Package.swift new file mode 100644 index 00000000000..31f579f1b85 --- /dev/null +++ b/Fixtures/Miscellaneous/VersionSpecificManifest/Package.swift @@ -0,0 +1,12 @@ +// swift-tools-version:6.0 +import PackageDescription + +let package = Package( + name: "Foo", + products: [ + .library(name: "Foo", targets: ["Foo"]), + ], + targets: [ + .target(name: "Foo", path: "./"), + ] +) diff --git a/Fixtures/Miscellaneous/VersionSpecificManifest/Package@swift-5.0.swift b/Fixtures/Miscellaneous/VersionSpecificManifest/Package@swift-5.0.swift new file mode 100644 index 00000000000..23f67814920 --- /dev/null +++ b/Fixtures/Miscellaneous/VersionSpecificManifest/Package@swift-5.0.swift @@ -0,0 +1,12 @@ +// swift-tools-version:5.2 +import PackageDescription + +let package = Package( + name: "Foo", + products: [ + .library(name: "Foo", targets: ["Foo"]), + ], + targets: [ + .target(name: "Foo", path: "./"), + ] +) diff --git a/Fixtures/PIFBuilder/BasicExecutable/Package.swift b/Fixtures/PIFBuilder/BasicExecutable/Package.swift new file mode 100644 index 00000000000..b369662574f --- /dev/null +++ b/Fixtures/PIFBuilder/BasicExecutable/Package.swift @@ -0,0 +1,12 @@ +// swift-tools-version: 6.2 + +import PackageDescription + +let package = Package( + name: "BasicExecutable", + targets: [ + .executableTarget( + name: "Executable", + ), + ] +) diff --git a/Fixtures/PIFBuilder/BasicExecutable/Sources/BasicExecutable/BasicExecutable.swift b/Fixtures/PIFBuilder/BasicExecutable/Sources/BasicExecutable/BasicExecutable.swift new file mode 100644 index 00000000000..8b32e00dca1 --- /dev/null +++ b/Fixtures/PIFBuilder/BasicExecutable/Sources/BasicExecutable/BasicExecutable.swift @@ -0,0 +1,9 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book + +@main +struct BasicExecutable { + static func main() { + print("Hello, world!") + } +} diff --git a/Fixtures/PIFBuilder/Library/.gitignore b/Fixtures/PIFBuilder/Library/.gitignore new file mode 100644 index 00000000000..0023a534063 --- /dev/null +++ b/Fixtures/PIFBuilder/Library/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Fixtures/PIFBuilder/Library/Package.swift b/Fixtures/PIFBuilder/Library/Package.swift new file mode 100644 index 00000000000..7cdecfeddff --- /dev/null +++ b/Fixtures/PIFBuilder/Library/Package.swift @@ -0,0 +1,36 @@ +// swift-tools-version: 6.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "Library", + products: [ + // Products define the executables and libraries a package produces, making them visible to other packages. + .library( + name: "LibraryAuto", + targets: ["Library"] + ), + .library( + name: "LibraryStatic", + type: .static, + targets: ["Library"] + ), + .library( + name: "LibraryDynamic", + type: .dynamic, + targets: ["Library"] + ), + ], + targets: [ + // Targets are the basic building blocks of a package, defining a module or a test suite. + // Targets can depend on other targets in this package and products from dependencies. + .target( + name: "Library" + ), + .testTarget( + name: "LibraryTests", + dependencies: ["Library"] + ), + ] +) diff --git a/Fixtures/PIFBuilder/Library/Sources/Library/Library.swift b/Fixtures/PIFBuilder/Library/Sources/Library/Library.swift new file mode 100644 index 00000000000..08b22b80fc0 --- /dev/null +++ b/Fixtures/PIFBuilder/Library/Sources/Library/Library.swift @@ -0,0 +1,2 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book diff --git a/Fixtures/PIFBuilder/Library/Tests/LibraryTests/LibraryTests.swift b/Fixtures/PIFBuilder/Library/Tests/LibraryTests/LibraryTests.swift new file mode 100644 index 00000000000..b1bc98df045 --- /dev/null +++ b/Fixtures/PIFBuilder/Library/Tests/LibraryTests/LibraryTests.swift @@ -0,0 +1,6 @@ +import Testing +@testable import Library + +@Test func example() async throws { + // Write your test here and use APIs like `#expect(...)` to check expected conditions. +} diff --git a/Fixtures/PIFBuilder/Simple/.gitignore b/Fixtures/PIFBuilder/Simple/.gitignore new file mode 100644 index 00000000000..0023a534063 --- /dev/null +++ b/Fixtures/PIFBuilder/Simple/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Fixtures/PIFBuilder/Simple/Package.swift b/Fixtures/PIFBuilder/Simple/Package.swift new file mode 100644 index 00000000000..4449f7edfff --- /dev/null +++ b/Fixtures/PIFBuilder/Simple/Package.swift @@ -0,0 +1,26 @@ +// swift-tools-version: 6.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "Simple", + products: [ + // Products define the executables and libraries a package produces, making them visible to other packages. + .library( + name: "Simple", + targets: ["Simple"] + ), + ], + targets: [ + // Targets are the basic building blocks of a package, defining a module or a test suite. + // Targets can depend on other targets in this package and products from dependencies. + .target( + name: "Simple" + ), + .testTarget( + name: "SimpleTests", + dependencies: ["Simple"] + ), + ] +) diff --git a/Fixtures/PIFBuilder/Simple/Sources/Simple/Simple.swift b/Fixtures/PIFBuilder/Simple/Sources/Simple/Simple.swift new file mode 100644 index 00000000000..551df789c2f --- /dev/null +++ b/Fixtures/PIFBuilder/Simple/Sources/Simple/Simple.swift @@ -0,0 +1,25 @@ +// The Swift Programming Language +// https://docs.swift.org/swift-book + +public struct Person { + public let name: String + + public init(name: String) { + self.name = name + } +} +extension Person: CustomStringConvertible { + public var description: String { + return name + } +} + +public func greet(person: Person? = nil) -> String { + let name = if let person { + person.name + } else { + "World" + } + + return "Hello, \(name)!" +} diff --git a/Fixtures/PIFBuilder/Simple/Tests/SimpleTests/SimpleTests.swift b/Fixtures/PIFBuilder/Simple/Tests/SimpleTests/SimpleTests.swift new file mode 100644 index 00000000000..55a56f80377 --- /dev/null +++ b/Fixtures/PIFBuilder/Simple/Tests/SimpleTests/SimpleTests.swift @@ -0,0 +1,36 @@ +import Testing +import XCTest + +import Simple + + +final public class XCTesting: XCTestCase { + func testGreetWithEmptyArgument() { + let actual = greet() + XCTAssertEqual(actual, "Hello, World!") + } + + func testGreetWithNonEmptyArgument() { + let name = "MyName" + let person = Person(name: name) + let actual = greet(person: person) + XCTAssertEqual(actual, "Hello, \(name)!") + } +} + +@Suite +struct STTestTests { + @Test("STTest tests") + func testGreetWithEmptyArgument() { + let actual = greet() + #expect(actual == "Hello, World!") + } + + @Test("STTest tests") + func testGreetWithNonEmptyArgument() { + let name = "MyName" + let person = Person(name: name) + let actual = greet(person: person) + #expect(actual == "Hello, \(name)!") + } +} diff --git a/NOTICE.txt b/NOTICE.txt index 5fa7c7bafaa..7710a0f3843 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -29,7 +29,7 @@ components that this product depends on. The dependency resolver is influenced by Dart project (pub tool). * LICENSE (BSD 3-Clause "New" or "Revised" License): - * https://github.com/dart-lang/pub/blob/master/LICENSE + * https://github.com/dart-lang/pub/blob/master/LICENSE // ignore-unacceptable-language * HOMEPAGE: * https://dart.dev * https://github.com/dart-lang/pub diff --git a/Package.swift b/Package.swift index aa32ba1e384..63bf3f76921 100644 --- a/Package.swift +++ b/Package.swift @@ -105,12 +105,14 @@ let swiftDriverDeps: [Target.Dependency] let swiftTSCBasicsDeps: [Target.Dependency] let swiftToolsCoreSupportAutoDeps: [Target.Dependency] let swiftTSCTestSupportDeps: [Target.Dependency] +let swiftToolsProtocolsDeps: [Target.Dependency] if shouldUseSwiftBuildFramework { swiftDriverDeps = [] swiftTSCBasicsDeps = [] swiftToolsCoreSupportAutoDeps = [] swiftTSCTestSupportDeps = [] + swiftToolsProtocolsDeps = [] } else { swiftDriverDeps = [ .product(name: "SwiftDriver", package: "swift-driver") @@ -124,6 +126,11 @@ if shouldUseSwiftBuildFramework { swiftTSCTestSupportDeps = [ .product(name: "TSCTestSupport", package: "swift-tools-support-core"), ] + swiftToolsProtocolsDeps = [ + .product(name: "BuildServerProtocol", package: "swift-tools-protocols", condition: .when(platforms: [.macOS, .linux, .windows, .android, .openbsd, .custom("freebsd")])), + .product(name: "LanguageServerProtocol", package: "swift-tools-protocols", condition: .when(platforms: [.macOS, .linux, .windows, .android, .openbsd, .custom("freebsd")])), + .product(name: "LanguageServerProtocolTransport", package: "swift-tools-protocols", condition: .when(platforms: [.macOS, .linux, .windows, .android, .openbsd, .custom("freebsd")])), + ] } let package = Package( name: "SwiftPM", @@ -547,6 +554,23 @@ let package = Package( ] ), + // MARK: BSP + .target( + name: "SwiftPMBuildServer", + dependencies: [ + "Basics", + "Build", + "PackageGraph", + "PackageLoading", + "PackageModel", + "SPMBuildCore", + "SourceControl", + "SourceKitLSPAPI", + "SwiftBuildSupport", + "Workspace" + ] + swiftTSCBasicsDeps + swiftToolsProtocolsDeps + ), + // MARK: Commands .target( @@ -575,6 +599,7 @@ let package = Package( dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), .product(name: "OrderedCollections", package: "swift-collections"), + .product(name: "SystemPackage", package: "swift-system"), "Basics", "BinarySymbols", "Build", @@ -585,6 +610,7 @@ let package = Package( "XCBuildSupport", "SwiftBuildSupport", "SwiftFixIt", + "SwiftPMBuildServer", ] + swiftSyntaxDependencies(["SwiftIDEUtils", "SwiftRefactor"]), exclude: ["CMakeLists.txt", "README.md"], swiftSettings: swift6CompatibleExperimentalFeatures + [ @@ -1055,6 +1081,13 @@ if ProcessInfo.processInfo.environment["SWIFTCI_DISABLE_SDK_DEPENDENT_TESTS"] == "dummy-swiftc", ] ), + .testTarget( + name: "SwiftPMBuildServerTests", + dependencies: [ + "SwiftPMBuildServer", + "_InternalTestSupport", + ] + swiftToolsProtocolsDeps + ), ]) } @@ -1151,7 +1184,7 @@ if ProcessInfo.processInfo.environment["ENABLE_APPLE_PRODUCT_TYPES"] == "1" { if !shouldUseSwiftBuildFramework { - let swiftbuildsupport: Target = package.targets.first(where: { $0.name == "SwiftBuildSupport" } )! + let swiftbuildsupport: Target = package.targets.first(where: { ["SwiftBuildSupport", "SwiftPMBuildServer", "SwiftPMBuildServerTests"].contains($0.name) } )! swiftbuildsupport.dependencies += [ .product(name: "SwiftBuild", package: "swift-build"), ] @@ -1164,10 +1197,12 @@ if !shouldUseSwiftBuildFramework { if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { package.dependencies += [ .package(url: "https://github.com/swiftlang/swift-build.git", branch: relatedDependenciesBranch), + .package(url: "https://github.com/swiftlang/swift-tools-protocols.git", .upToNextMinor(from: "0.0.9")), ] } else { package.dependencies += [ .package(path: "../swift-build"), + .package(path: "../swift-tools-protocols"), ] } } diff --git a/Sources/AppleProductTypes/Product.swift b/Sources/AppleProductTypes/Product.swift index 23f52a0a850..e4ae2ab2daf 100644 --- a/Sources/AppleProductTypes/Product.swift +++ b/Sources/AppleProductTypes/Product.swift @@ -1,12 +1,15 @@ -/* - This source file is part of the Swift.org open source project +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// - Copyright (c) 2021 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors -*/ @_spi(PackageProductSettings) import PackageDescription diff --git a/Sources/Basics/Cancellator.swift b/Sources/Basics/Cancellator.swift index 9cb30617d57..7925e1297e8 100644 --- a/Sources/Basics/Cancellator.swift +++ b/Sources/Basics/Cancellator.swift @@ -88,7 +88,7 @@ public final class Cancellator: Cancellable, Sendable { ) #endif sigaction(SIGINT, &action, nil) - kill(getpid(), SIGINT) + kill(getpid(), SIGINT) // ignore-unacceptable-language } interruptSignalSource.resume() #endif @@ -229,7 +229,7 @@ extension AsyncProcess { let forceKillSemaphore = DispatchSemaphore(value: 0) let forceKillThread = TSCBasic.Thread { if case .timedOut = forceKillSemaphore.wait(timeout: timeout) { - // send a force-kill signal + // send a force-kill signal // ignore-unacceptable-language #if os(Windows) self.signal(SIGTERM) #else @@ -239,8 +239,8 @@ extension AsyncProcess { } forceKillThread.start() _ = try? self.waitUntilExit() - forceKillSemaphore.signal() // let the force-kill thread know we do not need it any more - // join the force-kill thread thread so we don't exit before everything terminates + forceKillSemaphore.signal() // let the force-kill thread know we do not need it any more //ignore-unacceptable-language + // join the force-kill thread thread so we don't exit before everything terminates //ignore-unacceptable-language forceKillThread.join() } } @@ -263,14 +263,14 @@ extension Foundation.Process { return } - // force kill (SIGTERM) + // force kill (SIGTERM) // ignore-unacceptable-language self.terminate() } } forceKillThread.start() self.waitUntilExit() - forceKillSemaphore.signal() // let the force-kill thread know we do not need it any more - // join the force-kill thread thread so we don't exit before everything terminates + forceKillSemaphore.signal() // let the force-kill thread know we do not need it any more //ignore-unacceptable-language + // join the force-kill thread thread so we don't exit before everything terminates //ignore-unacceptable-language forceKillThread.join() } } diff --git a/Sources/Basics/Concurrency/AsyncProcess.swift b/Sources/Basics/Concurrency/AsyncProcess.swift index 17149e833bc..f86d465c3c6 100644 --- a/Sources/Basics/Concurrency/AsyncProcess.swift +++ b/Sources/Basics/Concurrency/AsyncProcess.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014-2020 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import _Concurrency import Dispatch @@ -342,7 +344,7 @@ package final class AsyncProcess { /// - workingDirectory: The path to the directory under which to run the process. /// - outputRedirection: How process redirects its output. Default value is .collect. /// - startNewProcessGroup: If true, a new progress group is created for the child making it - /// continue running even if the parent is killed or interrupted. Default value is true. + /// continue running even if the parent is killed or interrupted. Default value is true. //ignore-unacceptable-language /// - loggingHandler: Handler for logging messages /// package init( @@ -370,7 +372,7 @@ package final class AsyncProcess { /// - outputRedirection: How process redirects its output. Default value is .collect. /// - verbose: If true, launch() will print the arguments of the subprocess before launching it. /// - startNewProcessGroup: If true, a new progress group is created for the child making it - /// continue running even if the parent is killed or interrupted. Default value is true. + /// continue running even if the parent is killed or interrupted. Default value is true. //ignore-unacceptable-language /// - loggingHandler: Handler for logging messages package init( arguments: [String], @@ -517,7 +519,8 @@ package final class AsyncProcess { group.enter() stdoutPipe.fileHandleForReading.readabilityHandler = { (fh: FileHandle) in - let data = (try? fh.read(upToCount: Int.max)) ?? Data() + // 4096 is default pipe buffer size so reading in that size seems most efficient and still get output as it available + let data = (try? fh.read(upToCount: 4096)) ?? Data() if data.count == 0 { stdoutPipe.fileHandleForReading.readabilityHandler = nil group.leave() @@ -532,7 +535,8 @@ package final class AsyncProcess { group.enter() stderrPipe.fileHandleForReading.readabilityHandler = { (fh: FileHandle) in - let data = (try? fh.read(upToCount: Int.max)) ?? Data() + // 4096 is default pipe buffer size so reading in that size seems most efficient and still get output as it available + let data = (try? fh.read(upToCount: 4096)) ?? Data() if data.count == 0 { stderrPipe.fileHandleForReading.readabilityHandler = nil group.leave() @@ -933,7 +937,7 @@ package final class AsyncProcess { } #else assert(self.launched, "The process is not yet launched.") - kill(self.startNewProcessGroup ? -self.processID : self.processID, signal) + kill(self.startNewProcessGroup ? -self.processID : self.processID, signal) //ignore-unacceptable-language #endif } } diff --git a/Sources/Basics/Concurrency/ThreadSafeBox.swift b/Sources/Basics/Concurrency/ThreadSafeBox.swift index c05347a46ad..272415bcaaa 100644 --- a/Sources/Basics/Concurrency/ThreadSafeBox.swift +++ b/Sources/Basics/Concurrency/ThreadSafeBox.swift @@ -85,6 +85,14 @@ public final class ThreadSafeBox { } } + public func takeValue() -> Value where U? == Value { + self.lock.withLock { + guard let value = self.underlying else { return nil } + self.underlying = nil + return value + } + } + public subscript(dynamicMember keyPath: KeyPath) -> T? { self.lock.withLock { self.underlying?[keyPath: keyPath] diff --git a/Sources/Basics/Concurrency/ThrowingDefer.swift b/Sources/Basics/Concurrency/ThrowingDefer.swift index fdf821f7c96..3d882a2fa15 100644 --- a/Sources/Basics/Concurrency/ThrowingDefer.swift +++ b/Sources/Basics/Concurrency/ThrowingDefer.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/Basics/FileSystem/InMemoryFileSystem.swift b/Sources/Basics/FileSystem/InMemoryFileSystem.swift index 0853f607b31..be363eff72b 100644 --- a/Sources/Basics/FileSystem/InMemoryFileSystem.swift +++ b/Sources/Basics/FileSystem/InMemoryFileSystem.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import class Foundation.NSLock import class Dispatch.DispatchQueue @@ -23,7 +25,7 @@ public final class InMemoryFileSystem: FileSystem { private class Node { /// The actual node data. let contents: NodeContents - + /// Whether the node has executable bit enabled. var isExecutable: Bool @@ -502,7 +504,7 @@ public final class InMemoryFileSystem: FileSystem { return try fileQueue.sync(flags: type == .exclusive ? .barrier : .init() , execute: body) } - + public func withLock(on path: TSCBasic.AbsolutePath, type: FileLock.LockType, blocking: Bool, _ body: () throws -> T) throws -> T { try self.withLock(on: path, type: type, body) } diff --git a/Sources/Basics/Process.swift b/Sources/Basics/Process.swift index 91eb926655c..1b4af9fa5d2 100644 --- a/Sources/Basics/Process.swift +++ b/Sources/Basics/Process.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// public import Foundation diff --git a/Sources/Basics/Triple+Basics.swift b/Sources/Basics/Triple+Basics.swift index e1f33bd31dc..da99407bd78 100644 --- a/Sources/Basics/Triple+Basics.swift +++ b/Sources/Basics/Triple+Basics.swift @@ -217,7 +217,6 @@ extension Triple { case _ where isDarwin(): return ".bundle" default: - // See: https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/FHS%20Bundles.md return ".resources" } } diff --git a/Sources/Basics/Vendor/Triple+Platforms.swift b/Sources/Basics/Vendor/Triple+Platforms.swift index d26931b0ca7..b4bd95ad1b7 100644 --- a/Sources/Basics/Vendor/Triple+Platforms.swift +++ b/Sources/Basics/Vendor/Triple+Platforms.swift @@ -1,12 +1,12 @@ -//===--------------- Triple+Platforms.swift - Swift Platform Triples ------===// +//===----------------------------------------------------------------------===// // -// This source file is part of the Swift.org open source project +// This source file is part of the Swift open source project // // Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// @@ -357,7 +357,7 @@ public struct FeatureAvailability: Sendable { case available(since: Version) case availableInAllVersions } - + public let macOS: Availability public let iOS: Availability public let tvOS: Availability @@ -404,7 +404,7 @@ public struct FeatureAvailability: Sendable { guard let darwinPlatform = darwinPlatform else { return feature.nonDarwin } - + switch feature[darwinPlatform] { case .unavailable: return false diff --git a/Sources/Basics/Vendor/Triple.swift b/Sources/Basics/Vendor/Triple.swift index 441962f43ea..4688a56eb5d 100644 --- a/Sources/Basics/Vendor/Triple.swift +++ b/Sources/Basics/Vendor/Triple.swift @@ -1,12 +1,12 @@ -//===--------------- Triple.swift - Swift Target Triples ------------------===// +//===----------------------------------------------------------------------===// // -// This source file is part of the Swift.org open source project +// This source file is part of the Swift open source project // // Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/BinarySymbols/ClangHostDefaultObjectsDetector.swift b/Sources/BinarySymbols/ClangHostDefaultObjectsDetector.swift index ef22c3968d6..0650f333076 100644 --- a/Sources/BinarySymbols/ClangHostDefaultObjectsDetector.swift +++ b/Sources/BinarySymbols/ClangHostDefaultObjectsDetector.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics import Foundation diff --git a/Sources/BinarySymbols/LLVMObjdumpSymbolProvider.swift b/Sources/BinarySymbols/LLVMObjdumpSymbolProvider.swift index 70db3c39e82..194156f0579 100644 --- a/Sources/BinarySymbols/LLVMObjdumpSymbolProvider.swift +++ b/Sources/BinarySymbols/LLVMObjdumpSymbolProvider.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics import RegexBuilder diff --git a/Sources/BinarySymbols/ReferencedSymbols.swift b/Sources/BinarySymbols/ReferencedSymbols.swift index 13200282409..c287f15c940 100644 --- a/Sources/BinarySymbols/ReferencedSymbols.swift +++ b/Sources/BinarySymbols/ReferencedSymbols.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// package struct ReferencedSymbols { package private(set) var defined: Set diff --git a/Sources/BinarySymbols/SymbolProvider.swift b/Sources/BinarySymbols/SymbolProvider.swift index 29f4ee98c26..0fb09f50ac5 100644 --- a/Sources/BinarySymbols/SymbolProvider.swift +++ b/Sources/BinarySymbols/SymbolProvider.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics diff --git a/Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift b/Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift index 9a59bf3fff2..0115bb07e2f 100644 --- a/Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift +++ b/Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift @@ -791,7 +791,7 @@ public final class SwiftModuleBuildDescription { } func writeOutputFileMap(to path: AbsolutePath) throws { - let masterDepsPath = self.tempsPath.appending("master.swiftdeps") + let primateDepsPath = self.tempsPath.appending("primary.swiftdeps") var content = #""" @@ -822,7 +822,7 @@ public final class SwiftModuleBuildDescription { } content += #""" - "swift-dependencies": "\#(masterDepsPath._nativePathString(escaped: true))" + "swift-dependencies": "\#(primateDepsPath._nativePathString(escaped: true))" }, """# @@ -1043,7 +1043,7 @@ public final class SwiftModuleBuildDescription { let toolchainFlags = self.buildParameters.toolchain.extraFlags.swiftCompilerFlags if toolchainFlags.contains(queryFlags) { return true } - + let generalFlags = self.buildParameters.flags.swiftCompilerFlags if generalFlags.contains(queryFlags) { return true } diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 20d0958b12b..bac60ca6383 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -40,6 +40,7 @@ add_subdirectory(swift-sdk) add_subdirectory(swift-package) add_subdirectory(swift-run) add_subdirectory(swift-test) +add_subdirectory(SwiftPMBuildServer) add_subdirectory(SwiftSDKCommand) add_subdirectory(Workspace) add_subdirectory(XCBuildSupport) diff --git a/Sources/Commands/CMakeLists.txt b/Sources/Commands/CMakeLists.txt index 303944aebcc..b7e4e4b84d0 100644 --- a/Sources/Commands/CMakeLists.txt +++ b/Sources/Commands/CMakeLists.txt @@ -15,6 +15,7 @@ add_library(Commands PackageCommands/APIDiff.swift PackageCommands/ArchiveSource.swift PackageCommands/AuditBinaryArtifact.swift + PackageCommands/BuildServer.swift PackageCommands/CompletionCommand.swift PackageCommands/ComputeChecksum.swift PackageCommands/Config.swift @@ -61,6 +62,7 @@ add_library(Commands target_link_libraries(Commands PUBLIC SwiftCollections::OrderedCollections SwiftSyntax::SwiftRefactor + SwiftSystem::SystemPackage ArgumentParser Basics BinarySymbols @@ -70,6 +72,7 @@ target_link_libraries(Commands PUBLIC PackageGraph SourceControl SwiftFixIt + SwiftPMBuildServer TSCBasic TSCUtility Workspace diff --git a/Sources/Commands/PackageCommands/BuildServer.swift b/Sources/Commands/PackageCommands/BuildServer.swift new file mode 100644 index 00000000000..f088bd6a174 --- /dev/null +++ b/Sources/Commands/PackageCommands/BuildServer.swift @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// +#if canImport(LanguageServerProtocolTransport) +import ArgumentParser +import TSCBasic +import SwiftBuild +import BuildServerProtocol +import LanguageServerProtocol +import LanguageServerProtocolTransport +import CoreCommands +import Foundation +import PackageGraph +import SwiftPMBuildServer +import SPMBuildCore +import SwiftBuildSupport +import SystemPackage + +struct BuildServer: AsyncSwiftCommand { + static let configuration = CommandConfiguration( + commandName: "experimental-build-server", + abstract: "Launch a build server for Swift Packages", + shouldDisplay: false + ) + + @OptionGroup(visibility: .hidden) + var globalOptions: GlobalOptions + + func run(_ swiftCommandState: SwiftCommandState) async throws { + // Dup stdout and redirect the fd to stderr so that a careless print() + // will not break our connection stream. + let realStdout = try FileDescriptor.standardOutput.duplicate() + _ = try FileDescriptor.standardError.duplicate(as: FileDescriptor.standardOutput) + + let realStdoutHandle = FileHandle(fileDescriptor: realStdout.rawValue, closeOnDealloc: false) + + let clientConnection = JSONRPCConnection( + name: "client", + protocol: MessageRegistry.bspProtocol, + inFD: FileHandle.standardInput, + outFD: realStdoutHandle, + inputMirrorFile: nil, + outputMirrorFile: nil + ) + + guard let buildSystem = try await swiftCommandState.createBuildSystem() as? SwiftBuildSystem else { + throw ArgumentParser.ValidationError("Build server requires --build-system swiftbuild") + } + + guard let packagePath = try swiftCommandState.getWorkspaceRoot().packages.first else { + throw ArgumentParser.ValidationError("unknown package") + } + + let server = try await SwiftPMBuildServer( + packageRoot: packagePath, + buildSystem: buildSystem, + workspace: swiftCommandState.getActiveWorkspace(), + connectionToClient: clientConnection, + exitHandler: {_ in clientConnection.close() } + ) + await withCheckedContinuation {continuation in + clientConnection.start(receiveHandler: server, closeHandler: { continuation.resume() }) + } + } +} +#endif diff --git a/Sources/Commands/PackageCommands/DumpCommands.swift b/Sources/Commands/PackageCommands/DumpCommands.swift index f0b5aa81da1..46c6616da11 100644 --- a/Sources/Commands/PackageCommands/DumpCommands.swift +++ b/Sources/Commands/PackageCommands/DumpCommands.swift @@ -201,7 +201,7 @@ struct DumpPIF: AsyncSwiftCommand { } fileprivate extension BuildOutput.SymbolGraphAccessLevel { - fileprivate static func accessLevel(_ accessLevel: SymbolGraphExtract.AccessLevel) -> BuildOutput.SymbolGraphAccessLevel { + static func accessLevel(_ accessLevel: SymbolGraphExtract.AccessLevel) -> BuildOutput.SymbolGraphAccessLevel { return BuildOutput.SymbolGraphAccessLevel.init(rawValue: accessLevel.rawValue)! } } diff --git a/Sources/Commands/PackageCommands/SwiftPackageCommand.swift b/Sources/Commands/PackageCommands/SwiftPackageCommand.swift index 6c7437fe991..efd5bd0f83d 100644 --- a/Sources/Commands/PackageCommands/SwiftPackageCommand.swift +++ b/Sources/Commands/PackageCommands/SwiftPackageCommand.swift @@ -26,13 +26,9 @@ import enum TSCUtility.Diagnostics /// swift-package tool namespace public struct SwiftPackageCommand: AsyncParsableCommand { - public static var configuration = CommandConfiguration( - commandName: "package", - _superCommandName: "swift", - abstract: "Perform operations on Swift packages.", - discussion: "SEE ALSO: swift build, swift run, swift test \n(Run this command without --help to see possible dynamic plugin commands.)", - version: SwiftVersion.current.completeDisplayString, - subcommands: [ + + private static var subcommands: [any ParsableCommand.Type] = { + var subcommands: [any ParsableCommand.Type] = [ AddDependency.self, AddProduct.self, AddTarget.self, @@ -75,7 +71,22 @@ public struct SwiftPackageCommand: AsyncParsableCommand { DefaultCommand.self, ] - + (ProcessInfo.processInfo.environment["SWIFTPM_ENABLE_SNIPPETS"] == "1" ? [Learn.self] : []), + if ProcessInfo.processInfo.environment["SWIFTPM_ENABLE_SNIPPETS"] == "1" { + subcommands.append(Learn.self) + } + #if canImport(LanguageServerProtocol) + subcommands.append(BuildServer.self) + #endif + return subcommands + }() + + public static var configuration = CommandConfiguration( + commandName: "package", + _superCommandName: "swift", + abstract: "Perform operations on Swift packages.", + discussion: "SEE ALSO: swift build, swift run, swift test \n(Run this command without --help to see possible dynamic plugin commands.)", + version: SwiftVersion.current.completeDisplayString, + subcommands: Self.subcommands, defaultSubcommand: DefaultCommand.self, helpNames: [] ) diff --git a/Sources/Commands/Utilities/PluginDelegate.swift b/Sources/Commands/Utilities/PluginDelegate.swift index e5e82f10126..596cc03dc60 100644 --- a/Sources/Commands/Utilities/PluginDelegate.swift +++ b/Sources/Commands/Utilities/PluginDelegate.swift @@ -181,11 +181,11 @@ final class PluginDelegate: PluginInvocationDelegate { let result = await buildSystem.buildIgnoringError(subset: buildSubset, buildOutputs: [.builtArtifacts]) let success = result != nil - let packageGraph = try await buildSystem.getPackageGraph() + _ = try await buildSystem.getPackageGraph() - var builtArtifacts: [PluginInvocationBuildResult.BuiltArtifact] = (result?.builtArtifacts ?? []).filter { (name, _) in + let builtArtifacts: [PluginInvocationBuildResult.BuiltArtifact] = (result?.builtArtifacts ?? []).filter { (name, _) in switch subset { - case .all(let includingTests): + case .all: return true case .product(let productName): return name == productName diff --git a/Sources/PackageCollectionsSigning/Signature.swift b/Sources/PackageCollectionsSigning/Signature.swift index 76e27d45d10..7a7ac509723 100644 --- a/Sources/PackageCollectionsSigning/Signature.swift +++ b/Sources/PackageCollectionsSigning/Signature.swift @@ -64,7 +64,7 @@ extension Signature { } } -// Reference: https://github.com/vapor/jwt-kit/blob/master/Sources/JWTKit/JWTSerializer.swift +// Reference: https://github.com/vapor/jwt-kit/blob/main/Sources/JWTKit/JWTSerializer.swift extension Signature { static let rsaSigningPadding = _RSA.Signing.Padding.insecurePKCS1v1_5 @@ -100,7 +100,7 @@ extension Signature { } } -// Reference: https://github.com/vapor/jwt-kit/blob/master/Sources/JWTKit/JWTParser.swift +// Reference: https://github.com/vapor/jwt-kit/blob/main/Sources/JWTKit/JWTParser.swift extension Signature { typealias CertChainValidate = ([Data]) async throws -> [Certificate] diff --git a/Sources/PackageCollectionsSigning/Utilities/Base64URL.swift b/Sources/PackageCollectionsSigning/Utilities/Base64URL.swift index bae48bb4c62..fa803b7052e 100644 --- a/Sources/PackageCollectionsSigning/Utilities/Base64URL.swift +++ b/Sources/PackageCollectionsSigning/Utilities/Base64URL.swift @@ -25,7 +25,7 @@ import Foundation -// Source: https://github.com/vapor/jwt-kit/blob/master/Sources/JWTKit/Utilities/Base64URL.swift +// Source: https://github.com/vapor/jwt-kit/blob/main/Sources/JWTKit/Utilities/Base64URL.swift extension DataProtocol { func base64URLDecodedBytes() -> Data? { diff --git a/Sources/PackageCollectionsSigning/embedded_resources.swift b/Sources/PackageCollectionsSigning/embedded_resources.swift index a1dbeb69b2f..351c58990c9 100644 --- a/Sources/PackageCollectionsSigning/embedded_resources.swift +++ b/Sources/PackageCollectionsSigning/embedded_resources.swift @@ -1,3 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + struct PackageResources { static let AppleWWDRCAG2_cer: [UInt8] = [48,130,2,247,48,130,2,124,160,3,2,1,2,2,8,111,239,216,245,233,163,167,238,48,10,6,8,42,134,72,206,61,4,3,2,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,30,23,13,49,52,48,53,48,54,50,51,52,51,50,52,90,23,13,50,57,48,53,48,54,50,51,52,51,50,52,90,48,129,128,49,52,48,50,6,3,85,4,3,12,43,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,65,32,45,32,71,50,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,89,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,66,0,4,221,240,183,6,75,207,221,115,4,19,196,67,137,3,147,128,251,94,246,116,173,66,97,82,88,2,38,83,25,200,99,34,7,9,82,97,202,196,217,87,239,109,38,104,139,116,145,140,196,249,128,104,40,252,9,104,240,16,218,233,208,46,201,26,163,129,247,48,129,244,48,70,6,8,43,6,1,5,5,7,1,1,4,58,48,56,48,54,6,8,43,6,1,5,5,7,48,1,134,42,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,52,45,97,112,112,108,101,114,111,111,116,99,97,103,51,48,29,6,3,85,29,14,4,22,4,20,132,182,132,204,58,134,98,114,22,89,148,232,26,163,189,72,223,58,223,11,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,31,6,3,85,29,35,4,24,48,22,128,20,187,176,222,161,88,51,136,154,164,138,153,222,190,189,235,175,218,203,36,171,48,55,6,3,85,29,31,4,48,48,46,48,44,160,42,160,40,134,38,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,97,112,112,108,101,114,111,111,116,99,97,103,51,46,99,114,108,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,15,4,2,5,0,48,10,6,8,42,134,72,206,61,4,3,2,3,105,0,48,102,2,49,0,217,177,199,49,198,35,246,79,77,208,217,71,197,125,24,105,17,135,113,39,211,104,173,224,155,101,154,190,108,223,63,70,166,144,9,190,110,161,59,44,176,81,137,65,60,135,210,191,2,49,0,252,100,82,137,75,60,93,191,107,28,194,137,152,47,114,174,181,155,170,26,11,35,84,119,84,232,21,67,162,197,18,218,151,80,115,124,94,208,110,178,92,98,80,215,81,241,58,90] static let AppleWWDRCAG3_cer: [UInt8] = [48,130,4,81,48,130,3,57,160,3,2,1,2,2,16,124,175,105,10,37,183,57,254,123,155,68,122,193,120,197,238,48,13,6,9,42,134,72,134,247,13,1,1,11,5,0,48,98,49,11,48,9,6,3,85,4,6,19,2,85,83,49,19,48,17,6,3,85,4,10,19,10,65,112,112,108,101,32,73,110,99,46,49,38,48,36,6,3,85,4,11,19,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,22,48,20,6,3,85,4,3,19,13,65,112,112,108,101,32,82,111,111,116,32,67,65,48,30,23,13,50,48,48,50,49,57,49,56,49,51,52,55,90,23,13,51,48,48,50,50,48,48,48,48,48,48,48,90,48,117,49,68,48,66,6,3,85,4,3,12,59,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,11,48,9,6,3,85,4,11,12,2,71,51,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,130,1,34,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,130,1,15,0,48,130,1,10,2,130,1,1,0,216,245,137,252,168,89,11,135,199,76,145,46,45,86,144,211,120,29,164,48,233,165,72,239,11,67,191,45,132,251,36,93,69,27,229,235,89,54,18,92,84,100,158,108,98,45,180,198,151,202,204,60,246,214,6,145,252,229,2,166,28,106,180,121,213,103,203,172,233,63,7,17,225,132,188,71,29,102,142,57,162,232,180,73,237,58,210,225,16,96,122,142,147,140,202,192,218,12,192,131,208,227,249,145,214,167,140,200,193,115,226,174,70,209,98,157,146,168,144,96,55,125,104,150,205,141,224,252,155,250,120,187,227,123,175,45,23,221,91,254,128,89,35,117,23,184,18,193,237,27,229,52,206,254,34,181,158,73,176,229,85,191,143,132,162,60,168,186,197,134,149,22,228,0,201,159,3,208,204,179,58,22,123,214,5,92,157,235,71,174,13,181,45,140,14,105,77,64,208,75,76,59,4,158,141,33,177,172,46,67,84,48,206,193,138,134,148,152,75,223,106,13,63,254,251,28,174,151,23,194,120,10,48,224,95,31,84,59,73,183,37,0,26,55,130,210,86,151,165,82,73,124,96,56,155,239,2,3,1,0,1,163,129,239,48,129,236,48,18,6,3,85,29,19,1,1,255,4,8,48,6,1,1,255,2,1,0,48,31,6,3,85,29,35,4,24,48,22,128,20,43,208,105,71,148,118,9,254,244,107,141,46,64,166,247,71,77,127,8,94,48,68,6,8,43,6,1,5,5,7,1,1,4,56,48,54,48,52,6,8,43,6,1,5,5,7,48,1,134,40,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,51,45,97,112,112,108,101,114,111,111,116,99,97,48,46,6,3,85,29,31,4,39,48,37,48,35,160,33,160,31,134,29,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,114,111,111,116,46,99,114,108,48,29,6,3,85,29,14,4,22,4,20,9,254,192,21,144,249,175,100,10,146,18,185,38,40,99,12,151,236,167,178,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,1,4,2,5,0,48,13,6,9,42,134,72,134,247,13,1,1,11,5,0,3,130,1,1,0,173,101,19,232,246,224,129,119,68,2,71,66,190,95,165,57,32,234,98,169,253,197,144,201,115,19,213,158,155,208,170,15,141,141,203,237,1,207,108,40,64,91,199,85,36,65,248,252,207,193,181,35,233,220,236,241,111,202,128,29,119,194,196,97,73,37,103,175,15,202,57,37,173,211,227,122,204,51,40,13,14,46,161,87,64,115,250,230,92,174,6,81,41,237,227,133,12,79,97,220,50,22,139,119,208,68,202,93,114,3,49,70,156,174,155,64,26,250,244,224,211,62,250,47,140,102,159,151,196,84,89,239,210,72,244,7,153,73,96,89,25,199,221,148,209,192,193,108,127,120,33,239,12,235,59,108,153,130,75,82,96,56,181,57,130,109,236,82,49,83,190,15,145,76,73,73,116,143,166,81,203,132,71,78,29,117,39,110,189,249,210,92,243,127,194,108,11,9,54,226,100,228,194,55,3,20,25,213,234,106,148,170,169,219,254,246,154,8,103,139,239,43,184,170,23,73,131,175,207,203,188,233,207,234,149,113,176,180,69,162,204,229,135,170,10,195,65,58,121,92,218,80,52,157,149,59] @@ -10,4 +22,4 @@ static let AppleWWDRCAG4_cer: [UInt8] = [48,130,4,85,48,130,3,61,160,3,2,1,2,2,2 static let AppleWWDRCAG6_cer: [UInt8] = [48,130,3,22,48,130,2,156,160,3,2,1,2,2,20,34,193,161,71,10,116,115,105,239,83,134,18,201,198,159,61,56,243,108,215,48,10,6,8,42,134,72,206,61,4,3,3,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,30,23,13,50,49,48,51,49,55,50,48,51,55,49,48,90,23,13,51,54,48,51,49,57,48,48,48,48,48,48,90,48,117,49,68,48,66,6,3,85,4,3,12,59,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,11,48,9,6,3,85,4,11,12,2,71,54,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,110,196,10,11,222,15,174,85,166,101,121,215,130,220,115,117,82,75,241,61,18,25,137,224,13,17,169,158,9,247,55,163,211,240,147,4,111,177,67,139,134,193,152,248,66,157,157,255,178,174,143,23,247,6,112,165,214,176,190,111,58,215,145,135,34,120,231,29,192,72,254,220,56,31,154,106,143,116,125,202,113,74,255,196,100,86,231,136,6,205,129,145,161,34,26,72,163,129,250,48,129,247,48,18,6,3,85,29,19,1,1,255,4,8,48,6,1,1,255,2,1,0,48,31,6,3,85,29,35,4,24,48,22,128,20,187,176,222,161,88,51,136,154,164,138,153,222,190,189,235,175,218,203,36,171,48,70,6,8,43,6,1,5,5,7,1,1,4,58,48,56,48,54,6,8,43,6,1,5,5,7,48,1,134,42,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,51,45,97,112,112,108,101,114,111,111,116,99,97,103,51,48,55,6,3,85,29,31,4,48,48,46,48,44,160,42,160,40,134,38,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,97,112,112,108,101,114,111,111,116,99,97,103,51,46,99,114,108,48,29,6,3,85,29,14,4,22,4,20,63,47,148,35,81,211,80,201,154,40,61,237,176,124,229,207,165,144,98,153,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,1,4,2,5,0,48,10,6,8,42,134,72,206,61,4,3,3,3,104,0,48,101,2,48,64,94,20,170,228,140,138,162,3,2,62,220,56,247,64,90,7,174,251,9,161,6,37,123,159,64,31,196,169,145,157,232,36,163,136,43,78,158,227,19,109,117,87,155,28,92,197,249,2,49,0,211,72,252,90,173,149,239,54,185,49,83,116,228,80,194,55,223,44,239,21,85,81,79,140,49,88,144,189,247,131,172,117,198,120,249,17,141,177,128,242,71,152,38,118,189,39,12,104] static let AppleWWDRCAG8_cer: [UInt8] = [48,130,4,85,48,130,3,61,160,3,2,1,2,2,20,84,181,11,175,121,13,141,127,140,175,104,76,86,47,80,105,10,26,186,95,48,13,6,9,42,134,72,134,247,13,1,1,5,5,0,48,98,49,11,48,9,6,3,85,4,6,19,2,85,83,49,19,48,17,6,3,85,4,10,19,10,65,112,112,108,101,32,73,110,99,46,49,38,48,36,6,3,85,4,11,19,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,22,48,20,6,3,85,4,3,19,13,65,112,112,108,101,32,82,111,111,116,32,67,65,48,30,23,13,50,51,48,54,50,48,50,51,51,55,49,53,90,23,13,50,53,48,49,50,52,48,48,48,48,48,48,90,48,117,49,11,48,9,6,3,85,4,6,19,2,85,83,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,11,12,2,71,56,49,68,48,66,6,3,85,4,3,12,59,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,48,130,1,34,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,130,1,15,0,48,130,1,10,2,130,1,1,0,208,64,16,212,8,249,82,33,99,79,60,104,247,212,156,130,2,140,131,104,188,183,141,127,136,231,66,77,44,239,34,165,194,137,222,189,12,215,77,97,80,45,57,228,48,115,165,210,213,104,154,51,242,239,217,42,173,46,31,3,186,248,165,241,66,11,87,46,70,198,208,88,211,112,95,247,178,55,239,106,31,62,191,137,57,194,173,254,245,5,251,88,150,49,200,135,44,213,35,186,117,176,44,245,171,160,186,242,32,12,76,235,36,99,105,233,34,64,240,142,88,91,222,100,123,137,27,81,18,4,224,23,178,89,205,223,241,231,206,175,44,50,232,105,193,208,8,126,29,162,71,115,209,75,59,253,185,133,220,71,167,40,130,121,41,72,137,2,40,226,193,236,44,31,91,134,252,216,182,203,113,192,115,1,75,252,5,17,17,108,1,3,52,90,246,129,194,94,31,124,20,14,222,63,107,33,203,79,245,215,97,230,132,3,146,188,231,37,41,158,205,91,12,193,219,227,196,58,217,118,87,172,47,56,20,25,200,183,177,162,85,79,95,78,142,25,89,169,218,253,114,218,176,4,33,5,2,3,1,0,1,163,129,239,48,129,236,48,18,6,3,85,29,19,1,1,255,4,8,48,6,1,1,255,2,1,0,48,31,6,3,85,29,35,4,24,48,22,128,20,43,208,105,71,148,118,9,254,244,107,141,46,64,166,247,71,77,127,8,94,48,68,6,8,43,6,1,5,5,7,1,1,4,56,48,54,48,52,6,8,43,6,1,5,5,7,48,1,134,40,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,51,45,97,112,112,108,101,114,111,111,116,99,97,48,46,6,3,85,29,31,4,39,48,37,48,35,160,33,160,31,134,29,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,114,111,111,116,46,99,114,108,48,29,6,3,85,29,14,4,22,4,20,181,189,188,128,196,12,227,56,164,244,183,173,35,179,239,68,206,185,90,133,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,1,4,2,5,0,48,13,6,9,42,134,72,134,247,13,1,1,5,5,0,3,130,1,1,0,76,179,235,122,57,148,74,149,102,250,22,49,234,13,138,143,93,66,56,198,7,205,232,201,34,172,252,8,66,126,95,147,95,49,42,168,34,193,118,25,43,238,174,114,233,189,86,207,73,36,146,8,247,205,25,117,195,249,26,39,13,14,220,41,141,63,182,219,165,79,76,114,196,96,145,137,17,126,36,149,67,34,96,103,188,223,255,171,229,60,22,23,157,130,20,78,157,244,117,254,80,185,173,5,178,184,121,246,149,214,16,229,246,83,244,207,35,230,119,15,236,184,75,105,248,226,158,2,49,217,142,217,202,190,99,94,95,225,160,105,206,193,205,110,73,163,120,97,175,57,60,106,75,10,52,37,100,213,48,181,60,171,221,17,129,57,113,232,192,195,88,128,17,16,26,17,210,194,188,89,240,138,217,53,115,192,230,109,228,201,125,98,20,62,130,2,169,16,105,55,121,97,111,240,70,148,62,53,245,171,172,99,208,216,94,89,87,105,209,184,75,110,93,212,95,19,156,112,78,37,17,220,36,44,30,22,158,150,90,4,237,69,238,58,238,103,93,143,195,134,176,245,76,31,104,16] static let AppleRootCA_G3_cer: [UInt8] = [48,130,2,67,48,130,1,201,160,3,2,1,2,2,8,45,197,252,136,210,197,75,149,48,10,6,8,42,134,72,206,61,4,3,3,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,30,23,13,49,52,48,52,51,48,49,56,49,57,48,54,90,23,13,51,57,48,52,51,48,49,56,49,57,48,54,90,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,152,233,47,61,64,114,164,237,147,34,114,129,19,28,221,16,149,241,197,163,78,113,220,20,22,217,14,229,166,5,42,119,100,123,95,78,56,211,187,28,68,181,127,245,31,182,50,98,93,201,233,132,91,79,48,79,17,90,0,253,88,88,12,165,245,15,44,77,7,71,19,117,218,151,151,151,111,49,92,237,43,157,123,32,59,216,185,84,217,94,153,164,58,81,10,49,163,66,48,64,48,29,6,3,85,29,14,4,22,4,20,187,176,222,161,88,51,136,154,164,138,153,222,190,189,235,175,218,203,36,171,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,10,6,8,42,134,72,206,61,4,3,3,3,104,0,48,101,2,49,0,131,233,193,196,22,94,26,93,52,24,217,237,239,244,108,14,0,70,75,184,223,178,70,17,197,15,253,230,122,140,161,166,107,206,194,3,212,156,245,147,198,116,184,106,223,170,35,21,2,48,109,102,138,16,202,212,13,212,79,205,141,67,62,180,138,99,165,51,110,227,109,218,23,183,100,31,200,83,38,249,136,98,116,57,11,23,91,203,81,168,12,232,24,3,231,162,178,40] -} \ No newline at end of file +} diff --git a/Sources/PackageGraph/Resolution/PubGrub/PubGrubDependencyResolver.swift b/Sources/PackageGraph/Resolution/PubGrub/PubGrubDependencyResolver.swift index a8ae0399409..762795b3a32 100644 --- a/Sources/PackageGraph/Resolution/PubGrub/PubGrubDependencyResolver.swift +++ b/Sources/PackageGraph/Resolution/PubGrub/PubGrubDependencyResolver.swift @@ -573,8 +573,8 @@ public struct PubGrubDependencyResolver { } // Based on: - // https://github.com/dart-lang/pub/tree/master/doc/solver.md#conflict-resolution - // https://github.com/dart-lang/pub/blob/master/lib/src/solver/version_solver.dart#L201 + // https://github.com/dart-lang/pub/tree/master/doc/solver.md#conflict-resolution //ignore-unacceptable-language + // https://github.com/dart-lang/pub/blob/master/lib/src/solver/version_solver.dart#L201 //ignore-unacceptable-language internal func resolve(state: State, conflict: Incompatibility) throws -> Incompatibility { self.delegate?.conflict(conflict: conflict) diff --git a/Sources/PackageGraph/Resolution/PubGrub/Term.swift b/Sources/PackageGraph/Resolution/PubGrub/Term.swift index 9a8c458004c..ebfd32602c7 100644 --- a/Sources/PackageGraph/Resolution/PubGrub/Term.swift +++ b/Sources/PackageGraph/Resolution/PubGrub/Term.swift @@ -140,7 +140,7 @@ public struct Term: Equatable, Hashable { return true } - // From: https://github.com/dart-lang/pub/blob/master/lib/src/solver/term.dart + // From: https://github.com/dart-lang/pub/blob/master/lib/src/solver/term.dart //ignore-unacceptable-language public func relation(with other: Term) -> SetRelation { if self.node != other.node { assertionFailure("attempting to compute relation between different packages \(self) \(other)") diff --git a/Sources/PackageGraph/VersionSetSpecifier.swift b/Sources/PackageGraph/VersionSetSpecifier.swift index 12b92e0f268..e32a556ed65 100644 --- a/Sources/PackageGraph/VersionSetSpecifier.swift +++ b/Sources/PackageGraph/VersionSetSpecifier.swift @@ -367,7 +367,7 @@ extension VersionSetSpecifier { return self.difference(.ranges([r])) case (.ranges(let lhs), .ranges(let rhs)): - // Based on the difference method in https://github.com/dart-lang/pub_semver/blob/master/lib/src/version_union.dart + // Based on the difference method in https://github.com/dart-lang/pub_semver/blob/master/lib/src/version_union.dart //ignore-unacceptable-language var lhsItr = lhs.makeIterator() var rhsItr = rhs.makeIterator() diff --git a/Sources/PackageLoading/ModuleMapGenerator.swift b/Sources/PackageLoading/ModuleMapGenerator.swift index 1355a90328f..a358e72c9a9 100644 --- a/Sources/PackageLoading/ModuleMapGenerator.swift +++ b/Sources/PackageLoading/ModuleMapGenerator.swift @@ -58,7 +58,7 @@ extension ClangModule: ModuleMapProtocol { /// * Otherwise, if the "include" directory only contains header files and no other subdirectory: /// Generates: `umbrella "path/to/include"` /// -/// These rules are documented at https://github.com/swiftlang/swift-package-manager/blob/master/Documentation/Usage.md#creating-c-language-targets. To avoid breaking existing packages, do not change the semantics here without making any change conditional on the tools version of the package that defines the module. +/// These rules are documented at https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/Usage.md#creating-c-language-targets. To avoid breaking existing packages, do not change the semantics here without making any change conditional on the tools version of the package that defines the module. /// /// Note that a module map generator doesn't require a module to already have been instantiated; it can operate on information that will later be used to instantiate a module. public struct ModuleMapGenerator { @@ -84,7 +84,7 @@ public struct ModuleMapGenerator { /// Inspects the file system at the public-headers directory with which the module map generator was instantiated, and returns the type of module map that applies to that directory. This function contains all of the heuristics that implement module map policy for package targets; other functions just use the results of this determination. public func determineModuleMapType(observabilityScope: ObservabilityScope) -> ModuleMapType { - // The following rules are documented at https://github.com/swiftlang/swift-package-manager/blob/master/Documentation/Usage.md#creating-c-language-targets. To avoid breaking existing packages, do not change the semantics here without making any change conditional on the tools version of the package that defines the module. + // The following rules are documented at https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/Usage.md#creating-c-language-targets. To avoid breaking existing packages, do not change the semantics here without making any change conditional on the tools version of the package that defines the module. let diagnosticsEmitter = observabilityScope.makeDiagnosticsEmitter { var metadata = ObservabilityMetadata() diff --git a/Sources/PackageManagerDocs/Documentation.docc/PackageCollections/PackageCollectionDescribe.md b/Sources/PackageManagerDocs/Documentation.docc/PackageCollections/PackageCollectionDescribe.md index 3911c9dd044..58683b0c44f 100644 --- a/Sources/PackageManagerDocs/Documentation.docc/PackageCollections/PackageCollectionDescribe.md +++ b/Sources/PackageManagerDocs/Documentation.docc/PackageCollections/PackageCollectionDescribe.md @@ -52,7 +52,7 @@ $ swift package-collection describe [--json] https://github.com/jpsim/yams Description: A sweet and swifty YAML parser built on LibYAML. Available Versions: 4.0.0, 3.0.0, ... Stars: 14 -Readme: https://github.com/jpsim/Yams/blob/master/README.md +Readme: https://github.com/jpsim/Yams/blob/main/README.md Authors: @norio-nomura, @jpsim -------------------------------------------------------------- Latest Version: 4.0.0 @@ -220,7 +220,7 @@ specify more than one path.* - term **--color-diagnostics|no-color-diagnostics**: -*Enables or disables color diagnostics when printing to a TTY. +*Enables or disables color diagnostics when printing to a TTY. By default, color diagnostics are enabled when connected to a TTY and disabled otherwise.* diff --git a/Sources/PackageManagerDocs/Documentation.docc/Plugins/WritingCommandPlugin.md b/Sources/PackageManagerDocs/Documentation.docc/Plugins/WritingCommandPlugin.md index c4ee4b2c70b..e6c7e103984 100644 --- a/Sources/PackageManagerDocs/Documentation.docc/Plugins/WritingCommandPlugin.md +++ b/Sources/PackageManagerDocs/Documentation.docc/Plugins/WritingCommandPlugin.md @@ -83,7 +83,6 @@ import Foundation @main struct MyCommandPlugin: CommandPlugin { -123456789012345678901234567890123456789012345678901234567890 func performCommand( context: PluginContext, arguments: [String] diff --git a/Sources/PackageManagerDocs/Documentation.docc/RegistryServerSpecification.md b/Sources/PackageManagerDocs/Documentation.docc/RegistryServerSpecification.md index 453497e5564..9e7076a7b47 100644 --- a/Sources/PackageManagerDocs/Documentation.docc/RegistryServerSpecification.md +++ b/Sources/PackageManagerDocs/Documentation.docc/RegistryServerSpecification.md @@ -153,11 +153,11 @@ Valid `Accept` header field values are described by the following rules: ``` A server MUST set the `Content-Type` header field -with the corresponding content type of the response. +with the corresponding content type of the response. A server MUST set the `Content-Version` header field -with the API version number of the response, unless -explicitly stated otherwise. +with the API version number of the response, unless +explicitly stated otherwise. ```http HTTP/1.1 200 OK @@ -490,11 +490,11 @@ with a given combination of `name` and `type` values. ##### 4.2.2. Package release metadata standards - [Appendix B]() + [Appendix B]() defines the JSON schema for package release metadata that gets submitted as part of the ["create a package release"]() - request. A server MAY allow and/or populate additional metadata by - expanding the schema. The `metadata` key in the + request. A server MAY allow and/or populate additional metadata by + expanding the schema. The `metadata` key in the ["fetch information about a package release"]() API response will hold the user-provided as well as the server populated metadata. @@ -684,7 +684,7 @@ It is RECOMMENDED for clients and servers to support range requests as described by [RFC 7233] and caching as described by [RFC 7234]. -If a release is signed, a server MUST include +If a release is signed, a server MUST include `X-Swift-Package-Signature-Format` and `X-Swift-Package-Signature` headers in the response. @@ -744,7 +744,7 @@ Digest: sha-256=a2ac54cf25fbc1ad0028f03f0aa4b96833b83bb05a14e510892bb27dea4dc812 A client MUST validate the signature of a signed archive according to the signature format and configuration. Signing -information can alternatively be found in the associated +information can alternatively be found in the associated `source-archive` resource in the response to `GET /{scope}/{name}/{version}`, as described in [4.2.1](). @@ -797,7 +797,7 @@ caching as described by [RFC 7234]. ##### 4.5.1 URL to package identifier mappings As part of the [package release metadata]() JSON object, the `repositoryURLs` array can be used to specify URLs associated with a package identifier. -This is one way through which a server can obtain URL to package identifier mappings for this API. +This is one way through which a server can obtain URL to package identifier mappings for this API. A server MAY choose other mechanism(s) for package authors to specify these mappings. @@ -821,19 +821,19 @@ with the following sections: | `metadata` | `application/json` | Additional information about the release. | OPTIONAL | | `metadata-signature` | `application/octet-stream` | The signature of the metadata. | OPTIONAL | -A client MUST set a `Content-Type` header with the value +A client MUST set a `Content-Type` header with the value `multipart/form-data`. `boundary` can be any string. A client MAY use any valid value (e.g., `binary`) for the `Content-Transfer-Encoding` header. -A client SHOULD set the `Content-Length` header with +A client SHOULD set the `Content-Length` header with the total size of the body in bytes. A client SHOULD set the `Accept` header with the value `application/vnd.swift.registry.v1+json`. -A client MUST set a `X-Swift-Package-Signature-Format` header +A client MUST set a `X-Swift-Package-Signature-Format` header with the signature format if the source archive is signed. ```http @@ -1038,7 +1038,7 @@ Content-Language: en { "detail": "invalid JSON provided for release metadata" } -``` +``` ##### 4.6.3. Synchronous and asynchronous publication @@ -1221,13 +1221,13 @@ See [registry.openapi.yaml](./registry.openapi.yaml). ### Appendix B - Package Release Metadata JSON Schema -The `metadata` section of the [create package release request]() +The `metadata` section of the [create package release request]() must be a JSON object of type [`PackageRelease`](), as defined in the JSON schema below.
-Expand to view JSON schema +Expand to view JSON schema ```json { @@ -1241,52 +1241,52 @@ JSON schema below. "type": "object", "properties": { "name": { - "type": "string", + "type": "string", "description": "Name of the author." - }, + }, "email": { "type": "string", "format": "email", "description": "Email address of the author." - }, + }, "description": { - "type": "string", + "type": "string", "description": "A description of the author." }, "organization": { "type": "object", "properties": { "name": { - "type": "string", + "type": "string", "description": "Name of the organization." - }, + }, "email": { "type": "string", - "format": "email", + "format": "email", "description": "Email address of the organization." - }, + }, "description": { - "type": "string", + "type": "string", "description": "A description of the organization." - }, + }, "url": { "type": "string", - "format": "uri", + "format": "uri", "description": "URL of the organization." - }, + }, }, "required": ["name"] - }, + }, "url": { - "type": "string", - "format": "uri", + "type": "string", + "format": "uri", "description": "URL of the author." - }, + }, }, "required": ["name"] }, "description": { - "type": "string", + "type": "string", "description": "A description of the package release." }, "licenseURL": { @@ -1301,7 +1301,7 @@ JSON schema below. }, "readmeURL": { "type": "string", - "format": "uri", + "format": "uri", "description": "URL of the README specifically for the package release or broadly for the package." }, "repositoryURLs": { @@ -1310,7 +1310,7 @@ JSON schema below. "items": { "type": "string", "description": "Code repository URL." - } + } } } } @@ -1386,6 +1386,6 @@ JSON schema below. [thundering herd effect]: https://en.wikipedia.org/wiki/Thundering_herd_problem "Thundering herd problem" [offline cache]: https://yarnpkg.com/features/offline-cache "Offline Cache | Yarn - Package Manager" [XCFramework]: https://developer.apple.com/videos/play/wwdc2019/416/ "WWDC 2019 Session 416: Binary Frameworks in Swift" -[SE-0272]: https://github.com/swiftlang/swift-evolution/blob/master/proposals/0272-swiftpm-binary-dependencies.md "Package Manager Binary Dependencies" +[SE-0272]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0272-swiftpm-binary-dependencies.md "Package Manager Binary Dependencies" [Swift tools version]: https://github.com/swiftlang/swift-package-manager/blob/9b9bed7eaf0f38eeccd0d8ca06ae08f6689d1c3f/Documentation/Usage.md#swift-tools-version-specification "Swift Tools Version Specification" [ISO 8601]: https://www.iso.org/iso-8601-date-and-time-format.html "ISO 8601 Date and Time Format" diff --git a/Sources/PackageManagerDocs/EmptyFile.swift b/Sources/PackageManagerDocs/EmptyFile.swift index 5a717f150a4..c355ae2a4ae 100644 --- a/Sources/PackageManagerDocs/EmptyFile.swift +++ b/Sources/PackageManagerDocs/EmptyFile.swift @@ -1,3 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + // This is an empty placeholder swift file for the documentation target. // You can preview the documentation here by running the following command: diff --git a/Sources/PackageModel/EnabledTrait.swift b/Sources/PackageModel/EnabledTrait.swift index f5692528f98..103c1042a6c 100644 --- a/Sources/PackageModel/EnabledTrait.swift +++ b/Sources/PackageModel/EnabledTrait.swift @@ -1,12 +1,12 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift.org open source project +// This source file is part of the Swift open source project // // Copyright (c) 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/PackageModel/Manifest/Manifest+Traits.swift b/Sources/PackageModel/Manifest/Manifest+Traits.swift index 061d89a3477..5e772783b30 100644 --- a/Sources/PackageModel/Manifest/Manifest+Traits.swift +++ b/Sources/PackageModel/Manifest/Manifest+Traits.swift @@ -1,12 +1,12 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift.org open source project +// This source file is part of the Swift open source project // // Copyright (c) 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/PackageModel/Manifest/TargetDescription.swift b/Sources/PackageModel/Manifest/TargetDescription.swift index d336bedb60a..f75de84fd13 100644 --- a/Sources/PackageModel/Manifest/TargetDescription.swift +++ b/Sources/PackageModel/Manifest/TargetDescription.swift @@ -119,7 +119,7 @@ public struct TargetDescription: Hashable, Encodable, Sendable { /// The exclude patterns. public let exclude: [String] - // FIXME: Kill this. + // FIXME: Remote this. // /// Returns true if the target type is test. public var isTest: Bool { @@ -140,16 +140,16 @@ public struct TargetDescription: Hashable, Encodable, Sendable { /// The providers of a system library target. public let providers: [SystemPackageProviderDescription]? - + /// The declared capability for a package plugin target. public let pluginCapability: PluginCapability? - + /// Represents the declared capability of a package plugin. public enum PluginCapability: Hashable, Sendable { case buildTool case command(intent: PluginCommandIntent, permissions: [PluginPermission]) } - + public enum PluginCommandIntent: Hashable, Codable, Sendable { case documentationGeneration case sourceCodeFormatting @@ -185,7 +185,7 @@ public struct TargetDescription: Hashable, Encodable, Sendable { /// The binary target checksum. public let checksum: String? - + /// The usages of package plugins by the target. public let pluginUsages: [PluginUsage]? diff --git a/Sources/PackageSigning/embedded_resources.swift b/Sources/PackageSigning/embedded_resources.swift index a1dbeb69b2f..7e7119e9239 100644 --- a/Sources/PackageSigning/embedded_resources.swift +++ b/Sources/PackageSigning/embedded_resources.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2023-2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// struct PackageResources { static let AppleWWDRCAG2_cer: [UInt8] = [48,130,2,247,48,130,2,124,160,3,2,1,2,2,8,111,239,216,245,233,163,167,238,48,10,6,8,42,134,72,206,61,4,3,2,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,30,23,13,49,52,48,53,48,54,50,51,52,51,50,52,90,23,13,50,57,48,53,48,54,50,51,52,51,50,52,90,48,129,128,49,52,48,50,6,3,85,4,3,12,43,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,65,32,45,32,71,50,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,89,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,66,0,4,221,240,183,6,75,207,221,115,4,19,196,67,137,3,147,128,251,94,246,116,173,66,97,82,88,2,38,83,25,200,99,34,7,9,82,97,202,196,217,87,239,109,38,104,139,116,145,140,196,249,128,104,40,252,9,104,240,16,218,233,208,46,201,26,163,129,247,48,129,244,48,70,6,8,43,6,1,5,5,7,1,1,4,58,48,56,48,54,6,8,43,6,1,5,5,7,48,1,134,42,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,52,45,97,112,112,108,101,114,111,111,116,99,97,103,51,48,29,6,3,85,29,14,4,22,4,20,132,182,132,204,58,134,98,114,22,89,148,232,26,163,189,72,223,58,223,11,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,31,6,3,85,29,35,4,24,48,22,128,20,187,176,222,161,88,51,136,154,164,138,153,222,190,189,235,175,218,203,36,171,48,55,6,3,85,29,31,4,48,48,46,48,44,160,42,160,40,134,38,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,97,112,112,108,101,114,111,111,116,99,97,103,51,46,99,114,108,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,15,4,2,5,0,48,10,6,8,42,134,72,206,61,4,3,2,3,105,0,48,102,2,49,0,217,177,199,49,198,35,246,79,77,208,217,71,197,125,24,105,17,135,113,39,211,104,173,224,155,101,154,190,108,223,63,70,166,144,9,190,110,161,59,44,176,81,137,65,60,135,210,191,2,49,0,252,100,82,137,75,60,93,191,107,28,194,137,152,47,114,174,181,155,170,26,11,35,84,119,84,232,21,67,162,197,18,218,151,80,115,124,94,208,110,178,92,98,80,215,81,241,58,90] static let AppleWWDRCAG3_cer: [UInt8] = [48,130,4,81,48,130,3,57,160,3,2,1,2,2,16,124,175,105,10,37,183,57,254,123,155,68,122,193,120,197,238,48,13,6,9,42,134,72,134,247,13,1,1,11,5,0,48,98,49,11,48,9,6,3,85,4,6,19,2,85,83,49,19,48,17,6,3,85,4,10,19,10,65,112,112,108,101,32,73,110,99,46,49,38,48,36,6,3,85,4,11,19,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,22,48,20,6,3,85,4,3,19,13,65,112,112,108,101,32,82,111,111,116,32,67,65,48,30,23,13,50,48,48,50,49,57,49,56,49,51,52,55,90,23,13,51,48,48,50,50,48,48,48,48,48,48,48,90,48,117,49,68,48,66,6,3,85,4,3,12,59,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,11,48,9,6,3,85,4,11,12,2,71,51,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,130,1,34,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,130,1,15,0,48,130,1,10,2,130,1,1,0,216,245,137,252,168,89,11,135,199,76,145,46,45,86,144,211,120,29,164,48,233,165,72,239,11,67,191,45,132,251,36,93,69,27,229,235,89,54,18,92,84,100,158,108,98,45,180,198,151,202,204,60,246,214,6,145,252,229,2,166,28,106,180,121,213,103,203,172,233,63,7,17,225,132,188,71,29,102,142,57,162,232,180,73,237,58,210,225,16,96,122,142,147,140,202,192,218,12,192,131,208,227,249,145,214,167,140,200,193,115,226,174,70,209,98,157,146,168,144,96,55,125,104,150,205,141,224,252,155,250,120,187,227,123,175,45,23,221,91,254,128,89,35,117,23,184,18,193,237,27,229,52,206,254,34,181,158,73,176,229,85,191,143,132,162,60,168,186,197,134,149,22,228,0,201,159,3,208,204,179,58,22,123,214,5,92,157,235,71,174,13,181,45,140,14,105,77,64,208,75,76,59,4,158,141,33,177,172,46,67,84,48,206,193,138,134,148,152,75,223,106,13,63,254,251,28,174,151,23,194,120,10,48,224,95,31,84,59,73,183,37,0,26,55,130,210,86,151,165,82,73,124,96,56,155,239,2,3,1,0,1,163,129,239,48,129,236,48,18,6,3,85,29,19,1,1,255,4,8,48,6,1,1,255,2,1,0,48,31,6,3,85,29,35,4,24,48,22,128,20,43,208,105,71,148,118,9,254,244,107,141,46,64,166,247,71,77,127,8,94,48,68,6,8,43,6,1,5,5,7,1,1,4,56,48,54,48,52,6,8,43,6,1,5,5,7,48,1,134,40,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,51,45,97,112,112,108,101,114,111,111,116,99,97,48,46,6,3,85,29,31,4,39,48,37,48,35,160,33,160,31,134,29,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,114,111,111,116,46,99,114,108,48,29,6,3,85,29,14,4,22,4,20,9,254,192,21,144,249,175,100,10,146,18,185,38,40,99,12,151,236,167,178,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,1,4,2,5,0,48,13,6,9,42,134,72,134,247,13,1,1,11,5,0,3,130,1,1,0,173,101,19,232,246,224,129,119,68,2,71,66,190,95,165,57,32,234,98,169,253,197,144,201,115,19,213,158,155,208,170,15,141,141,203,237,1,207,108,40,64,91,199,85,36,65,248,252,207,193,181,35,233,220,236,241,111,202,128,29,119,194,196,97,73,37,103,175,15,202,57,37,173,211,227,122,204,51,40,13,14,46,161,87,64,115,250,230,92,174,6,81,41,237,227,133,12,79,97,220,50,22,139,119,208,68,202,93,114,3,49,70,156,174,155,64,26,250,244,224,211,62,250,47,140,102,159,151,196,84,89,239,210,72,244,7,153,73,96,89,25,199,221,148,209,192,193,108,127,120,33,239,12,235,59,108,153,130,75,82,96,56,181,57,130,109,236,82,49,83,190,15,145,76,73,73,116,143,166,81,203,132,71,78,29,117,39,110,189,249,210,92,243,127,194,108,11,9,54,226,100,228,194,55,3,20,25,213,234,106,148,170,169,219,254,246,154,8,103,139,239,43,184,170,23,73,131,175,207,203,188,233,207,234,149,113,176,180,69,162,204,229,135,170,10,195,65,58,121,92,218,80,52,157,149,59] @@ -10,4 +21,4 @@ static let AppleWWDRCAG4_cer: [UInt8] = [48,130,4,85,48,130,3,61,160,3,2,1,2,2,2 static let AppleWWDRCAG6_cer: [UInt8] = [48,130,3,22,48,130,2,156,160,3,2,1,2,2,20,34,193,161,71,10,116,115,105,239,83,134,18,201,198,159,61,56,243,108,215,48,10,6,8,42,134,72,206,61,4,3,3,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,30,23,13,50,49,48,51,49,55,50,48,51,55,49,48,90,23,13,51,54,48,51,49,57,48,48,48,48,48,48,90,48,117,49,68,48,66,6,3,85,4,3,12,59,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,11,48,9,6,3,85,4,11,12,2,71,54,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,110,196,10,11,222,15,174,85,166,101,121,215,130,220,115,117,82,75,241,61,18,25,137,224,13,17,169,158,9,247,55,163,211,240,147,4,111,177,67,139,134,193,152,248,66,157,157,255,178,174,143,23,247,6,112,165,214,176,190,111,58,215,145,135,34,120,231,29,192,72,254,220,56,31,154,106,143,116,125,202,113,74,255,196,100,86,231,136,6,205,129,145,161,34,26,72,163,129,250,48,129,247,48,18,6,3,85,29,19,1,1,255,4,8,48,6,1,1,255,2,1,0,48,31,6,3,85,29,35,4,24,48,22,128,20,187,176,222,161,88,51,136,154,164,138,153,222,190,189,235,175,218,203,36,171,48,70,6,8,43,6,1,5,5,7,1,1,4,58,48,56,48,54,6,8,43,6,1,5,5,7,48,1,134,42,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,51,45,97,112,112,108,101,114,111,111,116,99,97,103,51,48,55,6,3,85,29,31,4,48,48,46,48,44,160,42,160,40,134,38,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,97,112,112,108,101,114,111,111,116,99,97,103,51,46,99,114,108,48,29,6,3,85,29,14,4,22,4,20,63,47,148,35,81,211,80,201,154,40,61,237,176,124,229,207,165,144,98,153,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,1,4,2,5,0,48,10,6,8,42,134,72,206,61,4,3,3,3,104,0,48,101,2,48,64,94,20,170,228,140,138,162,3,2,62,220,56,247,64,90,7,174,251,9,161,6,37,123,159,64,31,196,169,145,157,232,36,163,136,43,78,158,227,19,109,117,87,155,28,92,197,249,2,49,0,211,72,252,90,173,149,239,54,185,49,83,116,228,80,194,55,223,44,239,21,85,81,79,140,49,88,144,189,247,131,172,117,198,120,249,17,141,177,128,242,71,152,38,118,189,39,12,104] static let AppleWWDRCAG8_cer: [UInt8] = [48,130,4,85,48,130,3,61,160,3,2,1,2,2,20,84,181,11,175,121,13,141,127,140,175,104,76,86,47,80,105,10,26,186,95,48,13,6,9,42,134,72,134,247,13,1,1,5,5,0,48,98,49,11,48,9,6,3,85,4,6,19,2,85,83,49,19,48,17,6,3,85,4,10,19,10,65,112,112,108,101,32,73,110,99,46,49,38,48,36,6,3,85,4,11,19,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,22,48,20,6,3,85,4,3,19,13,65,112,112,108,101,32,82,111,111,116,32,67,65,48,30,23,13,50,51,48,54,50,48,50,51,51,55,49,53,90,23,13,50,53,48,49,50,52,48,48,48,48,48,48,90,48,117,49,11,48,9,6,3,85,4,6,19,2,85,83,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,11,12,2,71,56,49,68,48,66,6,3,85,4,3,12,59,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,48,130,1,34,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,130,1,15,0,48,130,1,10,2,130,1,1,0,208,64,16,212,8,249,82,33,99,79,60,104,247,212,156,130,2,140,131,104,188,183,141,127,136,231,66,77,44,239,34,165,194,137,222,189,12,215,77,97,80,45,57,228,48,115,165,210,213,104,154,51,242,239,217,42,173,46,31,3,186,248,165,241,66,11,87,46,70,198,208,88,211,112,95,247,178,55,239,106,31,62,191,137,57,194,173,254,245,5,251,88,150,49,200,135,44,213,35,186,117,176,44,245,171,160,186,242,32,12,76,235,36,99,105,233,34,64,240,142,88,91,222,100,123,137,27,81,18,4,224,23,178,89,205,223,241,231,206,175,44,50,232,105,193,208,8,126,29,162,71,115,209,75,59,253,185,133,220,71,167,40,130,121,41,72,137,2,40,226,193,236,44,31,91,134,252,216,182,203,113,192,115,1,75,252,5,17,17,108,1,3,52,90,246,129,194,94,31,124,20,14,222,63,107,33,203,79,245,215,97,230,132,3,146,188,231,37,41,158,205,91,12,193,219,227,196,58,217,118,87,172,47,56,20,25,200,183,177,162,85,79,95,78,142,25,89,169,218,253,114,218,176,4,33,5,2,3,1,0,1,163,129,239,48,129,236,48,18,6,3,85,29,19,1,1,255,4,8,48,6,1,1,255,2,1,0,48,31,6,3,85,29,35,4,24,48,22,128,20,43,208,105,71,148,118,9,254,244,107,141,46,64,166,247,71,77,127,8,94,48,68,6,8,43,6,1,5,5,7,1,1,4,56,48,54,48,52,6,8,43,6,1,5,5,7,48,1,134,40,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,51,45,97,112,112,108,101,114,111,111,116,99,97,48,46,6,3,85,29,31,4,39,48,37,48,35,160,33,160,31,134,29,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,114,111,111,116,46,99,114,108,48,29,6,3,85,29,14,4,22,4,20,181,189,188,128,196,12,227,56,164,244,183,173,35,179,239,68,206,185,90,133,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,1,4,2,5,0,48,13,6,9,42,134,72,134,247,13,1,1,5,5,0,3,130,1,1,0,76,179,235,122,57,148,74,149,102,250,22,49,234,13,138,143,93,66,56,198,7,205,232,201,34,172,252,8,66,126,95,147,95,49,42,168,34,193,118,25,43,238,174,114,233,189,86,207,73,36,146,8,247,205,25,117,195,249,26,39,13,14,220,41,141,63,182,219,165,79,76,114,196,96,145,137,17,126,36,149,67,34,96,103,188,223,255,171,229,60,22,23,157,130,20,78,157,244,117,254,80,185,173,5,178,184,121,246,149,214,16,229,246,83,244,207,35,230,119,15,236,184,75,105,248,226,158,2,49,217,142,217,202,190,99,94,95,225,160,105,206,193,205,110,73,163,120,97,175,57,60,106,75,10,52,37,100,213,48,181,60,171,221,17,129,57,113,232,192,195,88,128,17,16,26,17,210,194,188,89,240,138,217,53,115,192,230,109,228,201,125,98,20,62,130,2,169,16,105,55,121,97,111,240,70,148,62,53,245,171,172,99,208,216,94,89,87,105,209,184,75,110,93,212,95,19,156,112,78,37,17,220,36,44,30,22,158,150,90,4,237,69,238,58,238,103,93,143,195,134,176,245,76,31,104,16] static let AppleRootCA_G3_cer: [UInt8] = [48,130,2,67,48,130,1,201,160,3,2,1,2,2,8,45,197,252,136,210,197,75,149,48,10,6,8,42,134,72,206,61,4,3,3,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,30,23,13,49,52,48,52,51,48,49,56,49,57,48,54,90,23,13,51,57,48,52,51,48,49,56,49,57,48,54,90,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,152,233,47,61,64,114,164,237,147,34,114,129,19,28,221,16,149,241,197,163,78,113,220,20,22,217,14,229,166,5,42,119,100,123,95,78,56,211,187,28,68,181,127,245,31,182,50,98,93,201,233,132,91,79,48,79,17,90,0,253,88,88,12,165,245,15,44,77,7,71,19,117,218,151,151,151,111,49,92,237,43,157,123,32,59,216,185,84,217,94,153,164,58,81,10,49,163,66,48,64,48,29,6,3,85,29,14,4,22,4,20,187,176,222,161,88,51,136,154,164,138,153,222,190,189,235,175,218,203,36,171,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,10,6,8,42,134,72,206,61,4,3,3,3,104,0,48,101,2,49,0,131,233,193,196,22,94,26,93,52,24,217,237,239,244,108,14,0,70,75,184,223,178,70,17,197,15,253,230,122,140,161,166,107,206,194,3,212,156,245,147,198,116,184,106,223,170,35,21,2,48,109,102,138,16,202,212,13,212,79,205,141,67,62,180,138,99,165,51,110,227,109,218,23,183,100,31,200,83,38,249,136,98,116,57,11,23,91,203,81,168,12,232,24,3,231,162,178,40] -} \ No newline at end of file +} diff --git a/Sources/QueryEngine/CacheKey.swift b/Sources/QueryEngine/CacheKey.swift index b10bac987d3..dcd1e930490 100644 --- a/Sources/QueryEngine/CacheKey.swift +++ b/Sources/QueryEngine/CacheKey.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/QueryEngine/FileCacheRecord.swift b/Sources/QueryEngine/FileCacheRecord.swift index de5dd18a450..7fc4afc80e0 100644 --- a/Sources/QueryEngine/FileCacheRecord.swift +++ b/Sources/QueryEngine/FileCacheRecord.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/QueryEngine/Query.swift b/Sources/QueryEngine/Query.swift index 56a34c9a3e4..d4f300c8d7f 100644 --- a/Sources/QueryEngine/Query.swift +++ b/Sources/QueryEngine/Query.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/QueryEngine/QueryEngine.swift b/Sources/QueryEngine/QueryEngine.swift index 933b305cc14..64aa938ee3f 100644 --- a/Sources/QueryEngine/QueryEngine.swift +++ b/Sources/QueryEngine/QueryEngine.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/Runtimes/PackageDescription/WarningLevel.swift b/Sources/Runtimes/PackageDescription/WarningLevel.swift index 1d4a953fc32..23030b57849 100644 --- a/Sources/Runtimes/PackageDescription/WarningLevel.swift +++ b/Sources/Runtimes/PackageDescription/WarningLevel.swift @@ -1,3 +1,4 @@ +//===----------------------------------------------------------------------===// // // This source file is part of the Swift open source project // @@ -11,7 +12,7 @@ /// The level at which a compiler warning should be treated. /// -/// This enum is used with the `SwiftSetting.treatAllWarnings(as:_:)` and +/// This enum is used with the `SwiftSetting.treatAllWarnings(as:_:)` and /// `SwiftSetting.treatWarning(name:as:_:)` methods to control how warnings /// are handled during compilation. @available(_PackageDescription, introduced: 6.2) diff --git a/Sources/Runtimes/cmake/modules/EmitSwiftInterface.cmake b/Sources/Runtimes/cmake/modules/EmitSwiftInterface.cmake index 00a49dc1b51..a3d0be0a5a4 100644 --- a/Sources/Runtimes/cmake/modules/EmitSwiftInterface.cmake +++ b/Sources/Runtimes/cmake/modules/EmitSwiftInterface.cmake @@ -1,3 +1,15 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See http://swift.org/LICENSE.txt for license information +## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## + # Generate and install swift interface files # TODO: CMake should learn how to model library evolution and generate this diff --git a/Sources/Runtimes/cmake/modules/InstallSwiftInterface.cmake b/Sources/Runtimes/cmake/modules/InstallSwiftInterface.cmake index 8158f539492..6ece4ac7d9c 100644 --- a/Sources/Runtimes/cmake/modules/InstallSwiftInterface.cmake +++ b/Sources/Runtimes/cmake/modules/InstallSwiftInterface.cmake @@ -1,3 +1,15 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See http://swift.org/LICENSE.txt for license information +## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## + # Install the generated swift interface files for the target. function(install_swift_interface target) # Swiftmodules are already in the directory structure diff --git a/Sources/Runtimes/cmake/modules/PlatformInfo.cmake b/Sources/Runtimes/cmake/modules/PlatformInfo.cmake index ebe92e0af78..353e763ead8 100644 --- a/Sources/Runtimes/cmake/modules/PlatformInfo.cmake +++ b/Sources/Runtimes/cmake/modules/PlatformInfo.cmake @@ -1,3 +1,15 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See http://swift.org/LICENSE.txt for license information +## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## + include_guard(GLOBAL) if(NOT ${PROJECT_NAME}_SIZEOF_POINTER) diff --git a/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift b/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift index e5d9802b79f..a9fe2744794 100644 --- a/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift +++ b/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift @@ -29,7 +29,7 @@ public struct BuildParameters: Encodable { } /// Mode for the indexing-while-building feature. - public enum IndexStoreMode: String, Encodable { + public enum IndexStoreMode: String, Encodable, CaseIterable { /// Index store should be enabled. case on /// Index store should be disabled. diff --git a/Sources/SPMBuildCore/Triple+Extensions.swift b/Sources/SPMBuildCore/Triple+Extensions.swift index 191419bb5dd..3e0680ada47 100644 --- a/Sources/SPMBuildCore/Triple+Extensions.swift +++ b/Sources/SPMBuildCore/Triple+Extensions.swift @@ -32,7 +32,9 @@ extension Triple { // can be used to build for any Apple platform and it has its own // conventions for build subpaths based on platforms. return "apple" - case .swiftbuild, .native: + case .swiftbuild: + return "out" + case .native: return self.platformBuildPathComponent } } diff --git a/Sources/SPMBuildCore/XcodeProjectRepresentation.swift b/Sources/SPMBuildCore/XcodeProjectRepresentation.swift index 5fb066ac535..ca7bd2a47ab 100644 --- a/Sources/SPMBuildCore/XcodeProjectRepresentation.swift +++ b/Sources/SPMBuildCore/XcodeProjectRepresentation.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2022 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors -*/ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics @@ -16,19 +18,19 @@ public struct XcodeProjectRepresentation: Equatable, Hashable { public var directoryPath: AbsolutePath public var filePaths: [AbsolutePath] public var targets: [Target] - + public init(displayName: String, directoryPath: AbsolutePath, filePaths: [AbsolutePath], targets: [Target]) { self.displayName = displayName self.directoryPath = directoryPath self.filePaths = filePaths self.targets = targets } - + public struct Target: Equatable, Hashable { public var displayName: String public var product: Product? public var inputFiles: [InputFile] - + public init(displayName: String, product: Product?, inputFiles: [InputFile]) { self.displayName = displayName self.product = product @@ -38,7 +40,7 @@ public struct XcodeProjectRepresentation: Equatable, Hashable { public struct Product: Equatable, Hashable { public var name: String public var kind: Kind - + public init(name: String, kind: Kind) { self.name = name self.kind = kind @@ -57,7 +59,7 @@ public struct XcodeProjectRepresentation: Equatable, Hashable { public struct InputFile: Equatable, Hashable { public var path: AbsolutePath public var role: Role - + public init(path: AbsolutePath, role: Role) { self.path = path self.role = role diff --git a/Sources/SwiftBuildSupport/BuildSystem.swift b/Sources/SwiftBuildSupport/BuildSystem.swift index f55dc8f734b..859959f4a33 100644 --- a/Sources/SwiftBuildSupport/BuildSystem.swift +++ b/Sources/SwiftBuildSupport/BuildSystem.swift @@ -1,3 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + import SPMBuildCore import PackageModel diff --git a/Sources/SwiftBuildSupport/DotPIFSerializer.swift b/Sources/SwiftBuildSupport/DotPIFSerializer.swift index 5cf883ee15c..3e48a1c9013 100644 --- a/Sources/SwiftBuildSupport/DotPIFSerializer.swift +++ b/Sources/SwiftBuildSupport/DotPIFSerializer.swift @@ -1,9 +1,14 @@ +//===----------------------------------------------------------------------===// // -// DotPIFSerializer.swift -// SwiftPM +// This source file is part of the Swift open source project // -// Created by Paulo Mattos on 2025-04-18. +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception // +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics import Foundation diff --git a/Sources/SwiftBuildSupport/PackagePIFBuilder+Helpers.swift b/Sources/SwiftBuildSupport/PackagePIFBuilder+Helpers.swift index 60a2a177f73..d5fa729f0f2 100644 --- a/Sources/SwiftBuildSupport/PackagePIFBuilder+Helpers.swift +++ b/Sources/SwiftBuildSupport/PackagePIFBuilder+Helpers.swift @@ -63,7 +63,7 @@ import enum SwiftBuild.ProjectModel enum TargetSuffix: String { case testable, dynamic - + func hasSuffix(id: GUID) -> Bool { id.value.hasSuffix("-\(self.rawValue)") } @@ -524,18 +524,18 @@ extension PackageGraph.ResolvedModule { /// Target-specific single-value build settings declared in the manifest and that apply to the target itself. var targetSingleValueSettings: [BuildConfiguration: SingleValueSettingsByPlatform] = [:] - + /// Target-specific multiple-value build settings declared in the manifest and that apply to the target itself. var targetMultipleValueSettings: [BuildConfiguration: MultipleValueSettingsByPlatform] = [:] /// Target-specific single-value build settings that should be imparted to client targets (packages and projects). var impartedSingleValueSettings: SingleValueSettingsByPlatform = [:] - + /// Target-specific multiple-value build settings that should be imparted to client targets (packages and projects). var impartedMultipleValueSettings: MultipleValueSettingsByPlatform = [:] - + // MARK: - Convenience Methods - + /// Apply all settings to a ProjectModel.BuildSettings instance func apply(to buildSettings: inout ProjectModel.BuildSettings, for configuration: BuildConfiguration) { // Apply single value settings for all platforms @@ -550,7 +550,7 @@ extension PackageGraph.ResolvedModule { } } } - + // Apply multiple value settings for all platforms if let multipleValuesByPlatform = targetMultipleValueSettings[configuration] { // First, collect all multiple-value settings that are being used @@ -560,7 +560,7 @@ extension PackageGraph.ResolvedModule { usedMultipleValueSettings.insert(setting) } } - + // Now apply the platform-specific values for (platform, multipleValues) in multipleValuesByPlatform { for (setting, values) in multipleValues { @@ -577,7 +577,7 @@ extension PackageGraph.ResolvedModule { } } } - + /// Apply imparted settings to a ProjectModel.BuildSettings instance func applyImparted(to buildSettings: inout ProjectModel.BuildSettings) { // Apply imparted single value settings for all platforms @@ -590,7 +590,7 @@ extension PackageGraph.ResolvedModule { } } } - + // Apply imparted multiple value settings for all platforms for (platform, multipleValues) in impartedMultipleValueSettings { for (setting, values) in multipleValues { @@ -621,7 +621,7 @@ extension PackageGraph.ResolvedModule { let values: [String] let singleValueSetting: ProjectModel.BuildSettings.SingleValueSetting? let multipleValueSetting: ProjectModel.BuildSettings.MultipleValueSetting? - + switch declaration { case .LINK_FRAMEWORKS: singleValueSetting = nil @@ -1032,6 +1032,12 @@ extension ProjectModel.BuildSettings { self[.PRODUCT_BUNDLE_IDENTIFIER] = "\(packageIdentity).\(productName)".spm_mangledToBundleIdentifier() self[.SWIFT_PACKAGE_NAME] = packageName ?? nil + // This should really be swift-build defaults set in the .xcspec files, but changing that requires + // some extensive testing to ensure xcode projects are not effected. + // So for now lets just force it here. + self[.EXECUTABLE_PREFIX] = "lib" + self[.EXECUTABLE_PREFIX, Platform.windows] = "" + if !createDylibForDynamicProducts { self[.GENERATE_INFOPLIST_FILE] = "YES" // If the built framework is named same as one of the target in the package, @@ -1106,7 +1112,7 @@ extension ObservabilityScope { let indentation = String(repeating: " ", count: Int(indent)) let message = "PIF: \(indentation)\(message)" - + let diagnostic = Diagnostic(severity: severity, message: message, metadata: metadata) self.emit(diagnostic) } @@ -1133,7 +1139,7 @@ public struct SourceLocation: Sendable { public init(_ file: StaticString, _ line: UInt) { precondition(file.description.hasContent) - + self.file = file self.line = line } diff --git a/Sources/SwiftBuildSupport/PackagePIFBuilder.swift b/Sources/SwiftBuildSupport/PackagePIFBuilder.swift index 53c7a428be8..90ff3db30e0 100644 --- a/Sources/SwiftBuildSupport/PackagePIFBuilder.swift +++ b/Sources/SwiftBuildSupport/PackagePIFBuilder.swift @@ -32,6 +32,8 @@ import struct PackageGraph.ModulesGraph import struct PackageGraph.ResolvedModule import struct PackageGraph.ResolvedPackage +import struct SPMBuildCore.BuildParameters + import enum SwiftBuild.ProjectModel typealias GUID = SwiftBuild.ProjectModel.GUID @@ -203,7 +205,7 @@ public final class PackagePIFBuilder { addLocalRpaths: Bool = true, packageDisplayVersion: String?, fileSystem: FileSystem, - observabilityScope: ObservabilityScope + observabilityScope: ObservabilityScope, ) { self.package = resolvedPackage self.packageManifest = packageManifest @@ -227,7 +229,7 @@ public final class PackagePIFBuilder { addLocalRpaths: Bool = true, packageDisplayVersion: String?, fileSystem: FileSystem, - observabilityScope: ObservabilityScope + observabilityScope: ObservabilityScope, ) { self.package = resolvedPackage self.packageManifest = packageManifest @@ -438,7 +440,7 @@ public final class PackagePIFBuilder { // self.log(.debug, "Processing \(package.products.count) products:") - + // For each of the **products** in the package we create a corresponding `PIFTarget` of the appropriate type. for product in self.package.products { switch product.type { @@ -561,8 +563,8 @@ public final class PackagePIFBuilder { // We currently deliberately do not support Swift ObjC interface headers. settings[.SWIFT_INSTALL_OBJC_HEADER] = "NO" settings[.SWIFT_OBJC_INTERFACE_HEADER_NAME] = "" - - // rdar://47937899 (Don't try to link frameworks to object files) + + // rdar://47937899 (Don't try to link frameworks to object files) // - looks like this defaults to OTHER_LDFLAGS (via xcspec) which can result in linking frameworks to mh_objects which is unwanted. settings[.OTHER_LDRFLAGS] = [] @@ -622,6 +624,7 @@ public final class PackagePIFBuilder { debugSettings[.ENABLE_TESTABILITY] = "YES" debugSettings[.SWIFT_ACTIVE_COMPILATION_CONDITIONS, default: []].append(contentsOf: ["DEBUG"]) debugSettings[.GCC_PREPROCESSOR_DEFINITIONS, default: ["$(inherited)"]].append(contentsOf: ["DEBUG=1"]) + debugSettings[.SWIFT_INDEX_STORE_ENABLE] = "YES" builder.project.addBuildConfig { id in BuildConfig(id: id, name: "Debug", settings: debugSettings) } // Add the build settings that are specific to release builds, and set those as the "Release" configuration. diff --git a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift b/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift index a36ea1b48f2..0fa439ab914 100644 --- a/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift +++ b/Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift @@ -440,6 +440,9 @@ extension PackagePIFProjectBuilder { // Redirect the built executable into a separate directory so it won't conflict with the real one. settings[.TARGET_BUILD_DIR] = "$(TARGET_BUILD_DIR)/ExecutableModules" + // on windows modules are libraries, so we need to add a search path so the linker finds them + impartedSettings[.LIBRARY_SEARCH_PATHS, .windows] = ["$(inherited)", "$(TARGET_BUILD_DIR)/ExecutableModules"] + // Don't install the Swift module of the testable side-built artifact, lest it conflict with the regular // one. // The modules should have compatible contents in any case — only the entry point function name is diff --git a/Sources/SwiftBuildSupport/SwiftBuildSystem.swift b/Sources/SwiftBuildSupport/SwiftBuildSystem.swift index bf0e98161cf..8f98a7b031b 100644 --- a/Sources/SwiftBuildSupport/SwiftBuildSystem.swift +++ b/Sources/SwiftBuildSupport/SwiftBuildSystem.swift @@ -43,7 +43,7 @@ struct SessionFailedError: Error { var diagnostics: [SwiftBuild.SwiftBuildMessage.DiagnosticInfo] } -func withService( +package func withService( connectionMode: SWBBuildServiceConnectionMode = .default, variant: SWBBuildServiceVariant = .default, serviceBundleURL: URL? = nil, @@ -111,7 +111,9 @@ func withSession( } } -private final class PlanningOperationDelegate: SWBPlanningOperationDelegate, Sendable { +package final class SwiftBuildSystemPlanningOperationDelegate: SWBPlanningOperationDelegate, SWBIndexingDelegate, Sendable { + package init() {} + public func provisioningTaskInputs( targetGUID: String, provisioningSourceData: SWBProvisioningTaskInputsSourceData @@ -175,7 +177,7 @@ private final class PlanningOperationDelegate: SWBPlanningOperationDelegate, Sen } public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { - private let buildParameters: BuildParameters + package let buildParameters: BuildParameters private let packageGraphLoader: () async throws -> ModulesGraph private let packageManagerResourcesDirectory: Basics.AbsolutePath? private let logLevel: Basics.Diagnostic.Severity @@ -341,7 +343,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { return result } - try await writePIF(buildParameters: buildParameters) + try await writePIF(buildParameters: self.buildParameters) return try await startSWBuildOperation( pifTargetName: subset.pifTargetName, @@ -726,7 +728,7 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { let operation = try await session.createBuildOperation( request: request, - delegate: PlanningOperationDelegate(), + delegate: SwiftBuildSystemPlanningOperationDelegate(), retainBuildDescription: true ) @@ -860,7 +862,11 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { ) } - private func makeBuildParameters(session: SWBBuildServiceSession, symbolGraphOptions: BuildOutput.SymbolGraphOptions?) async throws -> SwiftBuild.SWBBuildParameters { + internal func makeBuildParameters( + session: SWBBuildServiceSession, + symbolGraphOptions: BuildOutput.SymbolGraphOptions?, + setToolchainSetting: Bool = true, + ) async throws -> SwiftBuild.SWBBuildParameters { // Generate the run destination parameters. let runDestination = makeRunDestination() @@ -872,17 +878,33 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { // Generate a table of any overriding build settings. var settings: [String: String] = [:] - // If the SwiftPM toolchain corresponds to a toolchain registered with the lower level build system, add it to the toolchain stack. - // Otherwise, apply overrides for each component of the SwiftPM toolchain. - if let toolchainID = try await session.lookupToolchain(at: buildParameters.toolchain.toolchainDir.pathString) { - settings["TOOLCHAINS"] = "\(toolchainID.rawValue) $(inherited)" - } else { - // FIXME: This list of overrides is incomplete. - // An error with determining the override should not be fatal here. - settings["CC"] = try? buildParameters.toolchain.getClangCompiler().pathString - // Always specify the path of the effective Swift compiler, which was determined in the same way as for the - // native build system. - settings["SWIFT_EXEC"] = buildParameters.toolchain.swiftCompilerPath.pathString + if setToolchainSetting { + // If the SwiftPM toolchain corresponds to a toolchain registered with the lower level build system, add it to the toolchain stack. + // Otherwise, apply overrides for each component of the SwiftPM toolchain. + if let toolchainID = try await session.lookupToolchain(at: buildParameters.toolchain.toolchainDir.pathString) { + settings["TOOLCHAINS"] = "\(toolchainID.rawValue) $(inherited)" + } else { + // FIXME: This list of overrides is incomplete. + // An error with determining the override should not be fatal here. + settings["CC"] = try? buildParameters.toolchain.getClangCompiler().pathString + // Always specify the path of the effective Swift compiler, which was determined in the same way as for the + // native build system. + settings["SWIFT_EXEC"] = buildParameters.toolchain.swiftCompilerPath.pathString + } + } + + for sanitizer in buildParameters.sanitizers.sanitizers { + self.observabilityScope.emit(debug:"Enabling \(sanitizer) sanitizer") + switch sanitizer { + case .address: + settings["ENABLE_ADDRESS_SANITIZER"] = "YES" + case .thread: + settings["ENABLE_THREAD_SANITIZER"] = "YES" + case .undefined: + settings["ENABLE_UNDEFINED_BEHAVIOR_SANITIZER"] = "YES" + case .fuzzer, .scudo: + throw StringError("\(sanitizer) is not currently supported with this build system.") + } } // FIXME: workaround for old Xcode installations such as what is in CI @@ -985,6 +1007,38 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { settings["GENERATE_TEST_ENTRYPOINTS_FOR_BUNDLES"] = "YES" } + // Set the value of the index store + struct IndexStoreSettings { + let enableVariableName: String + let pathVariable: String + } + + let indexStoreSettingNames: [IndexStoreSettings] = [ + IndexStoreSettings( + enableVariableName: "CLANG_INDEX_STORE_ENABLE", + pathVariable: "CLANG_INDEX_STORE_PATH", + ), + IndexStoreSettings( + enableVariableName: "SWIFT_INDEX_STORE_ENABLE", + pathVariable: "SWIFT_INDEX_STORE_PATH", + ), + ] + + switch self.buildParameters.indexStoreMode { + case .on: + for setting in indexStoreSettingNames { + settings[setting.enableVariableName] = "YES" + settings[setting.pathVariable] = self.buildParameters.indexStore.pathString + } + case .off: + for setting in indexStoreSettingNames { + settings[setting.enableVariableName] = "NO" + } + case .auto: + // The settings are handles in the PIF builder + break + } + func reportConflict(_ a: String, _ b: String) throws -> String { throw StringError("Build parameters constructed conflicting settings overrides '\(a)' and '\(b)'") } @@ -1171,11 +1225,15 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { } public func generatePIF(preserveStructure: Bool) async throws -> String { - return try await getPIFBuilder().generatePIF( + pifBuilder = .init() + packageGraph = .init() + let pifBuilder = try await getPIFBuilder() + let pif = try await pifBuilder.generatePIF( preservePIFModelStructure: preserveStructure, printPIFManifestGraphviz: buildParameters.printPIFManifestGraphviz, buildParameters: buildParameters ) + return pif } public func writePIF(buildParameters: BuildParameters) async throws { @@ -1183,6 +1241,27 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem { try self.fileSystem.writeIfChanged(path: buildParameters.pifManifest, string: pif) } + package struct LongLivedBuildServiceSession { + package var session: SWBBuildServiceSession + package var diagnostics: [SwiftBuildMessage.DiagnosticInfo] + package var teardownHandler: () async throws -> Void + } + + package func createLongLivedSession(name: String) async throws -> LongLivedBuildServiceSession { + let service = try await SWBBuildService(connectionMode: .inProcessStatic(swiftbuildServiceEntryPoint)) + do { + let (session, diagnostics) = try await createSession(service: service, name: name, toolchainPath: buildParameters.toolchain.toolchainDir, packageManagerResourcesDirectory: packageManagerResourcesDirectory) + let teardownHandler = { + try await session.close() + await service.close() + } + return LongLivedBuildServiceSession(session: session, diagnostics: diagnostics, teardownHandler: teardownHandler) + } catch { + await service.close() + throw error + } + } + public func cancel(deadline: DispatchTime) throws {} /// Returns the package graph using the graph loader closure. @@ -1223,13 +1302,13 @@ fileprivate extension SwiftBuild.SwiftBuildMessage.DiagnosticInfo.Location { case .none: return path } - + case .buildSettings(let names): return names.joined(separator: ", ") - + case .buildFiles(let buildFiles, let targetGUID): return "\(targetGUID): " + buildFiles.map { String(describing: $0) }.joined(separator: ", ") - + case .unknown: return nil } diff --git a/Sources/SwiftPMBuildServer/CMakeLists.txt b/Sources/SwiftPMBuildServer/CMakeLists.txt new file mode 100644 index 00000000000..c4265428a65 --- /dev/null +++ b/Sources/SwiftPMBuildServer/CMakeLists.txt @@ -0,0 +1,35 @@ +# This source file is part of the Swift open source project +# +# Copyright (c) 2025 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +add_library(SwiftPMBuildServer STATIC + DisableSigpipe.swift + SwiftPMBuildServer.swift) +target_link_libraries(SwiftPMBuildServer PUBLIC + Basics + Build + PackageGraph + PackageLoading + PackageModel + SPMBuildCore + SourceControl + SourceKitLSPAPI + SwiftBuildSupport + Workspace + + SwiftBuild::SwiftBuild + + SwiftToolsProtocols::ToolsProtocolsSwiftExtensions + SwiftToolsProtocols::BuildServerProtocol + SwiftToolsProtocols::LanguageServerProtocol + SwiftToolsProtocols::LanguageServerProtocolTransport + + TSCBasic) + +# NOTE(compnerd) workaround for CMake not setting up include flags yet +set_target_properties(SwiftPMBuildServer PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) diff --git a/Sources/SwiftPMBuildServer/DisableSigpipe.swift b/Sources/SwiftPMBuildServer/DisableSigpipe.swift new file mode 100644 index 00000000000..3035104a9fa --- /dev/null +++ b/Sources/SwiftPMBuildServer/DisableSigpipe.swift @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +#if canImport(Glibc) +import Glibc +#elseif canImport(Musl) +import Musl +#elseif canImport(Android) +import Android +#endif + +#if canImport(Glibc) || canImport(Musl) || canImport(Android) +// This is a lazily initialised global variable that when read for the first time, will ignore SIGPIPE. +private let globallyIgnoredSIGPIPE: Bool = { + /* no F_SETNOSIGPIPE on Linux :( */ + _ = signal(SIGPIPE, SIG_IGN) + return true +}() +#endif + +/// We receive a `SIGPIPE` if we write to a pipe that points to a crashed process. This in particular happens if the +/// target of a `JSONRPCConnection` has crashed and we try to send it a message or if swift-format crashes and we try +/// to send the source file to it. +/// +/// On Darwin, `DispatchIO` ignores `SIGPIPE` for the pipes handled by it and swift-tools-support-core offers +/// `LocalFileOutputByteStream.disableSigpipe`, but that features is not available on Linux. +/// +/// Instead, globally ignore `SIGPIPE` on Linux to prevent us from crashing if the `JSONRPCConnection`'s target crashes. +/// +/// On Darwin platforms and on Windows this is a no-op. +package func globallyDisableSigpipeIfNeeded() { + #if !canImport(Darwin) && !os(Windows) + let haveWeIgnoredSIGPIEThisIsHereToTriggerIgnoringIt = globallyIgnoredSIGPIPE + guard haveWeIgnoredSIGPIEThisIsHereToTriggerIgnoringIt else { + fatalError("globallyIgnoredSIGPIPE should always be true") + } + #endif +} diff --git a/Sources/SwiftPMBuildServer/SwiftPMBuildServer.swift b/Sources/SwiftPMBuildServer/SwiftPMBuildServer.swift new file mode 100644 index 00000000000..8997851d5af --- /dev/null +++ b/Sources/SwiftPMBuildServer/SwiftPMBuildServer.swift @@ -0,0 +1,363 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// +#if canImport(LanguageServerProtocolTransport) +import Basics +import SwiftBuild +import Foundation +import SPMBuildCore +import SwiftBuildSupport +import SwiftBuild +import SWBBuildService +import Workspace +import BuildServerProtocol +import LanguageServerProtocol +import LanguageServerProtocolTransport +import ToolsProtocolsSwiftExtensions + +// Remove these extensions once they've been added to swift-tools-protocols +package extension Connection { + func withCancellableCheckedThrowingContinuation( + _ operation: (_ continuation: CheckedContinuation) -> Handle, + cancel: @Sendable (Handle) -> Void + ) async throws -> Result { + let handleWrapper = ThreadSafeBox(nil) + + @Sendable + func callCancel() { + /// Take the request ID out of the box. This ensures that we only send the + /// cancel notification once in case the `Task.isCancelled` and the + /// `onCancel` check race. + if let handle = handleWrapper.takeValue() { + cancel(handle) + } + } + + return try await withTaskCancellationHandler( + operation: { + try Task.checkCancellation() + return try await withCheckedThrowingContinuation { continuation in + handleWrapper.put(operation(continuation)) + + // Check if the task was cancelled. This ensures we send a + // CancelNotification even if the task gets cancelled after we register + // the cancellation handler but before we set the `requestID`. + if Task.isCancelled { + callCancel() + } + } + }, + onCancel: callCancel + ) + } + + func send(_ request: R) async throws -> R.Response { + return try await withCancellableCheckedThrowingContinuation { continuation in + return self.send(request) { result in + continuation.resume(with: result) + } + } cancel: { requestID in + self.send(CancelRequestNotification(id: requestID)) + } + } +} + +public actor SwiftPMBuildServer: QueueBasedMessageHandler { + private let underlyingBuildServer: SWBBuildServer + private let connectionToUnderlyingBuildServer: LocalConnection + private let packageRoot: Basics.AbsolutePath + private let buildSystem: SwiftBuildSystem + private let workspace: Workspace + + public let messageHandlingHelper = QueueBasedMessageHandlerHelper( + signpostLoggingCategory: "build-server-message-handling", + createLoggingScope: false + ) + public let messageHandlingQueue = AsyncQueue() + /// Serializes package loading + private let packageLoadingQueue = AsyncQueue() + /// Connection used to send messages to the client of the build server. + private let connectionToClient: any Connection + + /// Represents the lifetime of the build server implementation.. + enum ServerState: CustomStringConvertible { + case waitingForInitializeRequest + case waitingForInitializedNotification + case running + case shutdown + + var description: String { + switch self { + case .waitingForInitializeRequest: + "waiting for initialization request" + case .waitingForInitializedNotification: + "waiting for initialization notification" + case .running: + "running" + case .shutdown: + "shutdown" + } + } + } + var state: ServerState = .waitingForInitializeRequest + /// Allows customization of server exit behavior. + var exitHandler: (Int) -> Void + + public init(packageRoot: Basics.AbsolutePath, buildSystem: SwiftBuildSystem, workspace: Workspace, connectionToClient: any Connection, exitHandler: @escaping (Int) -> Void) async throws { + self.packageRoot = packageRoot + self.buildSystem = buildSystem + self.workspace = workspace + self.connectionToClient = connectionToClient + self.exitHandler = exitHandler + let session = try await buildSystem.createLongLivedSession(name: "swiftpm-build-server") + let connectionToUnderlyingBuildServer = LocalConnection(receiverName: "underlying-swift-build-server") + self.connectionToUnderlyingBuildServer = connectionToUnderlyingBuildServer + let connectionFromUnderlyingBuildServer = LocalConnection(receiverName: "swiftpm-build-server") + // TODO: fix derived data path, cleanup configured targets list computation + let buildrequest = try await self.buildSystem.makeBuildRequest( + session: session.session, + configuredTargets: [.init(rawValue: "ALL-INCLUDING-TESTS")], + derivedDataPath: self.buildSystem.buildParameters.buildPath, + symbolGraphOptions: nil + ) + self.underlyingBuildServer = SWBBuildServer( + session: session.session, + containerPath: buildSystem.buildParameters.pifManifest.pathString, + buildRequest: buildrequest, + connectionToClient: connectionFromUnderlyingBuildServer, + exitHandler: { _ in + connectionToUnderlyingBuildServer.close() + try? await session.teardownHandler() + } + ) + connectionToUnderlyingBuildServer.start(handler: underlyingBuildServer) + connectionFromUnderlyingBuildServer.start(handler: self) + } + + public func handle(notification: some NotificationType) async { + switch notification { + case is OnBuildExitNotification: + connectionToUnderlyingBuildServer.send(notification) + if state == .shutdown { + exitHandler(0) + } else { + exitHandler(1) + } + case is OnBuildInitializedNotification: + connectionToUnderlyingBuildServer.send(notification) + state = .running + case let notification as OnWatchedFilesDidChangeNotification: + // The underlying build server only receives updates via new PIF, so don't forward this notification. + for change in notification.changes { + if self.fileEventShouldTriggerPackageReload(event: change) { + scheduleRegeneratingBuildDescription() + return + } + } + case is OnBuildLogMessageNotification: + // If we receive a build log message notification, forward it on to the client + connectionToClient.send(notification) + default: + logToClient(.warning, "SwiftPM build server received unknown notification type: \(notification)") + } + } + + private func logToClient(_ kind: BuildServerProtocol.MessageType, _ message: String, _ structure: BuildServerProtocol.StructuredLogKind? = nil) { + connectionToClient.send( + OnBuildLogMessageNotification(type: .log, message: "\(message)", structure: structure) + ) + } + + public func handle( + request: Request, + id: RequestID, + reply: @Sendable @escaping (LSPResult) -> Void + ) async { + let request = RequestAndReply(request, reply: reply) + switch request { + case let request as RequestAndReply: + await request.reply { + _ = try await connectionToUnderlyingBuildServer.send(request.params) + return await shutdown() + } + case let request as RequestAndReply: + await request.reply { + var underlyingRequest = request.params + underlyingRequest.targets.removeAll(where: \.isSwiftPMBuildServerTargetID ) + return try await connectionToUnderlyingBuildServer.send(underlyingRequest) + } + case let request as RequestAndReply: + await request.reply { + var underlyingRequest = request.params + underlyingRequest.targets.removeAll(where: \.isSwiftPMBuildServerTargetID) + var sourcesResponse = try await connectionToUnderlyingBuildServer.send(underlyingRequest) + for target in request.params.targets.filter({ $0.isSwiftPMBuildServerTargetID }) { + if target == .forPackageManifest { + sourcesResponse.items.append(await manifestSourcesItem()) + } else { + await logToClient(.warning, "SwiftPM build server processed target sources request for unexpected target '\(target)'") + } + } + return sourcesResponse + } + case let request as RequestAndReply: + await request.reply { try await self.initialize(request: request.params) } + case let request as RequestAndReply: + await request.reply { + if request.params.target.isSwiftPMBuildServerTargetID { + return try await manifestSourceKitOptions(request: request.params) + } else { + return try await connectionToUnderlyingBuildServer.send(request.params) + } + } + case let request as RequestAndReply: + await request.reply { + var targetsResponse = try await connectionToUnderlyingBuildServer.send(request.params) + targetsResponse.targets.append(await manifestTarget()) + return targetsResponse + } + case let request as RequestAndReply: + await request.reply { + await waitForBuildSystemUpdates(request: request.params) + } + default: + await request.reply { throw ResponseError.methodNotFound(Request.method) } + } + } + + private func initialize(request: InitializeBuildRequest) async throws -> InitializeBuildResponse { + if state != .waitingForInitializeRequest { + logToClient(.warning, "Received initialization request while the build server is \(state)") + } + let underlyingInitializationResponse = try await connectionToUnderlyingBuildServer.send(request) + let underlyingSourceKitData = SourceKitInitializeBuildResponseData(fromLSPAny: underlyingInitializationResponse.data) + if underlyingSourceKitData?.watchers?.isEmpty == false { + logToClient(.warning, "Underlying build server reported unexpected file watchers") + } + state = .waitingForInitializedNotification + scheduleRegeneratingBuildDescription() + return InitializeBuildResponse( + displayName: "SwiftPM Build Server", + version: SwiftVersion.current.displayString, + bspVersion: "2.2.0", + capabilities: BuildServerCapabilities(), + dataKind: .sourceKit, + data: SourceKitInitializeBuildResponseData( + indexDatabasePath: underlyingSourceKitData?.indexDatabasePath, + indexStorePath: underlyingSourceKitData?.indexStorePath, + outputPathsProvider: true, + prepareProvider: true, + sourceKitOptionsProvider: true, + watchers: [] + ).encodeToLSPAny() + ) + } + + private func manifestTarget() -> BuildTarget { + // In the future, we should add a new target to represent plugin scripts so they can load the PackagePlugin module. + return BuildTarget( + id: .forPackageManifest, + displayName: "Package Manifest", + tags: [.notBuildable], + languageIds: [.swift], + dependencies: [] + ) + } + + private let versionSpecificManifestRegex = #/^Package@swift-(\d+)(?:\.(\d+))?(?:\.(\d+))?.swift$/# + + private func manifestSourcesItem() -> SourcesItem { + let versionSpecificManifests = try? FileManager.default.contentsOfDirectory( + at: packageRoot.asURL, + includingPropertiesForKeys: nil + ).compactMap { (url) -> SourceItem? in + guard (try? versionSpecificManifestRegex.wholeMatch(in: url.lastPathComponent)) != nil else { + return nil + } + return SourceItem( + uri: DocumentURI(url), + kind: .file, + generated: false + ) + } + return SourcesItem(target: .forPackageManifest, sources: [ + SourceItem( + uri: DocumentURI(packageRoot.appending(component: "Package.swift").asURL), + kind: .file, + generated: false + ) + ] + (versionSpecificManifests ?? [])) + } + + private func manifestSourceKitOptions(request: TextDocumentSourceKitOptionsRequest) async throws -> TextDocumentSourceKitOptionsResponse? { + guard request.target == .forPackageManifest else { + throw ResponseError.unknown("Unknown target \(request.target)") + } + guard let path = try request.textDocument.uri.fileURL?.filePath else { + throw ResponseError.unknown("Unknown manifest path for \(request.textDocument.uri.pseudoPath)") + } + let compilerArgs = try workspace.interpreterFlags(for: path) + [path.pathString] + return TextDocumentSourceKitOptionsResponse(compilerArguments: compilerArgs) + } + + private func shutdown() -> VoidResponse { + state = .shutdown + return VoidResponse() + } + + private func waitForBuildSystemUpdates(request: WorkspaceWaitForBuildSystemUpdatesRequest) async -> VoidResponse { + await packageLoadingQueue.async {}.valuePropagatingCancellation + return VoidResponse() + } + + /// An event is relevant if it modifies a file that matches one of the file rules used by the SwiftPM workspace. + private func fileEventShouldTriggerPackageReload(event: FileEvent) -> Bool { + guard let fileURL = event.uri.fileURL else { + return false + } + switch event.type { + case .created, .deleted: + // This is overly conservative, we may want to consider restricting it to file types which will be built. + // However, the possibility of a plugin which might process an arbitrary file type makes this difficult. + return true + case .changed: + return fileURL.lastPathComponent == "Package.swift" || fileURL.lastPathComponent == "Package.resolved" || fileURL.lastPathComponent.wholeMatch(of: versionSpecificManifestRegex) != nil + default: + logToClient(.warning, "received unknown file event type: '\(event.type)'") + return false + } + } + + public func scheduleRegeneratingBuildDescription() { + packageLoadingQueue.async { [buildSystem] in + do { + try await buildSystem.writePIF(buildParameters: buildSystem.buildParameters) + self.connectionToUnderlyingBuildServer.send(OnWatchedFilesDidChangeNotification(changes: [ + .init(uri: .init(buildSystem.buildParameters.pifManifest.asURL), type: .changed) + ])) + _ = try await self.connectionToUnderlyingBuildServer.send(WorkspaceWaitForBuildSystemUpdatesRequest()) + } catch { + self.logToClient(.warning, "error regenerating build description: \(error)") + } + } + } +} + +extension BuildTargetIdentifier { + static let swiftPMBuildServerTargetScheme = "swiftpm" + + static let forPackageManifest = BuildTargetIdentifier(uri: try! URI(string: "\(swiftPMBuildServerTargetScheme)://package-manifest")) + + var isSwiftPMBuildServerTargetID: Bool { + uri.scheme == Self.swiftPMBuildServerTargetScheme + } +} +#endif diff --git a/Sources/Workspace/ManifestSigning/Base64URL.swift b/Sources/Workspace/ManifestSigning/Base64URL.swift index bae48bb4c62..fa803b7052e 100644 --- a/Sources/Workspace/ManifestSigning/Base64URL.swift +++ b/Sources/Workspace/ManifestSigning/Base64URL.swift @@ -25,7 +25,7 @@ import Foundation -// Source: https://github.com/vapor/jwt-kit/blob/master/Sources/JWTKit/Utilities/Base64URL.swift +// Source: https://github.com/vapor/jwt-kit/blob/main/Sources/JWTKit/Utilities/Base64URL.swift extension DataProtocol { func base64URLDecodedBytes() -> Data? { diff --git a/Sources/Workspace/ManifestSigning/Signature.swift b/Sources/Workspace/ManifestSigning/Signature.swift index 76e27d45d10..7a7ac509723 100644 --- a/Sources/Workspace/ManifestSigning/Signature.swift +++ b/Sources/Workspace/ManifestSigning/Signature.swift @@ -64,7 +64,7 @@ extension Signature { } } -// Reference: https://github.com/vapor/jwt-kit/blob/master/Sources/JWTKit/JWTSerializer.swift +// Reference: https://github.com/vapor/jwt-kit/blob/main/Sources/JWTKit/JWTSerializer.swift extension Signature { static let rsaSigningPadding = _RSA.Signing.Padding.insecurePKCS1v1_5 @@ -100,7 +100,7 @@ extension Signature { } } -// Reference: https://github.com/vapor/jwt-kit/blob/master/Sources/JWTKit/JWTParser.swift +// Reference: https://github.com/vapor/jwt-kit/blob/main/Sources/JWTKit/JWTParser.swift extension Signature { typealias CertChainValidate = ([Data]) async throws -> [Certificate] diff --git a/Sources/Workspace/ManifestSigning/embedded_resources.swift b/Sources/Workspace/ManifestSigning/embedded_resources.swift index a1dbeb69b2f..b9c04a7faee 100644 --- a/Sources/Workspace/ManifestSigning/embedded_resources.swift +++ b/Sources/Workspace/ManifestSigning/embedded_resources.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// struct PackageResources { static let AppleWWDRCAG2_cer: [UInt8] = [48,130,2,247,48,130,2,124,160,3,2,1,2,2,8,111,239,216,245,233,163,167,238,48,10,6,8,42,134,72,206,61,4,3,2,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,30,23,13,49,52,48,53,48,54,50,51,52,51,50,52,90,23,13,50,57,48,53,48,54,50,51,52,51,50,52,90,48,129,128,49,52,48,50,6,3,85,4,3,12,43,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,65,32,45,32,71,50,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,89,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,66,0,4,221,240,183,6,75,207,221,115,4,19,196,67,137,3,147,128,251,94,246,116,173,66,97,82,88,2,38,83,25,200,99,34,7,9,82,97,202,196,217,87,239,109,38,104,139,116,145,140,196,249,128,104,40,252,9,104,240,16,218,233,208,46,201,26,163,129,247,48,129,244,48,70,6,8,43,6,1,5,5,7,1,1,4,58,48,56,48,54,6,8,43,6,1,5,5,7,48,1,134,42,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,52,45,97,112,112,108,101,114,111,111,116,99,97,103,51,48,29,6,3,85,29,14,4,22,4,20,132,182,132,204,58,134,98,114,22,89,148,232,26,163,189,72,223,58,223,11,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,31,6,3,85,29,35,4,24,48,22,128,20,187,176,222,161,88,51,136,154,164,138,153,222,190,189,235,175,218,203,36,171,48,55,6,3,85,29,31,4,48,48,46,48,44,160,42,160,40,134,38,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,97,112,112,108,101,114,111,111,116,99,97,103,51,46,99,114,108,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,15,4,2,5,0,48,10,6,8,42,134,72,206,61,4,3,2,3,105,0,48,102,2,49,0,217,177,199,49,198,35,246,79,77,208,217,71,197,125,24,105,17,135,113,39,211,104,173,224,155,101,154,190,108,223,63,70,166,144,9,190,110,161,59,44,176,81,137,65,60,135,210,191,2,49,0,252,100,82,137,75,60,93,191,107,28,194,137,152,47,114,174,181,155,170,26,11,35,84,119,84,232,21,67,162,197,18,218,151,80,115,124,94,208,110,178,92,98,80,215,81,241,58,90] static let AppleWWDRCAG3_cer: [UInt8] = [48,130,4,81,48,130,3,57,160,3,2,1,2,2,16,124,175,105,10,37,183,57,254,123,155,68,122,193,120,197,238,48,13,6,9,42,134,72,134,247,13,1,1,11,5,0,48,98,49,11,48,9,6,3,85,4,6,19,2,85,83,49,19,48,17,6,3,85,4,10,19,10,65,112,112,108,101,32,73,110,99,46,49,38,48,36,6,3,85,4,11,19,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,22,48,20,6,3,85,4,3,19,13,65,112,112,108,101,32,82,111,111,116,32,67,65,48,30,23,13,50,48,48,50,49,57,49,56,49,51,52,55,90,23,13,51,48,48,50,50,48,48,48,48,48,48,48,90,48,117,49,68,48,66,6,3,85,4,3,12,59,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,11,48,9,6,3,85,4,11,12,2,71,51,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,130,1,34,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,130,1,15,0,48,130,1,10,2,130,1,1,0,216,245,137,252,168,89,11,135,199,76,145,46,45,86,144,211,120,29,164,48,233,165,72,239,11,67,191,45,132,251,36,93,69,27,229,235,89,54,18,92,84,100,158,108,98,45,180,198,151,202,204,60,246,214,6,145,252,229,2,166,28,106,180,121,213,103,203,172,233,63,7,17,225,132,188,71,29,102,142,57,162,232,180,73,237,58,210,225,16,96,122,142,147,140,202,192,218,12,192,131,208,227,249,145,214,167,140,200,193,115,226,174,70,209,98,157,146,168,144,96,55,125,104,150,205,141,224,252,155,250,120,187,227,123,175,45,23,221,91,254,128,89,35,117,23,184,18,193,237,27,229,52,206,254,34,181,158,73,176,229,85,191,143,132,162,60,168,186,197,134,149,22,228,0,201,159,3,208,204,179,58,22,123,214,5,92,157,235,71,174,13,181,45,140,14,105,77,64,208,75,76,59,4,158,141,33,177,172,46,67,84,48,206,193,138,134,148,152,75,223,106,13,63,254,251,28,174,151,23,194,120,10,48,224,95,31,84,59,73,183,37,0,26,55,130,210,86,151,165,82,73,124,96,56,155,239,2,3,1,0,1,163,129,239,48,129,236,48,18,6,3,85,29,19,1,1,255,4,8,48,6,1,1,255,2,1,0,48,31,6,3,85,29,35,4,24,48,22,128,20,43,208,105,71,148,118,9,254,244,107,141,46,64,166,247,71,77,127,8,94,48,68,6,8,43,6,1,5,5,7,1,1,4,56,48,54,48,52,6,8,43,6,1,5,5,7,48,1,134,40,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,51,45,97,112,112,108,101,114,111,111,116,99,97,48,46,6,3,85,29,31,4,39,48,37,48,35,160,33,160,31,134,29,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,114,111,111,116,46,99,114,108,48,29,6,3,85,29,14,4,22,4,20,9,254,192,21,144,249,175,100,10,146,18,185,38,40,99,12,151,236,167,178,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,1,4,2,5,0,48,13,6,9,42,134,72,134,247,13,1,1,11,5,0,3,130,1,1,0,173,101,19,232,246,224,129,119,68,2,71,66,190,95,165,57,32,234,98,169,253,197,144,201,115,19,213,158,155,208,170,15,141,141,203,237,1,207,108,40,64,91,199,85,36,65,248,252,207,193,181,35,233,220,236,241,111,202,128,29,119,194,196,97,73,37,103,175,15,202,57,37,173,211,227,122,204,51,40,13,14,46,161,87,64,115,250,230,92,174,6,81,41,237,227,133,12,79,97,220,50,22,139,119,208,68,202,93,114,3,49,70,156,174,155,64,26,250,244,224,211,62,250,47,140,102,159,151,196,84,89,239,210,72,244,7,153,73,96,89,25,199,221,148,209,192,193,108,127,120,33,239,12,235,59,108,153,130,75,82,96,56,181,57,130,109,236,82,49,83,190,15,145,76,73,73,116,143,166,81,203,132,71,78,29,117,39,110,189,249,210,92,243,127,194,108,11,9,54,226,100,228,194,55,3,20,25,213,234,106,148,170,169,219,254,246,154,8,103,139,239,43,184,170,23,73,131,175,207,203,188,233,207,234,149,113,176,180,69,162,204,229,135,170,10,195,65,58,121,92,218,80,52,157,149,59] @@ -10,4 +21,4 @@ static let AppleWWDRCAG4_cer: [UInt8] = [48,130,4,85,48,130,3,61,160,3,2,1,2,2,2 static let AppleWWDRCAG6_cer: [UInt8] = [48,130,3,22,48,130,2,156,160,3,2,1,2,2,20,34,193,161,71,10,116,115,105,239,83,134,18,201,198,159,61,56,243,108,215,48,10,6,8,42,134,72,206,61,4,3,3,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,30,23,13,50,49,48,51,49,55,50,48,51,55,49,48,90,23,13,51,54,48,51,49,57,48,48,48,48,48,48,90,48,117,49,68,48,66,6,3,85,4,3,12,59,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,11,48,9,6,3,85,4,11,12,2,71,54,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,110,196,10,11,222,15,174,85,166,101,121,215,130,220,115,117,82,75,241,61,18,25,137,224,13,17,169,158,9,247,55,163,211,240,147,4,111,177,67,139,134,193,152,248,66,157,157,255,178,174,143,23,247,6,112,165,214,176,190,111,58,215,145,135,34,120,231,29,192,72,254,220,56,31,154,106,143,116,125,202,113,74,255,196,100,86,231,136,6,205,129,145,161,34,26,72,163,129,250,48,129,247,48,18,6,3,85,29,19,1,1,255,4,8,48,6,1,1,255,2,1,0,48,31,6,3,85,29,35,4,24,48,22,128,20,187,176,222,161,88,51,136,154,164,138,153,222,190,189,235,175,218,203,36,171,48,70,6,8,43,6,1,5,5,7,1,1,4,58,48,56,48,54,6,8,43,6,1,5,5,7,48,1,134,42,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,51,45,97,112,112,108,101,114,111,111,116,99,97,103,51,48,55,6,3,85,29,31,4,48,48,46,48,44,160,42,160,40,134,38,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,97,112,112,108,101,114,111,111,116,99,97,103,51,46,99,114,108,48,29,6,3,85,29,14,4,22,4,20,63,47,148,35,81,211,80,201,154,40,61,237,176,124,229,207,165,144,98,153,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,1,4,2,5,0,48,10,6,8,42,134,72,206,61,4,3,3,3,104,0,48,101,2,48,64,94,20,170,228,140,138,162,3,2,62,220,56,247,64,90,7,174,251,9,161,6,37,123,159,64,31,196,169,145,157,232,36,163,136,43,78,158,227,19,109,117,87,155,28,92,197,249,2,49,0,211,72,252,90,173,149,239,54,185,49,83,116,228,80,194,55,223,44,239,21,85,81,79,140,49,88,144,189,247,131,172,117,198,120,249,17,141,177,128,242,71,152,38,118,189,39,12,104] static let AppleWWDRCAG8_cer: [UInt8] = [48,130,4,85,48,130,3,61,160,3,2,1,2,2,20,84,181,11,175,121,13,141,127,140,175,104,76,86,47,80,105,10,26,186,95,48,13,6,9,42,134,72,134,247,13,1,1,5,5,0,48,98,49,11,48,9,6,3,85,4,6,19,2,85,83,49,19,48,17,6,3,85,4,10,19,10,65,112,112,108,101,32,73,110,99,46,49,38,48,36,6,3,85,4,11,19,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,22,48,20,6,3,85,4,3,19,13,65,112,112,108,101,32,82,111,111,116,32,67,65,48,30,23,13,50,51,48,54,50,48,50,51,51,55,49,53,90,23,13,50,53,48,49,50,52,48,48,48,48,48,48,90,48,117,49,11,48,9,6,3,85,4,6,19,2,85,83,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,11,12,2,71,56,49,68,48,66,6,3,85,4,3,12,59,65,112,112,108,101,32,87,111,114,108,100,119,105,100,101,32,68,101,118,101,108,111,112,101,114,32,82,101,108,97,116,105,111,110,115,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,48,130,1,34,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,130,1,15,0,48,130,1,10,2,130,1,1,0,208,64,16,212,8,249,82,33,99,79,60,104,247,212,156,130,2,140,131,104,188,183,141,127,136,231,66,77,44,239,34,165,194,137,222,189,12,215,77,97,80,45,57,228,48,115,165,210,213,104,154,51,242,239,217,42,173,46,31,3,186,248,165,241,66,11,87,46,70,198,208,88,211,112,95,247,178,55,239,106,31,62,191,137,57,194,173,254,245,5,251,88,150,49,200,135,44,213,35,186,117,176,44,245,171,160,186,242,32,12,76,235,36,99,105,233,34,64,240,142,88,91,222,100,123,137,27,81,18,4,224,23,178,89,205,223,241,231,206,175,44,50,232,105,193,208,8,126,29,162,71,115,209,75,59,253,185,133,220,71,167,40,130,121,41,72,137,2,40,226,193,236,44,31,91,134,252,216,182,203,113,192,115,1,75,252,5,17,17,108,1,3,52,90,246,129,194,94,31,124,20,14,222,63,107,33,203,79,245,215,97,230,132,3,146,188,231,37,41,158,205,91,12,193,219,227,196,58,217,118,87,172,47,56,20,25,200,183,177,162,85,79,95,78,142,25,89,169,218,253,114,218,176,4,33,5,2,3,1,0,1,163,129,239,48,129,236,48,18,6,3,85,29,19,1,1,255,4,8,48,6,1,1,255,2,1,0,48,31,6,3,85,29,35,4,24,48,22,128,20,43,208,105,71,148,118,9,254,244,107,141,46,64,166,247,71,77,127,8,94,48,68,6,8,43,6,1,5,5,7,1,1,4,56,48,54,48,52,6,8,43,6,1,5,5,7,48,1,134,40,104,116,116,112,58,47,47,111,99,115,112,46,97,112,112,108,101,46,99,111,109,47,111,99,115,112,48,51,45,97,112,112,108,101,114,111,111,116,99,97,48,46,6,3,85,29,31,4,39,48,37,48,35,160,33,160,31,134,29,104,116,116,112,58,47,47,99,114,108,46,97,112,112,108,101,46,99,111,109,47,114,111,111,116,46,99,114,108,48,29,6,3,85,29,14,4,22,4,20,181,189,188,128,196,12,227,56,164,244,183,173,35,179,239,68,206,185,90,133,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,16,6,10,42,134,72,134,247,99,100,6,2,1,4,2,5,0,48,13,6,9,42,134,72,134,247,13,1,1,5,5,0,3,130,1,1,0,76,179,235,122,57,148,74,149,102,250,22,49,234,13,138,143,93,66,56,198,7,205,232,201,34,172,252,8,66,126,95,147,95,49,42,168,34,193,118,25,43,238,174,114,233,189,86,207,73,36,146,8,247,205,25,117,195,249,26,39,13,14,220,41,141,63,182,219,165,79,76,114,196,96,145,137,17,126,36,149,67,34,96,103,188,223,255,171,229,60,22,23,157,130,20,78,157,244,117,254,80,185,173,5,178,184,121,246,149,214,16,229,246,83,244,207,35,230,119,15,236,184,75,105,248,226,158,2,49,217,142,217,202,190,99,94,95,225,160,105,206,193,205,110,73,163,120,97,175,57,60,106,75,10,52,37,100,213,48,181,60,171,221,17,129,57,113,232,192,195,88,128,17,16,26,17,210,194,188,89,240,138,217,53,115,192,230,109,228,201,125,98,20,62,130,2,169,16,105,55,121,97,111,240,70,148,62,53,245,171,172,99,208,216,94,89,87,105,209,184,75,110,93,212,95,19,156,112,78,37,17,220,36,44,30,22,158,150,90,4,237,69,238,58,238,103,93,143,195,134,176,245,76,31,104,16] static let AppleRootCA_G3_cer: [UInt8] = [48,130,2,67,48,130,1,201,160,3,2,1,2,2,8,45,197,252,136,210,197,75,149,48,10,6,8,42,134,72,206,61,4,3,3,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,30,23,13,49,52,48,52,51,48,49,56,49,57,48,54,90,23,13,51,57,48,52,51,48,49,56,49,57,48,54,90,48,103,49,27,48,25,6,3,85,4,3,12,18,65,112,112,108,101,32,82,111,111,116,32,67,65,32,45,32,71,51,49,38,48,36,6,3,85,4,11,12,29,65,112,112,108,101,32,67,101,114,116,105,102,105,99,97,116,105,111,110,32,65,117,116,104,111,114,105,116,121,49,19,48,17,6,3,85,4,10,12,10,65,112,112,108,101,32,73,110,99,46,49,11,48,9,6,3,85,4,6,19,2,85,83,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,152,233,47,61,64,114,164,237,147,34,114,129,19,28,221,16,149,241,197,163,78,113,220,20,22,217,14,229,166,5,42,119,100,123,95,78,56,211,187,28,68,181,127,245,31,182,50,98,93,201,233,132,91,79,48,79,17,90,0,253,88,88,12,165,245,15,44,77,7,71,19,117,218,151,151,151,111,49,92,237,43,157,123,32,59,216,185,84,217,94,153,164,58,81,10,49,163,66,48,64,48,29,6,3,85,29,14,4,22,4,20,187,176,222,161,88,51,136,154,164,138,153,222,190,189,235,175,218,203,36,171,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,6,48,10,6,8,42,134,72,206,61,4,3,3,3,104,0,48,101,2,49,0,131,233,193,196,22,94,26,93,52,24,217,237,239,244,108,14,0,70,75,184,223,178,70,17,197,15,253,230,122,140,161,166,107,206,194,3,212,156,245,147,198,116,184,106,223,170,35,21,2,48,109,102,138,16,202,212,13,212,79,205,141,67,62,180,138,99,165,51,110,227,109,218,23,183,100,31,200,83,38,249,136,98,116,57,11,23,91,203,81,168,12,232,24,3,231,162,178,40] -} \ No newline at end of file +} diff --git a/Sources/Workspace/PackageContainer/SourceControlPackageContainer.swift b/Sources/Workspace/PackageContainer/SourceControlPackageContainer.swift index 227a9d8ac4f..89d05743699 100644 --- a/Sources/Workspace/PackageContainer/SourceControlPackageContainer.swift +++ b/Sources/Workspace/PackageContainer/SourceControlPackageContainer.swift @@ -284,7 +284,7 @@ internal final class SourceControlPackageContainer: PackageContainer, CustomStri let isBranchRev = sha1RegEx.matchGroups(in: revision).compactMap { $0 }.isEmpty let errorMessage = "could not find " + (isBranchRev ? "a branch named ‘\(revision)’" : "the commit \(revision)") let mainBranchExists = (try? repository.resolveRevision(identifier: "main")) != nil - let suggestion = (revision == "master" && mainBranchExists) ? "did you mean ‘main’?" : nil + let suggestion = (revision == "master" && mainBranchExists) ? "did you mean ‘main’?" : nil //ignore-unacceptable-language throw GetDependenciesError( repository: self.repositorySpecifier, reference: revision, diff --git a/Sources/Workspace/Workspace+Traits.swift b/Sources/Workspace/Workspace+Traits.swift index 856627f4fcb..20ed1b5e5cc 100644 --- a/Sources/Workspace/Workspace+Traits.swift +++ b/Sources/Workspace/Workspace+Traits.swift @@ -1,12 +1,12 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift.org open source project +// This source file is part of the Swift open source project // // Copyright (c) 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/_AsyncFileSystem/AsyncFileSystem.swift b/Sources/_AsyncFileSystem/AsyncFileSystem.swift index 8bee554e2e1..c5feafbc43b 100644 --- a/Sources/_AsyncFileSystem/AsyncFileSystem.swift +++ b/Sources/_AsyncFileSystem/AsyncFileSystem.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/_AsyncFileSystem/ConcurrencySupport.swift b/Sources/_AsyncFileSystem/ConcurrencySupport.swift index c42fb1066b8..40867d4188b 100644 --- a/Sources/_AsyncFileSystem/ConcurrencySupport.swift +++ b/Sources/_AsyncFileSystem/ConcurrencySupport.swift @@ -1,4 +1,3 @@ - //===----------------------------------------------------------------------===// // // This source file is part of the Swift open source project diff --git a/Sources/_AsyncFileSystem/MockFileSystem.swift b/Sources/_AsyncFileSystem/MockFileSystem.swift index 374952999d8..9f46f0e4c97 100644 --- a/Sources/_AsyncFileSystem/MockFileSystem.swift +++ b/Sources/_AsyncFileSystem/MockFileSystem.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/_AsyncFileSystem/OSFileSystem.swift b/Sources/_AsyncFileSystem/OSFileSystem.swift index b749a07e548..b287053f79c 100644 --- a/Sources/_AsyncFileSystem/OSFileSystem.swift +++ b/Sources/_AsyncFileSystem/OSFileSystem.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/_AsyncFileSystem/OpenReadableFile.swift b/Sources/_AsyncFileSystem/OpenReadableFile.swift index 11cb298c80c..8f43b4fe8bf 100644 --- a/Sources/_AsyncFileSystem/OpenReadableFile.swift +++ b/Sources/_AsyncFileSystem/OpenReadableFile.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023-2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// @@ -30,7 +30,7 @@ package struct OpenReadableFile: Sendable { /// Concrete instance of underlying file storage. let fileHandle: Storage - + /// Creates a readable ``AsyncSequence`` that can be iterated on to read from this file handle. /// - Returns: `ReadableFileStream` value conforming to ``AsyncSequence``, ready for asynchronous iteration. package func read() async throws -> ReadableFileStream { @@ -43,7 +43,7 @@ package struct OpenReadableFile: Sendable { readChunkSize: self.chunkSize ) ) - + case .mock(let array): return ReadableFileStream.mock(.init(bytes: array, chunkSize: self.chunkSize)) } diff --git a/Sources/_AsyncFileSystem/OpenWritableFile.swift b/Sources/_AsyncFileSystem/OpenWritableFile.swift index 7f3f947db7c..afd8d418de5 100644 --- a/Sources/_AsyncFileSystem/OpenWritableFile.swift +++ b/Sources/_AsyncFileSystem/OpenWritableFile.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// @@ -21,11 +21,11 @@ package actor OpenWritableFile: WritableStream { /// Operating system file descriptor and a queue used for reading from that file descriptor without blocking /// the Swift Concurrency thread pool. case real(FileDescriptor, DispatchQueue) - + /// Reference to the ``MockFileSystem`` actor that provides file storage. case mock(MockFileSystem) } - + /// Concrete instance of underlying storage. let storage: Storage @@ -34,7 +34,7 @@ package actor OpenWritableFile: WritableStream { /// Whether the underlying file descriptor has been closed. private var isClosed = false - + /// Creates a new write-only file handle. /// - Parameters: /// - storage: Underlying storage for the file. @@ -43,7 +43,7 @@ package actor OpenWritableFile: WritableStream { self.storage = storage self.path = path } - + /// Writes a sequence of bytes to the buffer. package func write(_ bytes: some Collection & Sendable) async throws { assert(!isClosed) diff --git a/Sources/_AsyncFileSystem/ReadableFileStream.swift b/Sources/_AsyncFileSystem/ReadableFileStream.swift index f218e970ede..9d16a44d5d7 100644 --- a/Sources/_AsyncFileSystem/ReadableFileStream.swift +++ b/Sources/_AsyncFileSystem/ReadableFileStream.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// diff --git a/Sources/_AsyncFileSystem/WritableStream.swift b/Sources/_AsyncFileSystem/WritableStream.swift index 86db106f6bc..6b4296d3914 100644 --- a/Sources/_AsyncFileSystem/WritableStream.swift +++ b/Sources/_AsyncFileSystem/WritableStream.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors -*/ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// package import _Concurrency diff --git a/Sources/_IntegrationTestSupport/Filesystem.swift b/Sources/_IntegrationTestSupport/Filesystem.swift index b8e6e5db9fa..655200d04c2 100644 --- a/Sources/_IntegrationTestSupport/Filesystem.swift +++ b/Sources/_IntegrationTestSupport/Filesystem.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics diff --git a/Sources/_IntegrationTestSupport/Helpers.swift b/Sources/_IntegrationTestSupport/Helpers.swift index 7dd29842e09..346a7b4885c 100644 --- a/Sources/_IntegrationTestSupport/Helpers.swift +++ b/Sources/_IntegrationTestSupport/Helpers.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Foundation import Testing diff --git a/Sources/_InternalTestSupport/BuildSystemProvider+Configuration.swift b/Sources/_InternalTestSupport/BuildSystemProvider+Configuration.swift index 30b3db4b2c7..cb9054d8669 100644 --- a/Sources/_InternalTestSupport/BuildSystemProvider+Configuration.swift +++ b/Sources/_InternalTestSupport/BuildSystemProvider+Configuration.swift @@ -66,7 +66,7 @@ extension BuildSystemProvider.Kind { case .native: return scratchPath + [tripleString, "\(config)".lowercased()] case .swiftbuild: - return scratchPath + [tripleString, "Products", "\(config)".capitalized + suffix] + return scratchPath + ["out", "Products", "\(config)".capitalized + suffix] case .xcode: return scratchPath + ["apple", "Products", "\(config)".capitalized + suffix] } diff --git a/Sources/_InternalTestSupport/CombinationsWithRepetition.swift b/Sources/_InternalTestSupport/CombinationsWithRepetition.swift index 4855780db63..e66d6b77f41 100644 --- a/Sources/_InternalTestSupport/CombinationsWithRepetition.swift +++ b/Sources/_InternalTestSupport/CombinationsWithRepetition.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Foundation package struct CombinationsWithRepetition : Sequence { diff --git a/Sources/_InternalTestSupport/Commands.swift b/Sources/_InternalTestSupport/Commands.swift index bb69f7b84dd..015591c1c3b 100644 --- a/Sources/_InternalTestSupport/Commands.swift +++ b/Sources/_InternalTestSupport/Commands.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import SPMBuildCore import XCTest diff --git a/Sources/_InternalTestSupport/FileSystemHelpers.swift b/Sources/_InternalTestSupport/FileSystemHelpers.swift index 5f08a6ff35e..167ca445483 100644 --- a/Sources/_InternalTestSupport/FileSystemHelpers.swift +++ b/Sources/_InternalTestSupport/FileSystemHelpers.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Foundation import Basics @@ -48,15 +59,15 @@ public func getFiles( ) throws -> [AbsolutePath] { var matchingFiles: [AbsolutePath] = [] let normalizedExtension = `extension`.lowercased() - + guard fileSystem.exists(directory) else { throw StringError("Directory does not exist: \(directory)") } - + guard fileSystem.isDirectory(directory) else { throw StringError("Path is not a directory: \(directory)") } - + if recursive { try fileSystem.enumerate(directory: directory) { filePath in if fileSystem.isFile(filePath) { @@ -79,7 +90,7 @@ public func getFiles( } } } - + return matchingFiles } @@ -102,7 +113,7 @@ public func getFiles( guard let currentWorkingDirectory = fileSystem.currentWorkingDirectory else { throw StringError("Cannot determine current working directory") } - + let absoluteDirectory = currentWorkingDirectory.appending(directory) let absoluteResults = try getFiles( in: absoluteDirectory, @@ -110,7 +121,7 @@ public func getFiles( recursive: recursive, fileSystem: fileSystem ) - + // Convert results back to RelativePath return absoluteResults.map { absolutePath in absolutePath.relative(to: currentWorkingDirectory) diff --git a/Sources/_InternalTestSupport/MockBuildTestHelper.swift b/Sources/_InternalTestSupport/MockBuildTestHelper.swift index 024726107c9..bcb24f05a18 100644 --- a/Sources/_InternalTestSupport/MockBuildTestHelper.swift +++ b/Sources/_InternalTestSupport/MockBuildTestHelper.swift @@ -87,12 +87,13 @@ public func mockBuildParameters( shouldDisableLocalRpath: Bool = false, canRenameEntrypointFunctionName: Bool = false, triple: Basics.Triple = hostTriple, - indexStoreMode: BuildParameters.IndexStoreMode = .off, + indexStoreMode: BuildParameters.IndexStoreMode = .auto, linkerDeadStrip: Bool = true, linkTimeOptimizationMode: BuildParameters.LinkTimeOptimizationMode? = nil, omitFramePointers: Bool? = nil, enableXCFrameworksOnLinux: Bool = false, - prepareForIndexing: BuildParameters.PrepareForIndexingMode = .off + prepareForIndexing: BuildParameters.PrepareForIndexingMode = .off, + sanitizers: [Sanitizer] = [], ) -> BuildParameters { try! BuildParameters( destination: destination, @@ -104,6 +105,7 @@ public func mockBuildParameters( buildSystemKind: buildSystemKind, pkgConfigDirectories: [], workers: 3, + sanitizers: EnabledSanitizers(Set(sanitizers)), indexStoreMode: indexStoreMode, prepareForIndexing: prepareForIndexing, enableXCFrameworksOnLinux: enableXCFrameworksOnLinux, @@ -120,7 +122,7 @@ public func mockBuildParameters( linkTimeOptimizationMode: linkTimeOptimizationMode, shouldDisableLocalRpath: shouldDisableLocalRpath, shouldLinkStaticSwiftStdlib: shouldLinkStaticSwiftStdlib - ) + ), ) } diff --git a/Sources/_InternalTestSupport/ProcessInfo+hostutils.swift b/Sources/_InternalTestSupport/ProcessInfo+hostutils.swift index c09a1c59812..80ece72271c 100644 --- a/Sources/_InternalTestSupport/ProcessInfo+hostutils.swift +++ b/Sources/_InternalTestSupport/ProcessInfo+hostutils.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Foundation extension ProcessInfo { @@ -26,4 +28,4 @@ extension ProcessInfo { return contentString.contains(al2_name) } -} \ No newline at end of file +} diff --git a/Sources/_InternalTestSupport/SwiftTesting+Data.swift b/Sources/_InternalTestSupport/SwiftTesting+Data.swift index 1dc4ab9fa14..678f80b9aa5 100644 --- a/Sources/_InternalTestSupport/SwiftTesting+Data.swift +++ b/Sources/_InternalTestSupport/SwiftTesting+Data.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Testing diff --git a/Sources/_InternalTestSupport/SwiftTesting+Helpers.swift b/Sources/_InternalTestSupport/SwiftTesting+Helpers.swift index d7e3185b9a4..9131e584dab 100644 --- a/Sources/_InternalTestSupport/SwiftTesting+Helpers.swift +++ b/Sources/_InternalTestSupport/SwiftTesting+Helpers.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics import Testing diff --git a/Sources/_InternalTestSupport/SwiftTesting+Tags.swift b/Sources/_InternalTestSupport/SwiftTesting+Tags.swift index 1a9a2ffd677..66d6c441ccc 100644 --- a/Sources/_InternalTestSupport/SwiftTesting+Tags.swift +++ b/Sources/_InternalTestSupport/SwiftTesting+Tags.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Testing @@ -14,6 +16,7 @@ extension Tag { public enum TestSize {} public enum Feature {} public enum Platform {} + public enum FunctionalArea {} @Tag public static var UserWorkflow: Tag } @@ -27,6 +30,12 @@ extension Tag.Platform { @Tag public static var FileSystem: Tag } +extension Tag.FunctionalArea { + @Tag public static var PIF: Tag + @Tag public static var IndexMode: Tag + @Tag public static var Sanitizer: Tag +} + extension Tag.Feature { public enum Command {} public enum CommandLineArguments {} diff --git a/Sources/_InternalTestSupport/SwiftTesting+TraitConditional.swift b/Sources/_InternalTestSupport/SwiftTesting+TraitConditional.swift index 60b550e838f..8142ffa60fe 100644 --- a/Sources/_InternalTestSupport/SwiftTesting+TraitConditional.swift +++ b/Sources/_InternalTestSupport/SwiftTesting+TraitConditional.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import class Foundation.FileManager import class Foundation.ProcessInfo diff --git a/Sources/_InternalTestSupport/SwiftTesting+Traits.swift b/Sources/_InternalTestSupport/SwiftTesting+Traits.swift index 69b91fd83f7..e29b6e83714 100644 --- a/Sources/_InternalTestSupport/SwiftTesting+Traits.swift +++ b/Sources/_InternalTestSupport/SwiftTesting+Traits.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Testing diff --git a/Sources/_InternalTestSupport/SwiftTesting+TraitsBug.swift b/Sources/_InternalTestSupport/SwiftTesting+TraitsBug.swift index a08104d793a..34128dde0b5 100644 --- a/Sources/_InternalTestSupport/SwiftTesting+TraitsBug.swift +++ b/Sources/_InternalTestSupport/SwiftTesting+TraitsBug.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Testing diff --git a/Sources/dummy-swiftc/main.swift b/Sources/dummy-swiftc/main.swift index 407b435ff62..ab398058b64 100644 --- a/Sources/dummy-swiftc/main.swift +++ b/Sources/dummy-swiftc/main.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2023-2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// // This program can be used as `swiftc` in order to influence `-version` output import Foundation diff --git a/Sources/swift-build-prebuilts/build.sh b/Sources/swift-build-prebuilts/build.sh index 95898731484..2985a6b50d4 100755 --- a/Sources/swift-build-prebuilts/build.sh +++ b/Sources/swift-build-prebuilts/build.sh @@ -1,3 +1,15 @@ +#!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2025 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See http://swift.org/LICENSE.txt for license information +## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## swift run swift-build-prebuilts --stage-dir ~/swift/stage --build --test-signing \ --version 600.0.1 \ --version 601.0.1 \ diff --git a/Tests/BasicsTests/ArrayHelpersTests.swift b/Tests/BasicsTests/ArrayHelpersTests.swift index 55cc50fa82c..8a4a6069b11 100644 --- a/Tests/BasicsTests/ArrayHelpersTests.swift +++ b/Tests/BasicsTests/ArrayHelpersTests.swift @@ -1,12 +1,15 @@ -/* - This source file is part of the Swift.org open source project +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// - Copyright (c) 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ import func Basics.nextItem @testable import func Basics.containsNonContiguousSubset diff --git a/Tests/BasicsTests/AsyncProcessTests.swift b/Tests/BasicsTests/AsyncProcessTests.swift index 656831ef3c2..93453c4445c 100644 --- a/Tests/BasicsTests/AsyncProcessTests.swift +++ b/Tests/BasicsTests/AsyncProcessTests.swift @@ -1,13 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ - +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import _InternalTestSupport import _Concurrency import Basics @@ -425,7 +426,7 @@ final class AsyncProcessTests: XCTestCase { func testAsyncStream() async throws { // rdar://133548796 try XCTSkipIfPlatformCI() - try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8547: 'swift test' was hanging.") + try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8547: 'swift test' was stalled.") let (stdoutStream, stdoutContinuation) = AsyncProcess.ReadableStream.makeStream() let (stderrStream, stderrContinuation) = AsyncProcess.ReadableStream.makeStream() @@ -483,7 +484,7 @@ final class AsyncProcessTests: XCTestCase { func testAsyncStreamHighLevelAPI() async throws { // rdar://133548796 try XCTSkipIfPlatformCI() - try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8547: 'swift test' was hanging.") + try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8547: 'swift test' was stalled.") let result = try await AsyncProcess.popen( scriptName: "echo\(ProcessInfo.batSuffix)", // maps to 'processInputs/echo' script diff --git a/Tests/BasicsTests/FileSystem/InMemoryFilesSystemTests.swift b/Tests/BasicsTests/FileSystem/InMemoryFilesSystemTests.swift index be08df26ab1..91e5ee441d0 100644 --- a/Tests/BasicsTests/FileSystem/InMemoryFilesSystemTests.swift +++ b/Tests/BasicsTests/FileSystem/InMemoryFilesSystemTests.swift @@ -1,13 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ - +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics import struct TSCBasic.ByteString import struct TSCBasic.FileSystemError diff --git a/Tests/BasicsTests/FileSystem/PathTests.swift b/Tests/BasicsTests/FileSystem/PathTests.swift index a4c15dac7de..d319371756c 100644 --- a/Tests/BasicsTests/FileSystem/PathTests.swift +++ b/Tests/BasicsTests/FileSystem/PathTests.swift @@ -1,13 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ - +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics import Foundation import Testing @@ -170,7 +171,7 @@ struct PathTests { let actual = AbsolutePath(path).basenameWithoutExt #expect(actual == expected, "Actual is not as expected. Path is: \(path)") - + } @Test( @@ -325,7 +326,7 @@ struct PathTests { @Test func absolutePathValidation() throws { - #expect(throws: Never.self) { + #expect(throws: Never.self) { try AbsolutePath(validating: "/a/b/c/d") } @@ -640,12 +641,12 @@ struct PathTests { } } } - + @Test( .IssueWindowsPathTestsFailures, ) func relativePathValidation() throws { - #expect(throws: Never.self) { + #expect(throws: Never.self) { try RelativePath(validating: "a/b/c/d") } @@ -773,24 +774,24 @@ struct PathTests { do { let data = try JSONEncoder().encode(Baz(path: "")) - #expect(throws: (any Error).self) { + #expect(throws: (any Error).self) { try JSONDecoder().decode(Foo.self, from: data) } - #expect(throws: Never.self) { + #expect(throws: Never.self) { try JSONDecoder().decode(Bar.self, from: data) } // empty string is a valid relative path } do { let data = try JSONEncoder().encode(Baz(path: "foo")) - #expect(throws: (any Error).self) { + #expect(throws: (any Error).self) { try JSONDecoder().decode(Foo.self, from: data) } } do { let data = try JSONEncoder().encode(Baz(path: "/foo")) - #expect(throws: (any Error).self) { + #expect(throws: (any Error).self) { try JSONDecoder().decode(Bar.self, from: data) } } diff --git a/Tests/BinarySymbolsTests/LLVMObjdumpSymbolProviderTests.swift b/Tests/BinarySymbolsTests/LLVMObjdumpSymbolProviderTests.swift index 3bd20328824..52aab86d59e 100644 --- a/Tests/BinarySymbolsTests/LLVMObjdumpSymbolProviderTests.swift +++ b/Tests/BinarySymbolsTests/LLVMObjdumpSymbolProviderTests.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Testing import BinarySymbols import Basics diff --git a/Tests/BuildTests/BuildPlanTests.swift b/Tests/BuildTests/BuildPlanTests.swift index 62abd5aa3db..4370b856710 100644 --- a/Tests/BuildTests/BuildPlanTests.swift +++ b/Tests/BuildTests/BuildPlanTests.swift @@ -623,7 +623,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase { func testPackageNameFlag() async throws { try XCTSkipIfPlatformCI() // test is disabled because it isn't stable, see rdar://118239206 - try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8547: 'swift test' was hanging.") + try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8547: 'swift test' was stalled.") let isFlagSupportedInDriver = try DriverSupport.checkToolchainDriverFlags( flags: ["package-name"], toolchain: UserToolchain.default, diff --git a/Tests/CommandsTests/BuildCommandTests.swift b/Tests/CommandsTests/BuildCommandTests.swift index 5fa514da794..50b7f70de46 100644 --- a/Tests/CommandsTests/BuildCommandTests.swift +++ b/Tests/CommandsTests/BuildCommandTests.swift @@ -846,6 +846,23 @@ struct BuildCommandTestCases { } } + @Test + func pifManifestFileIsCreatedInTheRootScratchPathDirectory() async throws { + try await fixture(name: "Miscellaneous/ParseableInterfaces") { fixturePath in + try await withTemporaryDirectory { tmpDir in + try await executeSwiftBuild( + fixturePath, + extraArgs: [ + "--scratch-path", + tmpDir.pathString, + ], + buildSystem: .swiftbuild + ) + expectFileExists(at: tmpDir.appending("manifest.pif")) + } + } + } + @Test( .tags( .Feature.BuildCache, @@ -857,47 +874,43 @@ struct BuildCommandTestCases { data: BuildData, ) async throws { let buildSystem = data.buildSystem - try await withKnownIssue { - try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in - let buildCompleteRegex = try Regex(#"Build complete!\s?(\([0-9]*\.[0-9]*\s*s(econds)?\))?"#) - do { - let result = try await execute( - packagePath: fixturePath, - configuration: data.config, - buildSystem: buildSystem, - ) - // This test fails to match the 'Compiling' regex; rdar://101815761 - // XCTAssertMatch(result.stdout, .regex("\\[[1-9][0-9]*\\/[1-9][0-9]*\\] Compiling")) - let lines = result.stdout.split(whereSeparator: { $0.isNewline }) - let lastLine = try #require(lines.last) - #expect(lastLine.contains(buildCompleteRegex)) - } + try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in + let buildCompleteRegex = try Regex(#"Build complete!\s?(\([0-9]*\.[0-9]*\s*s(econds)?\))?"#) + do { + let result = try await execute( + packagePath: fixturePath, + configuration: data.config, + buildSystem: buildSystem, + ) + // This test fails to match the 'Compiling' regex; rdar://101815761 + // XCTAssertMatch(result.stdout, .regex("\\[[1-9][0-9]*\\/[1-9][0-9]*\\] Compiling")) + let lines = result.stdout.split(whereSeparator: { $0.isNewline }) + let lastLine = try #require(lines.last) + #expect(lastLine.contains(buildCompleteRegex)) + } - do { - // test second time, to stabilize the cache - try await execute( - packagePath: fixturePath, - configuration: data.config, - buildSystem: buildSystem, - ) - } + do { + // test second time, to stabilize the cache + try await execute( + packagePath: fixturePath, + configuration: data.config, + buildSystem: buildSystem, + ) + } - do { - // test third time, to make sure message is presented even when nothing to build (cached) - let result = try await execute( - packagePath: fixturePath, - configuration: data.config, - buildSystem: buildSystem, - ) - // This test fails to match the 'Compiling' regex; rdar://101815761 - // XCTAssertNoMatch(result.stdout, .regex("\\[[1-9][0-9]*\\/[1-9][0-9]*\\] Compiling")) - let lines = result.stdout.split(whereSeparator: { $0.isNewline }) - let lastLine = try #require(lines.last) - #expect(lastLine.contains(buildCompleteRegex)) - } + do { + // test third time, to make sure message is presented even when nothing to build (cached) + let result = try await execute( + packagePath: fixturePath, + configuration: data.config, + buildSystem: buildSystem, + ) + // This test fails to match the 'Compiling' regex; rdar://101815761 + // XCTAssertNoMatch(result.stdout, .regex("\\[[1-9][0-9]*\\/[1-9][0-9]*\\] Compiling")) + let lines = result.stdout.split(whereSeparator: { $0.isNewline }) + let lastLine = try #require(lines.last) + #expect(lastLine.contains(buildCompleteRegex)) } - } when: { - buildSystem == .swiftbuild && (ProcessInfo.hostOperatingSystem == .windows) } } @@ -1135,31 +1148,24 @@ struct BuildCommandTestCases { func swiftDriverRawOutputGetsNewlines( buildSystem: BuildSystemProvider.Kind, ) async throws { - try await withKnownIssue( - "error produced for this fixture", - isIntermittent: ProcessInfo.hostOperatingSystem == .linux, - ) { - try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in - // Building with `-wmo` should result in a `remark: Incremental compilation has been disabled: it is not - // compatible with whole module optimization` message, which should have a trailing newline. Since that - // message won't be there at all when the legacy compiler driver is used, we gate this check on whether the - // remark is there in the first place. - let result = try await execute( - ["-Xswiftc", "-wmo"], - packagePath: fixturePath, - configuration: .release, - buildSystem: buildSystem, - ) - if result.stdout.contains( - "remark: Incremental compilation has been disabled: it is not compatible with whole module optimization" - ) { - #expect(result.stdout.contains("optimization\n")) - #expect(!result.stdout.contains("optimization[")) - #expect(!result.stdout.contains("optimizationremark")) - } + try await fixture(name: "DependencyResolution/Internal/Simple") { fixturePath in + // Building with `-wmo` should result in a `remark: Incremental compilation has been disabled: it is not + // compatible with whole module optimization` message, which should have a trailing newline. Since that + // message won't be there at all when the legacy compiler driver is used, we gate this check on whether the + // remark is there in the first place. + let result = try await execute( + ["-Xswiftc", "-wmo"], + packagePath: fixturePath, + configuration: .release, + buildSystem: buildSystem, + ) + if result.stdout.contains( + "remark: Incremental compilation has been disabled: it is not compatible with whole module optimization" + ) { + #expect(result.stdout.contains("optimization\n")) + #expect(!result.stdout.contains("optimization[")) + #expect(!result.stdout.contains("optimizationremark")) } - } when: { - ProcessInfo.hostOperatingSystem == .windows && buildSystem == .swiftbuild } } diff --git a/Tests/CommandsTests/PackageCommandTests.swift b/Tests/CommandsTests/PackageCommandTests.swift index c41831f3029..3d6d74f253c 100644 --- a/Tests/CommandsTests/PackageCommandTests.swift +++ b/Tests/CommandsTests/PackageCommandTests.swift @@ -3070,7 +3070,7 @@ struct PackageCommandTests { data: BuildData, ) async throws { try await withKnownIssue( - isIntermittent: ProcessInfo.isHostAmazonLinux2() //rdar://134238535 + isIntermittent: ProcessInfo.isHostAmazonLinux2() // rdar://134238535 ) { // Create a temporary directory without Package.swift try await fixture(name: "Miscellaneous") { fixturePath in @@ -3101,57 +3101,63 @@ struct PackageCommandTests { func purgeCacheInPackageDirectory( data: BuildData, ) async throws { - // Test that purge-cache works in a package directory and successfully purges caches - try await fixture(name: "DependencyResolution/External/Simple") { fixturePath in - let packageRoot = fixturePath.appending("Bar") + try await withKnownIssue( + isIntermittent: ProcessInfo.isHostAmazonLinux2() // rdar://134238535 + ) { + // Test that purge-cache works in a package directory and successfully purges caches + try await fixture(name: "DependencyResolution/External/Simple") { fixturePath in + let packageRoot = fixturePath.appending("Bar") - // Use a unique temporary cache directory for this test - try await withTemporaryDirectory(removeTreeOnDeinit: true) { tempDir in - let cacheDir = tempDir.appending("test-cache") - let cacheArgs = ["--cache-path", cacheDir.pathString] + // Use a unique temporary cache directory for this test + try await withTemporaryDirectory(removeTreeOnDeinit: true) { tempDir in + let cacheDir = tempDir.appending("test-cache") + let cacheArgs = ["--cache-path", cacheDir.pathString] - // Resolve dependencies to populate cache - // Note: This fixture uses local dependencies, so only manifest cache will be populated - try await executeSwiftPackage( - packageRoot, - configuration: data.config, - extraArgs: ["resolve"] + cacheArgs, - buildSystem: data.buildSystem - ) + // Resolve dependencies to populate cache + // Note: This fixture uses local dependencies, so only manifest cache will be populated + try await executeSwiftPackage( + packageRoot, + configuration: data.config, + extraArgs: ["resolve"] + cacheArgs, + buildSystem: data.buildSystem + ) - // Verify manifest cache was populated - let manifestsCache = cacheDir.appending(components: "manifests") - expectDirectoryExists(at: manifestsCache) + // Verify manifest cache was populated + let manifestsCache = cacheDir.appending(components: "manifests") + expectDirectoryExists(at: manifestsCache) - // Check for manifest.db file (main database file) - let manifestDB = manifestsCache.appending("manifest.db") - let hasManifestDB = localFileSystem.exists(manifestDB) + // Check for manifest.db file (main database file) + let manifestDB = manifestsCache.appending("manifest.db") + let hasManifestDB = localFileSystem.exists(manifestDB) - // Check for SQLite auxiliary files that might exist - let manifestDBWAL = manifestsCache.appending("manifest.db-wal") - let manifestDBSHM = manifestsCache.appending("manifest.db-shm") - let hasAuxFiles = localFileSystem.exists(manifestDBWAL) || localFileSystem.exists(manifestDBSHM) + // Check for SQLite auxiliary files that might exist + let manifestDBWAL = manifestsCache.appending("manifest.db-wal") + let manifestDBSHM = manifestsCache.appending("manifest.db-shm") + let hasAuxFiles = localFileSystem.exists(manifestDBWAL) || localFileSystem.exists(manifestDBSHM) - // At least one manifest database file should exist - #expect(hasManifestDB || hasAuxFiles, "Manifest cache should be populated after resolve") + // At least one manifest database file should exist + #expect(hasManifestDB || hasAuxFiles, "Manifest cache should be populated after resolve") - // Run purge-cache - let result = try await executeSwiftPackage( - packageRoot, - configuration: data.config, - extraArgs: ["purge-cache"] + cacheArgs, - buildSystem: data.buildSystem - ) + // Run purge-cache + let result = try await executeSwiftPackage( + packageRoot, + configuration: data.config, + extraArgs: ["purge-cache"] + cacheArgs, + buildSystem: data.buildSystem + ) - // Verify command succeeded - #expect(!result.stderr.contains("Could not find Package.swift")) + // Verify command succeeded + #expect(!result.stderr.contains("Could not find Package.swift")) - // Verify manifest.db was removed (the purge implementation removes this file) - expectFileDoesNotExists(at: manifestDB, "manifest.db should be removed after purge") + // Verify manifest.db was removed (the purge implementation removes this file) + expectFileDoesNotExists(at: manifestDB, "manifest.db should be removed after purge") - // Note: SQLite auxiliary files (WAL/SHM) may or may not be removed depending on SQLite state - // The important check is that the main database file is removed + // Note: SQLite auxiliary files (WAL/SHM) may or may not be removed depending on SQLite state + // The important check is that the main database file is removed + } } + } when: { + ProcessInfo.isHostAmazonLinux2() } } @@ -5640,7 +5646,7 @@ struct PackageCommandTests { data: BuildData, ) async throws { // Plugin arguments: check-testability - try await withKnownIssue { + try await withKnownIssue(isIntermittent: true) { // Overall configuration: debug, plugin build request: debug -> without testability try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in let _ = await #expect(throws: Never.self) { @@ -5668,7 +5674,7 @@ struct PackageCommandTests { func commandPluginBuildTestabilityInternalModule_Release_False( data: BuildData, ) async throws { - try await withKnownIssue { + try await withKnownIssue(isIntermittent: true) { // Overall configuration: debug, plugin build request: release -> without testability try await fixture(name: "Miscellaneous/Plugins/CommandPluginTestStub") { fixturePath in let _ = await #expect(throws: Never.self) { diff --git a/Tests/CommandsTests/RunCommandTests.swift b/Tests/CommandsTests/RunCommandTests.swift index 7da21d8fae7..bfcd11d6ca7 100644 --- a/Tests/CommandsTests/RunCommandTests.swift +++ b/Tests/CommandsTests/RunCommandTests.swift @@ -53,7 +53,7 @@ struct RunCommandTests { buildSystem: BuildSystemProvider.Kind ) async throws { let stdout = try await execute(["-help"], buildSystem: buildSystem).stdout - + #expect(stdout.contains("USAGE: swift run ") || stdout.contains("USAGE: swift run []"), "got stdout:\n \(stdout)") } @@ -106,7 +106,6 @@ struct RunCommandTests { func toolsetDebugger( buildSystem: BuildSystemProvider.Kind, ) async throws { - try await withKnownIssue { try await fixture(name: "Miscellaneous/EchoExecutable") { fixturePath in #if os(Windows) let win32 = ".win32" @@ -135,10 +134,6 @@ struct RunCommandTests { buildSystem == .swiftbuild } } - } when: { - (.swiftbuild == buildSystem && ProcessInfo.hostOperatingSystem == .windows) - || (.native == buildSystem && ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSmokeTestPipeline) - } } @Test( @@ -152,34 +147,29 @@ struct RunCommandTests { func productArgumentPassing( buildSystem: BuildSystemProvider.Kind, ) async throws { - try await withKnownIssue { - try await fixture(name: "Miscellaneous/EchoExecutable") { fixturePath in - let (stdout, stderr) = try await execute( - ["secho", "1", "--hello", "world"], - packagePath: fixturePath, - buildSystem: buildSystem, - ) + try await fixture(name: "Miscellaneous/EchoExecutable") { fixturePath in + let (stdout, stderr) = try await execute( + ["secho", "1", "--hello", "world"], + packagePath: fixturePath, + buildSystem: buildSystem, + ) - // We only expect tool's output on the stdout stream. - #expect(stdout.contains(""" - "1" "--hello" "world" - """)) + // We only expect tool's output on the stdout stream. + #expect(stdout.contains(""" + "1" "--hello" "world" + """)) - // swift-build-tool output should go to stderr. - withKnownIssue { - #expect(stderr.contains("Compiling")) - } when: { - buildSystem == .swiftbuild - } - withKnownIssue { - #expect(stderr.contains("Linking")) - } when: { - buildSystem == .swiftbuild - } + // swift-build-tool output should go to stderr. + withKnownIssue { + #expect(stderr.contains("Compiling")) + } when: { + buildSystem == .swiftbuild + } + withKnownIssue { + #expect(stderr.contains("Linking")) + } when: { + buildSystem == .swiftbuild } - } when: { - (.windows == ProcessInfo.hostOperatingSystem && buildSystem == .swiftbuild) - || (.windows == ProcessInfo.hostOperatingSystem && buildSystem == .native && CiEnvironment.runningInSmokeTestPipeline) } } @@ -220,7 +210,6 @@ struct RunCommandTests { func multipleExecutableAndExplicitExecutable( buildSystem: BuildSystemProvider.Kind, ) async throws { - try await withKnownIssue { try await fixture(name: "Miscellaneous/MultipleExecutables") { fixturePath in let error = await #expect(throws: SwiftPMError.self ) { @@ -242,10 +231,6 @@ struct RunCommandTests { (runOutput, _) = try await execute(["exec2"], packagePath: fixturePath, buildSystem: buildSystem) #expect(runOutput.contains("2")) } - } when: { - ([.windows].contains(ProcessInfo.hostOperatingSystem) && buildSystem == .swiftbuild && CiEnvironment.runningInSelfHostedPipeline) - || (.windows == ProcessInfo.hostOperatingSystem && [.native, .swiftbuild].contains(buildSystem) && CiEnvironment.runningInSmokeTestPipeline) - } } diff --git a/Tests/CommandsTests/Sanitizer+ExtensionsTests.swift b/Tests/CommandsTests/Sanitizer+ExtensionsTests.swift index c7008f269b1..6db32201f71 100644 --- a/Tests/CommandsTests/Sanitizer+ExtensionsTests.swift +++ b/Tests/CommandsTests/Sanitizer+ExtensionsTests.swift @@ -15,7 +15,8 @@ import enum PackageModel.Sanitizer @Suite( .tags( - Tag.TestSize.small, + .TestSize.small, + .FunctionalArea.Sanitizer, ), ) struct SanitizerExtensionTests { diff --git a/Tests/ExtraTests/Tests/ExtraTests/FSWatchTests.swift b/Tests/ExtraTests/Tests/ExtraTests/FSWatchTests.swift index 19c0d62dcf0..e9052022b16 100644 --- a/Tests/ExtraTests/Tests/ExtraTests/FSWatchTests.swift +++ b/Tests/ExtraTests/Tests/ExtraTests/FSWatchTests.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2018-2019 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import XCTest import Basic diff --git a/Tests/ExtraTests/Tests/LinuxMain.swift b/Tests/ExtraTests/Tests/LinuxMain.swift index 28c46698219..b5e149a26c4 100644 --- a/Tests/ExtraTests/Tests/LinuxMain.swift +++ b/Tests/ExtraTests/Tests/LinuxMain.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2018 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import XCTest import ExtraTests diff --git a/Tests/IntegrationTests/BasicTests.swift b/Tests/IntegrationTests/BasicTests.swift index a7ed24883f7..2aeeb5edb43 100644 --- a/Tests/IntegrationTests/BasicTests.swift +++ b/Tests/IntegrationTests/BasicTests.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Foundation import _IntegrationTestSupport diff --git a/Tests/IntegrationTests/SwiftPMTests.swift b/Tests/IntegrationTests/SwiftPMTests.swift index ba2c766080f..773c2612d75 100644 --- a/Tests/IntegrationTests/SwiftPMTests.swift +++ b/Tests/IntegrationTests/SwiftPMTests.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Foundation import _IntegrationTestSupport @@ -152,7 +154,10 @@ private struct SwiftPMTests { } } - @Test(.requireHostOS(.macOS), arguments: [BuildSystemProvider.Kind.native, .swiftbuild]) + @Test( + .requireHostOS(.macOS), + arguments: SupportedBuildSystemOnAllPlatforms, + ) func testArchCustomization(buildSystem: BuildSystemProvider.Kind) async throws { try await withTemporaryDirectory { tmpDir in let packagePath = tmpDir.appending(component: "foo") @@ -192,7 +197,7 @@ private struct SwiftPMTests { ) case .swiftbuild: fooPath = try AbsolutePath( - validating: ".build/\(arch)-apple-macosx/Products/Debug/foo", + validating: ".build/out/Products/Debug/foo", relativeTo: packagePath ) default: @@ -225,7 +230,7 @@ private struct SwiftPMTests { ) case .swiftbuild: fooPath = try AbsolutePath( - validating: ".build/\(hostArch)-apple-macosx/Products/Debug/foo", + validating: ".build/out/Products/Debug/foo", relativeTo: packagePath ) default: diff --git a/Tests/IntegrationTests/XCBuildTests.swift b/Tests/IntegrationTests/XCBuildTests.swift index c6bd4faa4d7..7c679cc2f3f 100644 --- a/Tests/IntegrationTests/XCBuildTests.swift +++ b/Tests/IntegrationTests/XCBuildTests.swift @@ -1,12 +1,15 @@ -/* - This source file is part of the Swift.org open source project +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// - Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ import Basics import _IntegrationTestSupport @@ -521,9 +524,9 @@ private struct XCBuildTests { do { let output = try await executeSwiftTest( - fooPath, + fooPath, extraArgs: ["--parallel"], - buildSystem: .xcode, + buildSystem: .xcode, ) #expect(output.stdout.contains("Testing FooTests")) #expect(output.stdout.contains("Testing CFooTests")) diff --git a/Tests/PackageCollectionsTests/GitHubPackageMetadataProviderTests.swift b/Tests/PackageCollectionsTests/GitHubPackageMetadataProviderTests.swift index d29033ce597..57f6becd591 100644 --- a/Tests/PackageCollectionsTests/GitHubPackageMetadataProviderTests.swift +++ b/Tests/PackageCollectionsTests/GitHubPackageMetadataProviderTests.swift @@ -116,9 +116,9 @@ class GitHubPackageMetadataProviderTests: XCTestCase { XCTAssertEqual(metadata.authors, [PackageCollectionsModel.Package.Author(username: "octocat", url: "https://api.github.com/users/octocat", service: .init(name: "GitHub"))]) - XCTAssertEqual(metadata.readmeURL, "https://raw.githubusercontent.com/octokit/octokit.rb/master/README.md") + XCTAssertEqual(metadata.readmeURL, "https://raw.githubusercontent.com/octokit/octokit.rb/main/README.md") XCTAssertEqual(metadata.license?.type, PackageCollectionsModel.LicenseType.MIT) - XCTAssertEqual(metadata.license?.url, "https://raw.githubusercontent.com/benbalter/gman/master/LICENSE?lab=true") + XCTAssertEqual(metadata.license?.url, "https://raw.githubusercontent.com/benbalter/gman/main/LICENSE?lab=true") XCTAssertEqual(metadata.watchersCount, 80) XCTAssertEqual(metadata.languages, ["Swift", "Shell", "C"]) } diff --git a/Tests/PackageGraphTests/ModulesGraphTests.swift b/Tests/PackageGraphTests/ModulesGraphTests.swift index 1089a3ab30b..ec2e153d31d 100644 --- a/Tests/PackageGraphTests/ModulesGraphTests.swift +++ b/Tests/PackageGraphTests/ModulesGraphTests.swift @@ -1789,7 +1789,7 @@ struct ModulesGraphTests { path: "/Foo", toolsVersion: .v5_2, dependencies: [ - .localSourceControl(path: "/Bar", requirement: .branch("master")), + .localSourceControl(path: "/Bar", requirement: .branch("main")), .localSourceControl(path: "/BizPath", requirement: .exact("1.2.3")), .localSourceControl(path: "/FizPath", requirement: .upToNextMajor(from: "1.1.2")), ], @@ -1872,7 +1872,7 @@ struct ModulesGraphTests { path: "/Foo", toolsVersion: .v5_2, dependencies: [ - .localSourceControl(deprecatedName: "UnBar", path: "/Bar", requirement: .branch("master")), + .localSourceControl(deprecatedName: "UnBar", path: "/Bar", requirement: .branch("main")), ], targets: [ TargetDescription(name: "Foo", dependencies: [.product(name: "BarProduct", package: "UnBar")]), diff --git a/Tests/PackageGraphTests/PubGrubTests.swift b/Tests/PackageGraphTests/PubGrubTests.swift index ba04635930d..7b0c2a13fba 100644 --- a/Tests/PackageGraphTests/PubGrubTests.swift +++ b/Tests/PackageGraphTests/PubGrubTests.swift @@ -837,40 +837,40 @@ final class PubGrubTests: XCTestCase { func testUnversioned4() async throws { try builder.serve("foo", at: .unversioned) - try builder.serve("bar", at: .revision("master"), with: [ + try builder.serve("bar", at: .revision("main"), with: [ "bar": ["foo": (.versionSet(v1Range), .specific(["foo"]))] ]) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ "foo": (.unversioned, .specific(["foo"])), - "bar": (.revision("master"), .specific(["bar"])) + "bar": (.revision("main"), .specific(["bar"])) ]) let result = await resolver.solve(constraints: dependencies) AssertResult(result, [ ("foo", .unversioned), - ("bar", .revision("master")) + ("bar", .revision("main")) ]) } func testUnversioned5() async throws { try builder.serve("foo", at: .unversioned) - try builder.serve("foo", at: .revision("master")) - try builder.serve("bar", at: .revision("master"), with: [ - "bar": ["foo": (.revision("master"), .specific(["foo"]))] + try builder.serve("foo", at: .revision("main")) + try builder.serve("bar", at: .revision("main"), with: [ + "bar": ["foo": (.revision("main"), .specific(["foo"]))] ]) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ "foo": (.unversioned, .specific(["foo"])), - "bar": (.revision("master"), .specific(["bar"])) + "bar": (.revision("main"), .specific(["bar"])) ]) let result = await resolver.solve(constraints: dependencies) AssertResult(result, [ ("foo", .unversioned), - ("bar", .revision("master")) + ("bar", .revision("main")) ]) } @@ -1200,92 +1200,92 @@ final class PubGrubTests: XCTestCase { } func testResolutionWithSimpleBranchBasedDependency() async throws { - try builder.serve("foo", at: .revision("master"), with: ["foo": ["bar": (.versionSet(v1Range), .specific(["bar"]))]]) + try builder.serve("foo", at: .revision("main"), with: ["foo": ["bar": (.versionSet(v1Range), .specific(["bar"]))]]) try builder.serve("bar", at: v1) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ - "foo": (.revision("master"), .specific(["foo"])), + "foo": (.revision("main"), .specific(["foo"])), "bar": (.versionSet(v1Range), .specific(["bar"])) ]) let result = await resolver.solve(constraints: dependencies) AssertResult(result, [ - ("foo", .revision("master")), + ("foo", .revision("main")), ("bar", .version(v1)) ]) } func testResolutionWithSimpleBranchBasedDependency2() async throws { - try builder.serve("foo", at: .revision("master"), with: ["foo": ["bar": (.versionSet(v1Range), .specific(["bar"]))]]) + try builder.serve("foo", at: .revision("main"), with: ["foo": ["bar": (.versionSet(v1Range), .specific(["bar"]))]]) try builder.serve("bar", at: v1) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ - "foo": (.revision("master"), .specific(["foo"])), + "foo": (.revision("main"), .specific(["foo"])), ]) let result = await resolver.solve(constraints: dependencies) AssertResult(result, [ - ("foo", .revision("master")), + ("foo", .revision("main")), ("bar", .version(v1)) ]) } func testResolutionWithOverridingBranchBasedDependency() async throws { - try builder.serve("foo", at: .revision("master")) + try builder.serve("foo", at: .revision("main")) try builder.serve("bar", at: v1, with: ["bar": ["foo": (.versionSet(v1Range), .specific(["foo"]))]]) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ - "foo": (.revision("master"), .specific(["foo"])), + "foo": (.revision("main"), .specific(["foo"])), "bar": (.versionSet(.exact(v1)), .specific(["bar"])), ]) let result = await resolver.solve(constraints: dependencies) AssertResult(result, [ - ("foo", .revision("master")), + ("foo", .revision("main")), ("bar", .version(v1)) ]) } func testResolutionWithOverridingBranchBasedDependency2() async throws { - try builder.serve("foo", at: .revision("master")) + try builder.serve("foo", at: .revision("main")) try builder.serve("bar", at: v1, with: ["bar": ["foo": (.versionSet(v1Range), .specific(["foo"]))]]) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ "bar": (.versionSet(.exact(v1)), .specific(["bar"])), - "foo": (.revision("master"), .specific(["foo"])), + "foo": (.revision("main"), .specific(["foo"])), ]) let result = await resolver.solve(constraints: dependencies) AssertResult(result, [ - ("foo", .revision("master")), + ("foo", .revision("main")), ("bar", .version(v1)) ]) } func testResolutionWithOverridingBranchBasedDependency3() async throws { - try builder.serve("foo", at: .revision("master"), with: ["foo": ["bar": (.revision("master"), .specific(["bar"]))]]) + try builder.serve("foo", at: .revision("main"), with: ["foo": ["bar": (.revision("main"), .specific(["bar"]))]]) - try builder.serve("bar", at: .revision("master")) + try builder.serve("bar", at: .revision("main")) try builder.serve("bar", at: v1) - try builder.serve("baz", at: .revision("master"), with: ["baz": ["bar": (.versionSet(v1Range), .specific(["bar"]))]]) + try builder.serve("baz", at: .revision("main"), with: ["baz": ["bar": (.versionSet(v1Range), .specific(["bar"]))]]) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ - "foo": (.revision("master"), .specific(["foo"])), - "baz": (.revision("master"), .specific(["baz"])), + "foo": (.revision("main"), .specific(["foo"])), + "baz": (.revision("main"), .specific(["baz"])), ]) let result = await resolver.solve(constraints: dependencies) AssertResult(result, [ - ("foo", .revision("master")), - ("bar", .revision("master")), - ("baz", .revision("master")), + ("foo", .revision("main")), + ("bar", .revision("main")), + ("baz", .revision("main")), ]) } @@ -1294,7 +1294,7 @@ final class PubGrubTests: XCTestCase { let resolver = builder.create() let dependencies = try builder.create(dependencies: [ - "foo": (.revision("master"), .specific(["foo"])) + "foo": (.revision("main"), .specific(["foo"])) ]) let result = await resolver.solve(constraints: dependencies) @@ -1302,27 +1302,27 @@ final class PubGrubTests: XCTestCase { } func testResolutionWithRevisionConflict() async throws { - try builder.serve("foo", at: .revision("master"), with: ["foo": ["bar": (.revision("master"), .specific(["bar"]))]]) + try builder.serve("foo", at: .revision("main"), with: ["foo": ["bar": (.revision("main"), .specific(["bar"]))]]) try builder.serve("bar", at: .version(v1)) - try builder.serve("bar", at: .revision("master")) + try builder.serve("bar", at: .revision("main")) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ "bar": (.versionSet(v1Range), .specific(["bar"])), - "foo": (.revision("master"), .specific(["foo"])), + "foo": (.revision("main"), .specific(["foo"])), ]) let result = await resolver.solve(constraints: dependencies) AssertResult(result, [ - ("foo", .revision("master")), - ("bar", .revision("master")), + ("foo", .revision("main")), + ("bar", .revision("main")), ]) } func testBranchOverriding3() async throws { try builder.serve("swift-nio", at: v1) - try builder.serve("swift-nio", at: .revision("master")) - try builder.serve("swift-nio-ssl", at: .revision("master"), with: [ + try builder.serve("swift-nio", at: .revision("main")) + try builder.serve("swift-nio-ssl", at: .revision("main"), with: [ "swift-nio-ssl": ["swift-nio": (.versionSet(v2Range), .specific(["swift-nio"]))], ]) try builder.serve("foo", at: "1.0.0", with: [ @@ -1332,28 +1332,28 @@ final class PubGrubTests: XCTestCase { let resolver = builder.create() let dependencies = try builder.create(dependencies: [ "foo": (.versionSet(v1Range), .specific(["foo"])), - "swift-nio": (.revision("master"), .specific(["swift-nio"])), - "swift-nio-ssl": (.revision("master"), .specific(["swift-nio-ssl"])), + "swift-nio": (.revision("main"), .specific(["swift-nio"])), + "swift-nio-ssl": (.revision("main"), .specific(["swift-nio-ssl"])), ]) let result = await resolver.solve(constraints: dependencies) AssertResult(result, [ - ("swift-nio-ssl", .revision("master")), - ("swift-nio", .revision("master")), + ("swift-nio-ssl", .revision("main")), + ("swift-nio", .revision("main")), ("foo", .version(v1)) ]) } func testBranchOverriding4() async throws { try builder.serve("swift-nio", at: v1) - try builder.serve("swift-nio", at: .revision("master")) - try builder.serve("swift-nio-ssl", at: .revision("master"), with: [ + try builder.serve("swift-nio", at: .revision("main")) + try builder.serve("swift-nio-ssl", at: .revision("main"), with: [ "swift-nio-ssl": ["swift-nio": (.versionSet(v2Range), .specific(["swift-nio"]))], ]) - try builder.serve("nio-postgres", at: .revision("master"), with: [ + try builder.serve("nio-postgres", at: .revision("main"), with: [ "nio-postgres": [ - "swift-nio": (.revision("master"), .specific(["swift-nio"])), - "swift-nio-ssl": (.revision("master"), .specific(["swift-nio-ssl"])), + "swift-nio": (.revision("main"), .specific(["swift-nio"])), + "swift-nio-ssl": (.revision("main"), .specific(["swift-nio-ssl"])), ] ]) try builder.serve("http-client", at: v1, with: [ @@ -1368,16 +1368,16 @@ final class PubGrubTests: XCTestCase { let resolver = builder.create() let dependencies = try builder.create(dependencies: [ - "nio-postgres": (.revision("master"), .specific(["nio-postgres"])), + "nio-postgres": (.revision("main"), .specific(["nio-postgres"])), "http-client": (.versionSet(v1Range), .specific(["https-client"])), "boring-ssl": (.versionSet(v1Range), .specific(["boring-ssl"])), ]) let result = await resolver.solve(constraints: dependencies) AssertResult(result, [ - ("swift-nio-ssl", .revision("master")), - ("swift-nio", .revision("master")), - ("nio-postgres", .revision("master")), + ("swift-nio-ssl", .revision("main")), + ("swift-nio", .revision("main")), + ("nio-postgres", .revision("main")), ("http-client", .version(v1)), ("boring-ssl", .version(v1)), ]) @@ -1385,7 +1385,7 @@ final class PubGrubTests: XCTestCase { func testNonVersionDependencyInVersionDependency2() async throws { try builder.serve("foo", at: v1_1, with: [ - "foo": ["bar": (.revision("master"), .specific(["bar"]))] + "foo": ["bar": (.revision("main"), .specific(["bar"]))] ]) try builder.serve("foo", at: v1) let resolver = builder.create() @@ -1491,16 +1491,16 @@ final class PubGrubTests: XCTestCase { // This test ensures that we get the SHA listed in Package.resolved for branch-based // dependencies. try builder.serve("a", at: .revision("develop-sha-1")) - try builder.serve("b", at: .revision("master-sha-2")) + try builder.serve("b", at: .revision("main-sha-2")) let dependencies = try builder.create(dependencies: [ "a": (.revision("develop"), .specific(["a"])), - "b": (.revision("master"), .specific(["b"])), + "b": (.revision("main"), .specific(["b"])), ]) let resolvedPackagesStore = try builder.create(resolvedPackages: [ "a": (.branch(name: "develop", revision: "develop-sha-1"), .specific(["a"])), - "b": (.branch(name: "master", revision: "master-sha-2"), .specific(["b"])), + "b": (.branch(name: "main", revision: "main-sha-2"), .specific(["b"])), ]) let resolver = builder.create(resolvedPackages: resolvedPackagesStore.resolvedPackages) @@ -1508,7 +1508,7 @@ final class PubGrubTests: XCTestCase { AssertResult(result, [ ("a", .revision("develop-sha-1", branch: "develop")), - ("b", .revision("master-sha-2", branch: "master")), + ("b", .revision("main-sha-2", branch: "main")), ]) } @@ -2420,14 +2420,14 @@ final class PubGrubDiagnosticsTests: XCTestCase { func testUnversioned6() async throws { try builder.serve("foo", at: .unversioned) - try builder.serve("bar", at: .revision("master"), with: [ + try builder.serve("bar", at: .revision("main"), with: [ "bar": ["foo": (.unversioned, .specific(["foo"]))] ]) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ - "bar": (.revision("master"), .specific(["bar"])) + "bar": (.revision("main"), .specific(["bar"])) ]) let result = await resolver.solve(constraints: dependencies) @@ -2435,28 +2435,28 @@ final class PubGrubDiagnosticsTests: XCTestCase { } func testResolutionWithOverridingBranchBasedDependency4() async throws { - try builder.serve("foo", at: .revision("master"), with: ["foo": ["bar": (.revision("master"), .specific(["bar"]))]]) + try builder.serve("foo", at: .revision("main"), with: ["foo": ["bar": (.revision("main"), .specific(["bar"]))]]) - try builder.serve("bar", at: .revision("master")) + try builder.serve("bar", at: .revision("main")) try builder.serve("bar", at: v1) - try builder.serve("baz", at: .revision("master"), with: ["baz": ["bar": (.revision("develop"), .specific(["baz"]))]]) + try builder.serve("baz", at: .revision("main"), with: ["baz": ["bar": (.revision("develop"), .specific(["baz"]))]]) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ - "foo": (.revision("master"), .specific(["foo"])), - "baz": (.revision("master"), .specific(["baz"])), + "foo": (.revision("main"), .specific(["foo"])), + "baz": (.revision("main"), .specific(["baz"])), ]) let result = await resolver.solve(constraints: dependencies) - XCTAssertEqual(result.errorMsg, "bar is required using two different revision-based requirements (master and develop), which is not supported") + XCTAssertEqual(result.errorMsg, "bar is required using two different revision-based requirements (main and develop), which is not supported") } func testNonVersionDependencyInVersionDependency1() async throws { try builder.serve("foo", at: v1_1, with: [ - "foo": ["bar": (.revision("master"), .specific(["bar"]))] + "foo": ["bar": (.revision("main"), .specific(["bar"]))] ]) - try builder.serve("bar", at: .revision("master")) + try builder.serve("bar", at: .revision("main")) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ @@ -2489,15 +2489,15 @@ final class PubGrubDiagnosticsTests: XCTestCase { func testNonVersionDependencyInVersionDependency3() async throws { try builder.serve("foo", at: "1.0.0-beta.1", with: [ - "foo": ["bar": (.revision("master"), .specific(["bar"]))] + "foo": ["bar": (.revision("main"), .specific(["bar"]))] ]) try builder.serve("foo", at: "1.0.0-beta.2", with: [ - "foo": ["bar": (.revision("master"), .specific(["bar"]))] + "foo": ["bar": (.revision("main"), .specific(["bar"]))] ]) try builder.serve("foo", at: "1.0.0-beta.3", with: [ - "foo": ["bar": (.revision("master"), .specific(["bar"]))] + "foo": ["bar": (.revision("main"), .specific(["bar"]))] ]) - try builder.serve("bar", at: .revision("master")) + try builder.serve("bar", at: .revision("main")) let resolver = builder.create() let dependencies = try builder.create(dependencies: [ diff --git a/Tests/PackageLoadingTests/Inputs/package-deps-manifest.swift b/Tests/PackageLoadingTests/Inputs/package-deps-manifest.swift index d671cb28fe0..571b79bd669 100644 --- a/Tests/PackageLoadingTests/Inputs/package-deps-manifest.swift +++ b/Tests/PackageLoadingTests/Inputs/package-deps-manifest.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2016 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import PackageDescription let package = Package( diff --git a/Tests/PackageLoadingTests/Inputs/target-deps-manifest.swift b/Tests/PackageLoadingTests/Inputs/target-deps-manifest.swift index d7a1bcbb198..7c486942468 100644 --- a/Tests/PackageLoadingTests/Inputs/target-deps-manifest.swift +++ b/Tests/PackageLoadingTests/Inputs/target-deps-manifest.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2016 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import PackageDescription let package = Package( diff --git a/Tests/PackageLoadingTests/Inputs/trivial-manifest.swift b/Tests/PackageLoadingTests/Inputs/trivial-manifest.swift index 5ff29c04e54..79d6e6a7775 100644 --- a/Tests/PackageLoadingTests/Inputs/trivial-manifest.swift +++ b/Tests/PackageLoadingTests/Inputs/trivial-manifest.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2016 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import PackageDescription let package = Package(name: "Trivial") diff --git a/Tests/PackageLoadingTests/PDAppleProductLoadingTests.swift b/Tests/PackageLoadingTests/PDAppleProductLoadingTests.swift index 2bd05cfbb1c..083e3239b2c 100644 --- a/Tests/PackageLoadingTests/PDAppleProductLoadingTests.swift +++ b/Tests/PackageLoadingTests/PDAppleProductLoadingTests.swift @@ -1,12 +1,14 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2021 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors -*/ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import XCTest diff --git a/Tests/PackageLoadingTests/PD_4_0_LoadingTests.swift b/Tests/PackageLoadingTests/PD_4_0_LoadingTests.swift index b3a50c22c7c..fd29edf26cc 100644 --- a/Tests/PackageLoadingTests/PD_4_0_LoadingTests.swift +++ b/Tests/PackageLoadingTests/PD_4_0_LoadingTests.swift @@ -295,7 +295,7 @@ final class PackageDescription4_0LoadingTests: PackageDescriptionLoadingTests { name: "Foo", dependencies: [ .package(url: "/foo1", version: "1.0.0"), - .package(url: "/foo2", branch: "master"), + .package(url: "/foo2", branch: "main"), .package(url: "/foo3", revision: "rev"), .package(url: "/foo4", range: "1.0.0"..<"1.5.0"), ] diff --git a/Tests/PackageLoadingTests/PD_4_2_LoadingTests.swift b/Tests/PackageLoadingTests/PD_4_2_LoadingTests.swift index 1059a81d4a3..2f54e2a14de 100644 --- a/Tests/PackageLoadingTests/PD_4_2_LoadingTests.swift +++ b/Tests/PackageLoadingTests/PD_4_2_LoadingTests.swift @@ -258,7 +258,7 @@ final class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests { .package(path: "\(AbsolutePath("/path/to/foo4").escapedPathString)"), .package(url: "\(AbsolutePath("/foo5").escapedPathString)", .exact("1.2.3")), .package(url: "\(AbsolutePath("/foo6").escapedPathString)", "1.2.3"..<"2.0.0"), - .package(url: "\(AbsolutePath("/foo7").escapedPathString)", .branch("master")), + .package(url: "\(AbsolutePath("/foo7").escapedPathString)", .branch("main")), .package(url: "\(AbsolutePath("/foo8").escapedPathString)", .upToNextMinor(from: "1.3.4")), .package(url: "\(AbsolutePath("/foo9").escapedPathString)", .upToNextMajor(from: "1.3.4")), .package(path: "~/path/to/foo10"), @@ -293,7 +293,7 @@ final class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests { XCTAssertEqual(deps["foo5"], .localSourceControl(path: "/foo5", requirement: .exact("1.2.3"))) XCTAssertEqual(deps["foo6"], .localSourceControl(path: "/foo6", requirement: .range("1.2.3"..<"2.0.0"))) - XCTAssertEqual(deps["foo7"], .localSourceControl(path: "/foo7", requirement: .branch("master"))) + XCTAssertEqual(deps["foo7"], .localSourceControl(path: "/foo7", requirement: .branch("main"))) XCTAssertEqual(deps["foo8"], .localSourceControl(path: "/foo8", requirement: .upToNextMinor(from: "1.3.4"))) XCTAssertEqual(deps["foo9"], .localSourceControl(path: "/foo9", requirement: .upToNextMajor(from: "1.3.4"))) diff --git a/Tests/PackageLoadingTests/PackageBuilderTests.swift b/Tests/PackageLoadingTests/PackageBuilderTests.swift index 0dd27697125..3d577aaa805 100644 --- a/Tests/PackageLoadingTests/PackageBuilderTests.swift +++ b/Tests/PackageLoadingTests/PackageBuilderTests.swift @@ -1077,7 +1077,7 @@ struct PackageBuilderTests { try TargetDescription(name: "Random"), ] ) - + try PackageBuilderTester(manifest, in: fs) { package, diagnostics in try package.checkModule("Random") { result in #expect("/\(predefinedSourceDir)" == result.target.path) @@ -1177,7 +1177,7 @@ struct PackageBuilderTests { try TargetDescription(name: "MyTests", type: .test), ] ) - + try PackageBuilderTester(manifest, in: fs) { package, diagnostics in try package.checkModule("MyTests") { result in #expect("/\(predefinedSourceDir)" == result.target.path) @@ -1280,7 +1280,7 @@ struct PackageBuilderTests { try TargetDescription(name: "MyPlugin", type: .plugin, pluginCapability: .buildTool), ] ) - + try PackageBuilderTester(manifest, in: fs) { package, diagnostics in try package.checkModule("MyPlugin") { result in result.checkSources(root: result.target.path.appending(component: predefinedSourceDir).pathString, paths: "Foo.swift") @@ -2838,19 +2838,19 @@ struct PackageBuilderTests { // invalid - same target in package "Bar" "Bar", "Bar", - + // invalid - same target in package "Bar" "Bar2", .product(name: "Bar2", package: "Bar"), - + // invalid - same target in this package "Foo2", "Foo2", - + // invalid - same target in this package "Foo3", .target(name: "Foo3"), - + // valid - different packages "Qux", .product(name: "Qux", package: "Bar") @@ -2979,7 +2979,7 @@ struct PackageBuilderTests { func testXcodeResources5_4AndEarlier() throws { // In SwiftTools 5.4 and earlier, supported xcbuild file types are supported by default. // Of course, modern file types such as xcstrings won't be supported here because those require a newer Swift tools version in general. - + let root: AbsolutePath = "/Foo" let foo = root.appending(components: "Sources", "Foo") @@ -3011,11 +3011,11 @@ struct PackageBuilderTests { } } } - + @Test func testXcodeResources5_5AndLater() throws { // In SwiftTools 5.5 and later, xcbuild file types are only supported when explicitly passed via additionalFileRules. - + let root: AbsolutePath = "/Foo" let foo = root.appending(components: "Sources", "Foo") @@ -3140,7 +3140,7 @@ struct PackageBuilderTests { internalSourcesDir.appending("Internal.swift").pathString, productSourcesDir.appending("Product.swift").pathString, snippetsDir.appending("ASnippet.swift").pathString) - + let manifest = Manifest.createRootManifest( displayName: "Foo", toolsVersion: .v5_7, products: [ @@ -3150,7 +3150,7 @@ struct PackageBuilderTests { try TargetDescription(name: "Internal"), try TargetDescription(name: "Product"), ]) - + try PackageBuilderTester(manifest, path: root, in: fs) { result, diagnostics in result.checkProduct("Product") { product in product.check(type: .library(.automatic), targets: ["Product"]) @@ -3315,7 +3315,7 @@ struct PackageBuilderTests { } } } - + @Test func testCWarningControlFlags() throws { let fs = InMemoryFileSystem(emptyFiles: diff --git a/Tests/PackageLoadingTests/ToolsVersionParserTests.swift b/Tests/PackageLoadingTests/ToolsVersionParserTests.swift index c7c6b05778d..cc3ac47cbd4 100644 --- a/Tests/PackageLoadingTests/ToolsVersionParserTests.swift +++ b/Tests/PackageLoadingTests/ToolsVersionParserTests.swift @@ -349,7 +349,7 @@ final class ToolsVersionParserTests: XCTestCase { "/// We are the knights who say 'Ni!'", // Missing version specifiers are diagnosed before backward-compatibility checks. "\r\n//\tswift-tools-version:", - "\n\r///The swifts hung in the sky in much the same way that bricks don't.\u{85}", + "\n\r///The swifts hovered in the sky in much the same way that bricks don't.\u{85}", ] for manifestSnippet in manifestSnippetsWithoutVersionSpecifier { diff --git a/Tests/PackageModelTests/EnabledTraitTests.swift b/Tests/PackageModelTests/EnabledTraitTests.swift index 35b8a5fc7f7..9eb63f1897b 100644 --- a/Tests/PackageModelTests/EnabledTraitTests.swift +++ b/Tests/PackageModelTests/EnabledTraitTests.swift @@ -1,12 +1,12 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift.org open source project +// This source file is part of the Swift open source project // // Copyright (c) 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// @@ -373,7 +373,7 @@ struct EnabledTraitTests { let enabledTraits: EnabledTraits = ["Apple", "Banana", "Orange"] var otherEnabledTraits: EnabledTraits = ["Banana", "Chocolate"] #expect(enabledTraits != otherEnabledTraits) - + let intersection = enabledTraits.intersection(otherEnabledTraits) #expect(intersection.count == 1) #expect(intersection.contains("Banana")) diff --git a/Tests/QueryEngineTests/QueryEngineTests.swift b/Tests/QueryEngineTests/QueryEngineTests.swift index 01c258e8168..6e9d9d2ad7f 100644 --- a/Tests/QueryEngineTests/QueryEngineTests.swift +++ b/Tests/QueryEngineTests/QueryEngineTests.swift @@ -5,8 +5,8 @@ // Copyright (c) 2023 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// import Foundation diff --git a/Tests/SPMBuildCoreTests/MainAttrDetectionTests.swift b/Tests/SPMBuildCoreTests/MainAttrDetectionTests.swift index c7e3cdba562..9eee5216651 100644 --- a/Tests/SPMBuildCoreTests/MainAttrDetectionTests.swift +++ b/Tests/SPMBuildCoreTests/MainAttrDetectionTests.swift @@ -1,3 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// import Basics import SPMBuildCore import Testing diff --git a/Tests/SourceControlTests/GitRepositoryTests.swift b/Tests/SourceControlTests/GitRepositoryTests.swift index b9ee3871aaf..53ebb0dccf3 100644 --- a/Tests/SourceControlTests/GitRepositoryTests.swift +++ b/Tests/SourceControlTests/GitRepositoryTests.swift @@ -63,7 +63,7 @@ class GitRepositoryTests: XCTestCase { /// Test the basic provider functions. func testProvider() async throws { // Skipping all tests that call git on Windows. - // We have a hang in CI when running in parallel. + // We have a test stall in CI when running in parallel. try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8564", skipSelfHostedCI: true) try await testWithTemporaryDirectory { path in let testRepoPath = path.appending("test-repo") @@ -145,8 +145,10 @@ class GitRepositoryTests: XCTestCase { // Check hash resolution. let repo = GitRepository(path: testRepoPath) - XCTAssertEqual(try repo.resolveHash(treeish: "1.0", type: "commit"), - try repo.resolveHash(treeish: "master")) + XCTAssertEqual( + try repo.resolveHash(treeish: "1.0", type: "commit"), + try repo.resolveHash(treeish: "main"), + ) // Get the initial commit. let initialCommitHash = try repo.resolveHash(treeish: "a8b9fcb") diff --git a/Tests/SourceControlTests/Inputs/TestRepo.tgz b/Tests/SourceControlTests/Inputs/TestRepo.tgz index 791138453fa..cc17517df2c 100644 Binary files a/Tests/SourceControlTests/Inputs/TestRepo.tgz and b/Tests/SourceControlTests/Inputs/TestRepo.tgz differ diff --git a/Tests/SwiftBuildSupportTests/PIFBuilderTests.swift b/Tests/SwiftBuildSupportTests/PIFBuilderTests.swift index 80f00260ee5..4d71bb2c88a 100644 --- a/Tests/SwiftBuildSupportTests/PIFBuilderTests.swift +++ b/Tests/SwiftBuildSupportTests/PIFBuilderTests.swift @@ -43,13 +43,24 @@ extension PIFBuilderParameters { } } -fileprivate func withGeneratedPIF(fromFixture fixtureName: String, addLocalRpaths: Bool = true, do doIt: (SwiftBuildSupport.PIF.TopLevelObject, TestingObservability) async throws -> ()) async throws { +fileprivate func withGeneratedPIF( + fromFixture fixtureName: String, + addLocalRpaths: Bool = true, + buildParameters: BuildParameters? = nil, + do doIt: (SwiftBuildSupport.PIF.TopLevelObject, TestingObservability) async throws -> (), +) async throws { + let buildParameters = if let buildParameters { + buildParameters + } else { + mockBuildParameters(destination: .host) + } try await fixture(name: fixtureName) { fixturePath in - let observabilitySystem = ObservabilitySystem.makeForTesting() + let observabilitySystem: TestingObservability = ObservabilitySystem.makeForTesting() + let toolchain = try UserToolchain.default let workspace = try Workspace( fileSystem: localFileSystem, forRootPackage: fixturePath, - customManifestLoader: ManifestLoader(toolchain: UserToolchain.default), + customManifestLoader: ManifestLoader(toolchain: toolchain), delegate: MockWorkspaceDelegate() ) let rootInput = PackageGraphRootInput(packages: [fixturePath], dependencies: []) @@ -64,7 +75,7 @@ fileprivate func withGeneratedPIF(fromFixture fixtureName: String, addLocalRpath observabilityScope: observabilitySystem.topScope ) let pif = try await builder.constructPIF( - buildParameters: mockBuildParameters(destination: .host) + buildParameters: buildParameters, ) try await doIt(pif, observabilitySystem) } @@ -119,9 +130,9 @@ extension SwiftBuildSupport.PIF.Project { } } - fileprivate func buildConfig(named name: String) throws -> SwiftBuild.ProjectModel.BuildConfig { + fileprivate func buildConfig(named name: BuildConfiguration) throws -> SwiftBuild.ProjectModel.BuildConfig { let matchingConfigs = underlying.buildConfigs.filter { - $0.name == name + $0.name == name.pifConfiguration } if matchingConfigs.isEmpty { throw StringError("No config named \(name) in PIF project") @@ -134,9 +145,9 @@ extension SwiftBuildSupport.PIF.Project { } extension SwiftBuild.ProjectModel.BaseTarget { - fileprivate func buildConfig(named name: String) throws -> SwiftBuild.ProjectModel.BuildConfig { + fileprivate func buildConfig(named name: BuildConfiguration) throws -> SwiftBuild.ProjectModel.BuildConfig { let matchingConfigs = common.buildConfigs.filter { - $0.name == name + $0.name == name.pifConfiguration } if matchingConfigs.isEmpty { throw StringError("No config named \(name) in PIF target") @@ -148,8 +159,41 @@ extension SwiftBuild.ProjectModel.BaseTarget { } } -@Suite +extension BuildConfiguration { + var pifConfiguration: String { + switch self { + case .debug, .release: self.rawValue.capitalized + } + } +} + +@Suite( + .tags( + .TestSize.medium, + .FunctionalArea.PIF, + ), +) struct PIFBuilderTests { + + @Test func platformExecutableModuleLibrarySearchPath() async throws { + try await withGeneratedPIF(fromFixture: "PIFBuilder/BasicExecutable") { pif, observabilitySystem in + let releaseConfig = try pif.workspace + .project(named: "BasicExecutable") + .target(named: "Executable") + .buildConfig(named: .release) + + for platform in ProjectModel.BuildSettings.Platform.allCases { + let search_paths = releaseConfig.impartedBuildProperties.settings[.LIBRARY_SEARCH_PATHS, platform] + switch platform { + case .macOS, .macCatalyst, .iOS, .watchOS, .tvOS, .xrOS, .driverKit, .freebsd, .android, .linux, .wasi, .openbsd, ._iOSDevice: + #expect(search_paths == nil, "for platform \(platform)") + case .windows: + #expect(search_paths == ["$(inherited)", "$(TARGET_BUILD_DIR)/ExecutableModules"], "for platform \(platform)") + } + } + } + } + @Test func platformConditionBasics() async throws { try await withGeneratedPIF(fromFixture: "PIFBuilder/UnknownPlatforms") { pif, observabilitySystem in // We should emit a warning to the PIF log about the unknown platform @@ -160,7 +204,7 @@ struct PIFBuilderTests { let releaseConfig = try pif.workspace .project(named: "UnknownPlatforms") .target(named: "UnknownPlatforms") - .buildConfig(named: "Release") + .buildConfig(named: .release) // The platforms with conditional settings should have those propagated to the PIF. #expect(releaseConfig.settings[.SWIFT_ACTIVE_COMPILATION_CONDITIONS, .linux] == ["$(inherited)", "BAR"]) @@ -174,7 +218,7 @@ struct PIFBuilderTests { let releaseConfig = try pif.workspace .project(named: "CCPackage") .target(id: "PACKAGE-TARGET:CCTarget") - .buildConfig(named: "Release") + .buildConfig(named: .release) for platform in ProjectModel.BuildSettings.Platform.allCases { let ld_flags = releaseConfig.impartedBuildProperties.settings[.OTHER_LDFLAGS, platform] @@ -182,7 +226,7 @@ struct PIFBuilderTests { case .macOS, .macCatalyst, .iOS, .watchOS, .tvOS, .xrOS, .driverKit, .freebsd: #expect(ld_flags == ["-lc++", "$(inherited)"], "for platform \(platform)") case .android, .linux, .wasi, .openbsd: - #expect(ld_flags == ["-lstdc++", "$(inherited)"], "for platform \(platform)") + #expect(ld_flags == ["-lstdc++", "$(inherited)"], "for platform \(platform)") case .windows, ._iOSDevice: #expect(ld_flags == nil, "for platform \(platform)") } @@ -192,12 +236,12 @@ struct PIFBuilderTests { @Test func packageWithInternal() async throws { try await withGeneratedPIF(fromFixture: "PIFBuilder/PackageWithSDKSpecialization") { pif, observabilitySystem in - let errors = observabilitySystem.diagnostics.filter { $0.severity == .error } + let errors: [Diagnostic] = observabilitySystem.diagnostics.filter { $0.severity == .error } #expect(errors.isEmpty, "Expected no errors during PIF generation, but got: \(errors)") let releaseConfig = try pif.workspace .project(named: "PackageWithSDKSpecialization") - .buildConfig(named: "Release") + .buildConfig(named: .release) #expect(releaseConfig.settings[.SPECIALIZATION_SDK_OPTIONS, .macOS] == ["foo"]) } @@ -231,6 +275,55 @@ struct PIFBuilderTests { } } + @Test( + arguments: BuildConfiguration.allCases, + ) + func executablePrefixIsSetCorrectly( + configuration: BuildConfiguration, + ) async throws { + try await withGeneratedPIF(fromFixture: "PIFBuilder/Library") { pif, observabilitySystem in + let errors: [Diagnostic] = observabilitySystem.diagnostics.filter { $0.severity == .error } + #expect(errors.isEmpty, "Expected no errors during PIF generation, but got: \(errors)") + + struct ExpectedValue { + let targetName: String + let expectedValue: String? + let expectedValueForWindows: String? + } + let targetsUnderTest = [ + ExpectedValue( + targetName: "LibraryDynamic-product", + expectedValue: "lib", + expectedValueForWindows: "", + ), + ExpectedValue( + targetName: "LibraryStatic-product", + expectedValue: nil, + expectedValueForWindows: nil, + ), + ExpectedValue( + targetName: "LibraryAuto-product", + expectedValue: nil, + expectedValueForWindows: nil, + ), + ] + for targetUnderTest in targetsUnderTest { + let projectConfig = try pif.workspace + .project(named: "Library") + .target(named: targetUnderTest.targetName) + .buildConfig(named: configuration) + + let actualValue = projectConfig.settings[.EXECUTABLE_PREFIX] + let actualValueForWindows = projectConfig.settings[.EXECUTABLE_PREFIX, .windows] + #expect(actualValue == targetUnderTest.expectedValue) + #expect(actualValueForWindows == targetUnderTest.expectedValueForWindows) + + } + } + } + + + @Test func impartedModuleMaps() async throws { try await withGeneratedPIF(fromFixture: "CFamilyTargets/ModuleMapGenerationCases") { pif, observabilitySystem in #expect(observabilitySystem.diagnostics.filter { @@ -241,7 +334,7 @@ struct PIFBuilderTests { let releaseConfig = try pif.workspace .project(named: "ModuleMapGenerationCases") .target(named: "UmbrellaHeader") - .buildConfig(named: "Release") + .buildConfig(named: .release) #expect(releaseConfig.impartedBuildProperties.settings[.OTHER_CFLAGS] == ["-fmodule-map-file=\(RelativePath("$(GENERATED_MODULEMAP_DIR)").appending(component: "UmbrellaHeader.modulemap").pathString)", "$(inherited)"]) } @@ -250,7 +343,7 @@ struct PIFBuilderTests { let releaseConfig = try pif.workspace .project(named: "ModuleMapGenerationCases") .target(named: "UmbrellaDirectoryInclude") - .buildConfig(named: "Release") + .buildConfig(named: .release) #expect(releaseConfig.impartedBuildProperties.settings[.OTHER_CFLAGS] == ["-fmodule-map-file=\(RelativePath("$(GENERATED_MODULEMAP_DIR)").appending(component: "UmbrellaDirectoryInclude.modulemap").pathString)", "$(inherited)"]) } @@ -259,7 +352,7 @@ struct PIFBuilderTests { let releaseConfig = try pif.workspace .project(named: "ModuleMapGenerationCases") .target(named: "CustomModuleMap") - .buildConfig(named: "Release") + .buildConfig(named: .release) let arg = try #require(releaseConfig.impartedBuildProperties.settings[.OTHER_CFLAGS]?.first) #expect(arg.hasPrefix("-fmodule-map-file") && arg.hasSuffix(RelativePath("CustomModuleMap").appending(components: ["include", "module.modulemap"]).pathString)) } @@ -276,7 +369,7 @@ struct PIFBuilderTests { let releaseConfig = try pif.workspace .project(named: "Foo") .target(named: "Foo") - .buildConfig(named: "Release") + .buildConfig(named: .release) #expect(releaseConfig.impartedBuildProperties.settings[.LD_RUNPATH_SEARCH_PATHS] == ["$(RPATH_ORIGIN)", "$(inherited)"]) } @@ -291,10 +384,63 @@ struct PIFBuilderTests { let releaseConfig = try pif.workspace .project(named: "Foo") .target(named: "Foo") - .buildConfig(named: "Release") + .buildConfig(named: .release) #expect(releaseConfig.impartedBuildProperties.settings[.LD_RUNPATH_SEARCH_PATHS] == nil) } } } + + @Suite( + .tags( + .FunctionalArea.IndexMode, + ), + ) + struct IndexModeSettingTests { + + @Test( + arguments: [BuildParameters.IndexStoreMode.auto], [BuildConfiguration.debug], + // arguments: BuildParameters.IndexStoreMode.allCases, BuildConfiguration.allCases, + ) + func indexModeSettingSetTo( + indexStoreSettingUT: BuildParameters.IndexStoreMode, + configuration: BuildConfiguration, + ) async throws { + try await withGeneratedPIF( + fromFixture: "PIFBuilder/Simple", + buildParameters: mockBuildParameters(destination: .host, indexStoreMode: indexStoreSettingUT), + ) { pif, observabilitySystem in + // #expect(false, "fail purposefully...") + #expect(observabilitySystem.diagnostics.filter { + $0.severity == .error + }.isEmpty) + + let targetConfig = try pif.workspace + .project(named: "Simple") + // .target(named: "Simple") + .buildConfig(named: configuration) + switch indexStoreSettingUT { + case .on, .off: + #expect(targetConfig.settings[.SWIFT_INDEX_STORE_ENABLE] == nil) + case .auto: + let expectedSwiftIndexStoreEnableValue: String? = switch configuration { + case .debug: "YES" + case .release: nil + } + #expect(targetConfig.settings[.SWIFT_INDEX_STORE_ENABLE] == expectedSwiftIndexStoreEnableValue) + } + + let testTargetConfig = try pif.workspace + .project(named: "Simple") + .target(named: "SimplePackageTests-product") + .buildConfig(named: configuration) + switch indexStoreSettingUT { + case .on, .off: + #expect(testTargetConfig.settings[.SWIFT_INDEX_STORE_ENABLE] == nil) + case .auto: + #expect(testTargetConfig.settings[.SWIFT_INDEX_STORE_ENABLE] == "YES") + } + } + } + } } diff --git a/Tests/SwiftBuildSupportTests/SwiftBuildSystemTests.swift b/Tests/SwiftBuildSupportTests/SwiftBuildSystemTests.swift new file mode 100644 index 00000000000..161c94eec1a --- /dev/null +++ b/Tests/SwiftBuildSupportTests/SwiftBuildSystemTests.swift @@ -0,0 +1,238 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import Testing + +@testable import SwiftBuildSupport +import SPMBuildCore + + +import var TSCBasic.stderrStream +import Basics +import Workspace +import PackageModel +import PackageGraph +import PackageLoading + +@testable import SwiftBuild +import SWBBuildService + +import _InternalTestSupport + +func withInstantiatedSwiftBuildSystem( + fromFixture fixtureName: String, + buildParameters: BuildParameters? = nil, + logLevel: Basics.Diagnostic.Severity = .warning, + do doIt: @escaping (SwiftBuildSupport.SwiftBuildSystem, SWBBuildServiceSession, TestingObservability, BuildParameters,) async throws -> (), +) async throws { + let fileSystem = Basics.localFileSystem + + try await fixture(name: fixtureName) { fixturePath in + try await withTemporaryDirectory { tmpDir in + let buildParameters = if let buildParameters { + buildParameters + } else { + mockBuildParameters(destination: .host) + } + let observabilitySystem: TestingObservability = ObservabilitySystem.makeForTesting() + let toolchain = try UserToolchain.default + let workspace = try Workspace( + fileSystem: localFileSystem, + forRootPackage: fixturePath, + customManifestLoader: ManifestLoader(toolchain: toolchain), + ) + let rootInput = PackageGraphRootInput(packages: [fixturePath], dependencies: []) + let graphLoader = { + try await workspace.loadPackageGraph( + rootInput: rootInput, + observabilityScope: observabilitySystem.topScope + ) + } + + let pluginScriptRunner = try DefaultPluginScriptRunner( + fileSystem: fileSystem, + cacheDir: tmpDir.appending("plugin-script-cache"), + toolchain: UserToolchain.default, + ) + + let swBuild = try SwiftBuildSystem( + buildParameters: buildParameters, + packageGraphLoader: graphLoader, + packageManagerResourcesDirectory: nil, + additionalFileRules: [], + outputStream: TSCBasic.stderrStream, + logLevel: logLevel, + fileSystem: fileSystem, + observabilityScope: observabilitySystem.topScope, + pluginConfiguration: PluginConfiguration( + scriptRunner: pluginScriptRunner, + workDirectory: AbsolutePath("/tmp/plugin-script-working-dir"), + disableSandbox: true, + ), + delegate: nil, + ) + + try await SwiftBuildSupport.withService( + connectionMode: .inProcessStatic(swiftbuildServiceEntryPoint), + ) { service in + + let result = await service.createSession( + name: "session", + cachePath: nil, + inferiorProductsPath: nil, + environment: nil, + ) + + let buildSession: SWBBuildServiceSession + switch result { + case (.success(let session), _): + buildSession = session + case (.failure(let error), _): + throw StringError("\(error)") + // throw SessionFailedError(error: error, diagnostics: diagnostics) + } + + do { + try await doIt(swBuild, buildSession, observabilitySystem, buildParameters) + try await buildSession.close() + } catch { + try await buildSession.close() + throw error + } + } + } + } +} + +extension PackageModel.Sanitizer { + var hasSwiftBuildSupport: Bool { + switch self { + case .address, .thread, .undefined: true + case .fuzzer, .scudo: false + } + } + + var swiftBuildSettingName: String? { + switch self { + case .address: "ENABLE_ADDRESS_SANITIZER" + case .thread: "ENABLE_THREAD_SANITIZER" + case .undefined: "ENABLE_UNDEFINED_BEHAVIOR_SANITIZER" + case .fuzzer, .scudo: nil + } + + } +} + +@Suite( + .tags( + .TestSize.medium, + ), +) +struct SwiftBuildSystemTests { + + @Suite( + .tags( + .FunctionalArea.Sanitizer, + ) + ) + struct SanitizerTests { + + @Test( + arguments: PackageModel.Sanitizer.allCases.filter { $0.hasSwiftBuildSupport }, + ) + func sanitizersSettingSetCorrectBuildRequest( + sanitizer: Sanitizer, + ) async throws { + try await withInstantiatedSwiftBuildSystem( + fromFixture: "PIFBuilder/Simple", + buildParameters: mockBuildParameters( + destination: .host, + sanitizers: [sanitizer], + ), + ) { swiftBuild, session, observabilityScope, buildParameters in + let buildSettings: SWBBuildParameters = try await swiftBuild.makeBuildParameters( + session: session, + symbolGraphOptions: nil, + setToolchainSetting: false, // Set this to false as SwiftBuild checks the toolchain path + ) + + let synthesizedArgs = try #require(buildSettings.overrides.synthesized) + + let swbSettingName = try #require(sanitizer.swiftBuildSettingName) + #expect(synthesizedArgs.table[swbSettingName] == "YES") + } + + } + + @Test( + arguments: PackageModel.Sanitizer.allCases.filter { !$0.hasSwiftBuildSupport }, + ) + func unsupportedSanitizersRaisesError( + sanitizer: Sanitizer, + ) async throws { + try await withInstantiatedSwiftBuildSystem( + fromFixture: "PIFBuilder/Simple", + buildParameters: mockBuildParameters( + destination: .host, + sanitizers: [sanitizer], + ), + ) { swiftBuild, session, observabilityScope, buildParameters in + await #expect(throws: (any Error).self) { + try await swiftBuild.makeBuildParameters( + session: session, + symbolGraphOptions: nil, + setToolchainSetting: false, // Set this to false as SwiftBuild checks the toolchain path + ) + } + } + } + } + + @Test( + arguments: BuildParameters.IndexStoreMode.allCases, + // arguments: [BuildParameters.IndexStoreMode.on], + ) + func indexModeSettingSetCorrectBuildRequest( + indexStoreSettingUT: BuildParameters.IndexStoreMode + ) async throws { + try await withInstantiatedSwiftBuildSystem( + fromFixture: "PIFBuilder/Simple", + buildParameters: mockBuildParameters( + destination: .host, + indexStoreMode: indexStoreSettingUT, + ), + ) { swiftBuild, session, observabilityScope, buildParameters in + let buildSettings = try await swiftBuild.makeBuildParameters( + session: session, + symbolGraphOptions: nil, + setToolchainSetting: false, // Set this to false as SwiftBuild checks the toolchain path + ) + + let synthesizedArgs = try #require(buildSettings.overrides.synthesized) + let expectedSettingValue: String? = switch indexStoreSettingUT { + case .on: "YES" + case .off: "NO" + case .auto: nil + } + let expectedPathValue: String? = switch indexStoreSettingUT { + case .on: buildParameters.indexStore.pathString + case .off: nil + case .auto: nil + } + + #expect(synthesizedArgs.table["SWIFT_INDEX_STORE_ENABLE"] == expectedSettingValue) + #expect(synthesizedArgs.table["CLANG_INDEX_STORE_ENABLE"] == expectedSettingValue) + #expect(synthesizedArgs.table["SWIFT_INDEX_STORE_PATH"] == expectedPathValue) + #expect(synthesizedArgs.table["CLANG_INDEX_STORE_PATH"] == expectedPathValue) + } + } +} diff --git a/Tests/SwiftPMBuildServerTests/BuildServerTests.swift b/Tests/SwiftPMBuildServerTests/BuildServerTests.swift new file mode 100644 index 00000000000..151a8b2e772 --- /dev/null +++ b/Tests/SwiftPMBuildServerTests/BuildServerTests.swift @@ -0,0 +1,174 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// +#if canImport(LanguageServerProtocolTransport) +import Basics +import Foundation +import PackageModel +import BuildServerProtocol +import LanguageServerProtocol +import LanguageServerProtocolTransport +import SwiftPMBuildServer +import _InternalTestSupport +import Testing + +final fileprivate class NotificationCollectingMessageHandler: MessageHandler { + func handle(_ notification: some NotificationType) {} + func handle(_ request: Request, id: RequestID, reply: @escaping @Sendable (LSPResult) -> Void) where Request : RequestType {} +} + +fileprivate func withSwiftPMBSP(fixtureName: String, body: (Connection, NotificationCollectingMessageHandler, AbsolutePath) async throws -> Void) async throws { + try await withKnownIssue(isIntermittent: true) { + try await fixture(name: fixtureName) { fixture in + let inPipe = Pipe() + let outPipe = Pipe() + let connection = JSONRPCConnection( + name: "bsp-connection", + protocol: MessageRegistry.bspProtocol, + inFD: inPipe.fileHandleForReading, + outFD: outPipe.fileHandleForWriting + ) + let bspProcess = Process() + bspProcess.standardOutputPipe = inPipe + bspProcess.standardInput = outPipe + let execPath = SwiftPM.xctestBinaryPath(for: "swift-package").pathString + bspProcess.executableURL = URL(filePath: execPath) + bspProcess.arguments = ["experimental-build-server", "--build-system", "swiftbuild"] + bspProcess.currentDirectoryURL = URL(filePath: fixture.pathString) + async let terminationPromise: Void = try await bspProcess.run() + let notificationCollector = NotificationCollectingMessageHandler() + connection.start(receiveHandler: notificationCollector) + _ = try await connection.send( + InitializeBuildRequest( + displayName: "test-bsp-client", + version: "1.0.0", + bspVersion: "2.2.0", + rootUri: URI(URL(filePath: fixture.pathString)), + capabilities: .init(languageIds: [.swift, .c, .objective_c, .cpp, .objective_cpp]) + ) + ) + connection.send(OnBuildInitializedNotification()) + _ = try await connection.send(WorkspaceWaitForBuildSystemUpdatesRequest()) + try await body(connection, notificationCollector, fixture) + _ = try await connection.send(BuildShutdownRequest()) + connection.send(OnBuildExitNotification()) + connection.close() + try await terminationPromise + } + } when: { + ProcessInfo.isHostAmazonLinux2() + } +} + +@Suite +struct SwiftPMBuildServerTests { + @Test + func lifecycleBasics() async throws { + try await withSwiftPMBSP(fixtureName: "Miscellaneous/Simple") { _, _, _ in + // Do nothing, but ensure the surrounding initialization and shutdown complete successfully. + } + } + + @Test + func buildTargetsListBasics() async throws { + try await withSwiftPMBSP(fixtureName: "Miscellaneous/Simple") { connection, _, _ in + let response = try await connection.send(WorkspaceBuildTargetsRequest()) + #expect(response.targets.count == 2) + #expect(response.targets.map(\.displayName).sorted() == ["Foo", "Package Manifest"]) + } + } + + @Test + func sourcesItemsBasics() async throws { + try await withSwiftPMBSP(fixtureName: "Miscellaneous/Simple") { connection, _, _ in + let targetResponse = try await connection.send(WorkspaceBuildTargetsRequest()) + #expect(targetResponse.targets.count == 2) + #expect(targetResponse.targets.map(\.displayName).sorted() == ["Foo", "Package Manifest"]) + + let fooID = try #require(targetResponse.targets.first(where: { $0.displayName == "Foo" })).id + let sourcesResponse = try await connection.send(BuildTargetSourcesRequest(targets: [fooID])) + let item = try #require(sourcesResponse.items.only?.sources.only) + #expect(item.kind == .file) + #expect(item.uri.fileURL?.lastPathComponent == "Foo.swift") + } + } + + @Test + func compilerArgsBasics() async throws { + try await withSwiftPMBSP(fixtureName: "Miscellaneous/Simple") { connection, _, _ in + let targetResponse = try await connection.send(WorkspaceBuildTargetsRequest()) + #expect(targetResponse.targets.count == 2) + #expect(targetResponse.targets.map(\.displayName).sorted() == ["Foo", "Package Manifest"]) + + let fooID = try #require(targetResponse.targets.first(where: { $0.displayName == "Foo" })).id + let sourcesResponse = try await connection.send(BuildTargetSourcesRequest(targets: [fooID])) + let item = try #require(sourcesResponse.items.only?.sources.only) + #expect(item.kind == .file) + #expect(item.uri.fileURL?.lastPathComponent == "Foo.swift") + + _ = try await connection.send(BuildTargetPrepareRequest(targets: [fooID])) + + let settingsResponse = try #require(try await connection.send(TextDocumentSourceKitOptionsRequest(textDocument: TextDocumentIdentifier(item.uri), target: fooID, language: .swift))) + #expect(settingsResponse.compilerArguments.contains(["-module-name", "Foo"])) + try await AsyncProcess.checkNonZeroExit(arguments: [UserToolchain.default.swiftCompilerPath.pathString, "-typecheck"] + settingsResponse.compilerArguments) + } + } + + @Test + func packageReloadBasics() async throws { + try await withSwiftPMBSP(fixtureName: "Miscellaneous/Simple") { connection, _, fixturePath in + let targetResponse = try await connection.send(WorkspaceBuildTargetsRequest()) + #expect(targetResponse.targets.count == 2) + #expect(targetResponse.targets.map(\.displayName).sorted() == ["Foo", "Package Manifest"]) + + let fooID = try #require(targetResponse.targets.first(where: { $0.displayName == "Foo" })).id + let sourcesResponse = try await connection.send(BuildTargetSourcesRequest(targets: [fooID])) + let sourcesItem = try #require(sourcesResponse.items.only) + #expect(sourcesItem.sources.count == 1) + #expect(sourcesItem.sources.map(\.uri.fileURL?.lastPathComponent).sorted() == ["Foo.swift"]) + + try localFileSystem.writeFileContents(fixturePath.appending(component: "Bar.swift"), body: { + $0.write("public let baz = \"hello\"") + }) + + connection.send(OnWatchedFilesDidChangeNotification(changes: [ + .init(uri: .init(.init(filePath: fixturePath.appending(component: "Bar.swift").pathString)), type: .created) + ])) + _ = try await connection.send(WorkspaceWaitForBuildSystemUpdatesRequest()) + + let updatedSourcesResponse = try await connection.send(BuildTargetSourcesRequest(targets: [fooID])) + let updatedSourcesItem = try #require(updatedSourcesResponse.items.only) + #expect(updatedSourcesItem.sources.count == 2) + #expect(updatedSourcesItem.sources.map(\.uri.fileURL?.lastPathComponent).sorted() == ["Bar.swift", "Foo.swift"]) + } + } + + @Test + func manifestArgs() async throws { + try await withSwiftPMBSP(fixtureName: "Miscellaneous/VersionSpecificManifest") { connection, _, _ in + let targetResponse = try await connection.send(WorkspaceBuildTargetsRequest()) + #expect(targetResponse.targets.count == 2) + #expect(targetResponse.targets.map(\.displayName).sorted() == ["Foo", "Package Manifest"]) + + let manifestTarget = try #require(targetResponse.targets.first(where: { $0.displayName == "Package Manifest" })) + #expect(manifestTarget.tags.contains(.notBuildable)) + let manifestID = manifestTarget.id + let sourcesResponse = try await connection.send(BuildTargetSourcesRequest(targets: [manifestID])) + let manifestItems = try #require(sourcesResponse.items.only?.sources) + #expect(manifestItems.map(\.uri.fileURL?.lastPathComponent).sorted() == ["Package.swift", "Package@swift-5.0.swift"]) + for item in manifestItems { + let settingsResponse = try #require(try await connection.send(TextDocumentSourceKitOptionsRequest(textDocument: TextDocumentIdentifier(item.uri), target: manifestID, language: .swift))) + try await AsyncProcess.checkNonZeroExit(arguments: [UserToolchain.default.swiftCompilerPath.pathString, "-typecheck"] + settingsResponse.compilerArguments) + } + } + } +} +#endif diff --git a/Tests/WorkspaceTests/SourceControlPackageContainerTests.swift b/Tests/WorkspaceTests/SourceControlPackageContainerTests.swift index e73fb132090..b193c501dc5 100644 --- a/Tests/WorkspaceTests/SourceControlPackageContainerTests.swift +++ b/Tests/WorkspaceTests/SourceControlPackageContainerTests.swift @@ -531,7 +531,7 @@ final class SourceControlPackageContainerTests: XCTestCase { try packageRepo.commit(message: "Initial") try packageRepo.tag(name: "1.0.0") - // Rename the `master` branch to `main`. + // Rename the default branch to `main`. try await AsyncProcess.checkNonZeroExit(args: Git.tool, "-C", packageDir.pathString, "branch", "-m", "main") // Create a repository manager for it. @@ -563,13 +563,13 @@ final class SourceControlPackageContainerTests: XCTestCase { let packageRef = PackageReference.localSourceControl(identity: PackageIdentity(path: packageDir), path: packageDir) let container = try await containerProvider.getContainer(for: packageRef) as! SourceControlPackageContainer - // Simulate accessing a fictitious dependency on the `master` branch, and check that we get back the expected error. - do { _ = try await container.getDependencies(at: "master", productFilter: .everything) } + // Simulate accessing a fictitious dependency on the `master` branch, and check that we get back the expected error. //ignore-unacceptable-language + do { _ = try await container.getDependencies(at: "master", productFilter: .everything) } //ignore-unacceptable-language catch let error as SourceControlPackageContainer.GetDependenciesError { // We expect to get an error message that mentions main. - XCTAssertMatch(error.description, .and(.prefix("could not find a branch named ‘master’"), .suffix("(did you mean ‘main’?)"))) + XCTAssertMatch(error.description, .and(.prefix("could not find a branch named ‘master’"), .suffix("(did you mean ‘main’?)"))) //ignore-unacceptable-language XCTAssertMatch(error.repository.description, .suffix("SomePackage")) - XCTAssertMatch(error.reference, "master") + XCTAssertMatch(error.reference, "master") //ignore-unacceptable-language } // Simulate accessing a fictitious dependency on some random commit that doesn't exist, and check that we get back the expected error. diff --git a/Tests/WorkspaceTests/WorkspaceTests.swift b/Tests/WorkspaceTests/WorkspaceTests.swift index ea2974d13c0..73db78f47c6 100644 --- a/Tests/WorkspaceTests/WorkspaceTests.swift +++ b/Tests/WorkspaceTests/WorkspaceTests.swift @@ -1099,7 +1099,7 @@ final class WorkspaceTests: XCTestCase { let bPath = RelativePath("B") let cPath = RelativePath("C") let v1Requirement: SourceControlRequirement = .range("1.0.0" ..< "2.0.0") - let branchRequirement: SourceControlRequirement = .branch("master") + let branchRequirement: SourceControlRequirement = .branch("main") let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello")) let workspace = try await MockWorkspace( @@ -1157,7 +1157,7 @@ final class WorkspaceTests: XCTestCase { XCTAssertEqual(result.result, .required(reason: .packageRequirementChange( package: cRef, state: .sourceControlCheckout(v1_5), - requirement: .revision("master") + requirement: .revision("main") ))) } @@ -1217,7 +1217,7 @@ final class WorkspaceTests: XCTestCase { let fs = InMemoryFileSystem() let bPath = RelativePath("B") let v1Requirement: SourceControlRequirement = .range("1.0.0" ..< "2.0.0") - let masterRequirement: SourceControlRequirement = .branch("master") + let masterRequirement: SourceControlRequirement = .branch("main") let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello")) let workspace = try await MockWorkspace( @@ -1275,7 +1275,7 @@ final class WorkspaceTests: XCTestCase { XCTAssertEqual(result.result, .required(reason: .packageRequirementChange( package: cRef, state: .fileSystem(cPackagePath), - requirement: .revision("master") + requirement: .revision("main") ))) } @@ -1353,7 +1353,7 @@ final class WorkspaceTests: XCTestCase { let cPath = RelativePath("C") let v1Requirement: SourceControlRequirement = .range("1.0.0" ..< "2.0.0") let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello")) - let master = CheckoutState.branch(name: "master", revision: Revision(identifier: "master")) + let main = CheckoutState.branch(name: "main", revision: Revision(identifier: "main")) let workspace = try await MockWorkspace( sandbox: sandbox, @@ -1398,10 +1398,10 @@ final class WorkspaceTests: XCTestCase { ) try await workspace.set( - resolvedPackages: [bRef: v1_5, cRef: master], + resolvedPackages: [bRef: v1_5, cRef: main], managedDependencies: [ bPackagePath: .sourceControlCheckout(packageRef: bRef, state: v1_5, subpath: bPath), - cPackagePath: .sourceControlCheckout(packageRef: cRef, state: master, subpath: cPath), + cPackagePath: .sourceControlCheckout(packageRef: cRef, state: main, subpath: cPath), ] ) @@ -1409,7 +1409,7 @@ final class WorkspaceTests: XCTestCase { XCTAssertNoDiagnostics(result.diagnostics) XCTAssertEqual(result.result, .required(reason: .packageRequirementChange( package: cRef, - state: .sourceControlCheckout(master), + state: .sourceControlCheckout(main), requirement: .unversioned ))) } @@ -5644,7 +5644,7 @@ final class WorkspaceTests: XCTestCase { roots: [ MockPackage( name: "Baz", - path: "Overridden/bazzz-master", + path: "Overridden/bazzz-default", targets: [ MockTarget(name: "Baz"), ], @@ -5672,11 +5672,11 @@ final class WorkspaceTests: XCTestCase { .sourceControl(path: "./bazzz", requirement: .exact("1.0.0"), products: .specific(["Baz"])), ] - try await workspace.checkPackageGraphFailure(roots: ["Overridden/bazzz-master"], deps: deps) { diagnostics in + try await workspace.checkPackageGraphFailure(roots: ["Overridden/bazzz-default"], deps: deps) { diagnostics in testDiagnostics(diagnostics) { result in result.check( diagnostic: .equal( - "unable to override package 'Baz' because its identity 'bazzz' doesn't match override's identity (directory name) 'bazzz-master'" + "unable to override package 'Baz' because its identity 'bazzz' doesn't match override's identity (directory name) 'bazzz-default'" ), severity: .error ) @@ -5922,7 +5922,7 @@ final class WorkspaceTests: XCTestCase { ], products: [], dependencies: [ - .sourceControl(path: "./Foo", requirement: .branch("master")), + .sourceControl(path: "./Foo", requirement: .branch("main")), .sourceControl(path: "./Baz", requirement: .upToNextMajor(from: "1.0.0")), ] ), @@ -5937,9 +5937,9 @@ final class WorkspaceTests: XCTestCase { MockProduct(name: "Foo", modules: ["Foo"]), ], dependencies: [ - .sourceControl(path: "./Bar", requirement: .branch("master")), + .sourceControl(path: "./Bar", requirement: .branch("main")), ], - versions: ["master", nil] + versions: ["main", nil] ), MockPackage( name: "Bar", @@ -5949,7 +5949,7 @@ final class WorkspaceTests: XCTestCase { products: [ MockProduct(name: "Bar", modules: ["Bar"]), ], - versions: ["master", "1.0.0", nil] + versions: ["main", "1.0.0", nil] ), MockPackage( name: "Baz", @@ -5972,8 +5972,8 @@ final class WorkspaceTests: XCTestCase { XCTAssertNoDiagnostics(diagnostics) } await workspace.checkManagedDependencies { result in - result.check(dependency: "foo", at: .checkout(.branch("master"))) - result.check(dependency: "bar", at: .checkout(.branch("master"))) + result.check(dependency: "foo", at: .checkout(.branch("main"))) + result.check(dependency: "bar", at: .checkout(.branch("main"))) result.check(dependency: "baz", at: .checkout(.version("1.0.0"))) } @@ -6002,7 +6002,7 @@ final class WorkspaceTests: XCTestCase { } await workspace.checkManagedDependencies { result in result.check(dependency: "foo", at: .edited(nil)) - result.check(dependency: "bar", at: .checkout(.branch("master"))) + result.check(dependency: "bar", at: .checkout(.branch("main"))) result.check(dependency: "baz", at: .checkout(.version("1.0.0"))) } XCTAssertNoMatch(workspace.delegate.events, [.equal("will resolve dependencies")]) diff --git a/Tests/XCBuildSupportTests/PIFBuilderTests.swift b/Tests/XCBuildSupportTests/PIFBuilderTests.swift index d3ca5fc8bbe..d312562d262 100644 --- a/Tests/XCBuildSupportTests/PIFBuilderTests.swift +++ b/Tests/XCBuildSupportTests/PIFBuilderTests.swift @@ -65,7 +65,7 @@ final class PIFBuilderTests: XCTestCase { path: "/A", toolsVersion: .v5_2, dependencies: [ - .localSourceControl(path: "/B", requirement: .branch("master")), + .localSourceControl(path: "/B", requirement: .branch("main")), ], products: [ .init(name: "alib", type: .library(.static), targets: ["A2"]), @@ -138,7 +138,7 @@ final class PIFBuilderTests: XCTestCase { defaultLocalization: "fr", toolsVersion: .v5_2, dependencies: [ - .localSourceControl(path: "/Bar", requirement: .branch("master")), + .localSourceControl(path: "/Bar", requirement: .branch("main")), ], targets: [ .init(name: "foo", dependencies: [.product(name: "BarLib", package: "Bar")]), @@ -445,7 +445,7 @@ final class PIFBuilderTests: XCTestCase { toolsVersion: .v5_2, swiftLanguageVersions: [.v4_2, .v5], dependencies: [ - .localSourceControl(path: "/Bar", requirement: .branch("master")), + .localSourceControl(path: "/Bar", requirement: .branch("main")), ], targets: [ .init(name: "foo", dependencies: [ @@ -806,7 +806,7 @@ final class PIFBuilderTests: XCTestCase { toolsVersion: .v5_2, swiftLanguageVersions: [.v4_2, .v5], dependencies: [ - .localSourceControl(path: "/Bar", requirement: .branch("master")), + .localSourceControl(path: "/Bar", requirement: .branch("main")), ], targets: [ .init(name: "FooTests", dependencies: [ @@ -1125,7 +1125,7 @@ final class PIFBuilderTests: XCTestCase { toolsVersion: .v5_2, swiftLanguageVersions: [.v4_2, .v5], dependencies: [ - .localSourceControl(path: "/Bar", requirement: .branch("master")), + .localSourceControl(path: "/Bar", requirement: .branch("main")), ], products: [ .init(name: "FooLib1", type: .library(.static), targets: ["FooLib1"]), @@ -1337,7 +1337,7 @@ final class PIFBuilderTests: XCTestCase { cxxLanguageStandard: "c++14", swiftLanguageVersions: [.v4_2, .v5], dependencies: [ - .localSourceControl(path: "/Bar", requirement: .branch("master")), + .localSourceControl(path: "/Bar", requirement: .branch("main")), ], targets: [ .init(name: "FooLib1", dependencies: ["SystemLib", "FooLib2"]), diff --git a/Tests/_AsyncFileSystemTests/AsyncFileSystemTests.swift b/Tests/_AsyncFileSystemTests/AsyncFileSystemTests.swift index e69338ebf41..31bc1372a49 100644 --- a/Tests/_AsyncFileSystemTests/AsyncFileSystemTests.swift +++ b/Tests/_AsyncFileSystemTests/AsyncFileSystemTests.swift @@ -1,13 +1,16 @@ -import Foundation -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2024 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ +import Foundation import _AsyncFileSystem import _InternalTestSupport diff --git a/Utilities/Docker/Dockerfile b/Utilities/Docker/Dockerfile index 75f684c5ce5..249fbfa88ac 100644 --- a/Utilities/Docker/Dockerfile +++ b/Utilities/Docker/Dockerfile @@ -1,10 +1,14 @@ -# This source file is part of the Swift open source project -# -# Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See http://swift.org/LICENSE.txt for license information -# See http://swift.org/CONTRIBUTORS.txt for Swift project authors +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2014-2024 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See http://swift.org/LICENSE.txt for license information +## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## ARG swift_version=5.9 ARG ubuntu_version=jammy diff --git a/Utilities/InstalledSwiftPMConfiguration/Sources/exec.swift b/Utilities/InstalledSwiftPMConfiguration/Sources/exec.swift index 44a912f5085..1def4bd5317 100644 --- a/Utilities/InstalledSwiftPMConfiguration/Sources/exec.swift +++ b/Utilities/InstalledSwiftPMConfiguration/Sources/exec.swift @@ -1,3 +1,15 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2023 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + import Foundation @main diff --git a/Utilities/bootstrap b/Utilities/bootstrap index 14219d6374b..b09242f9742 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -883,7 +883,7 @@ def get_llbuild_source_path(args): llbuild_path = os.path.join(args.project_root, "..", "llbuild") if os.path.exists(llbuild_path): return llbuild_path - logging.info("clone llbuild next to swiftpm directory; see development docs: https://github.com/swiftlang/swift-package-manager/blob/master/Documentation/Contributing.md") + logging.info("clone llbuild next to swiftpm directory; see development docs: https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/Contributing.md") logging.error("unable to find llbuild source directory at %s", llbuild_path) raise BinaryNotFound(tool="llbuild", path=llbuild_path) diff --git a/Utilities/build-using-self b/Utilities/build-using-self index 0cf187e939f..9650b68f8f6 100755 --- a/Utilities/build-using-self +++ b/Utilities/build-using-self @@ -25,7 +25,6 @@ from datetime import datetime import typing as t from helpers import ( - Configuration, change_directory, call, call_output, @@ -71,10 +70,8 @@ def get_arguments() -> argparse.Namespace: parser.add_argument( "-c", "--configuration", - type=Configuration, + type=str, dest="config", - default=Configuration.DEBUG, - choices=[e for e in Configuration], help="The configuration to use.", ) parser.add_argument( @@ -89,6 +86,18 @@ def get_arguments() -> argparse.Namespace: type=str, dest="build_system", ) + parser.add_argument( + "--skip-clean", + action="store_false", + dest="should_clean", + help="When set, do not clean the build output" + ) + parser.add_argument( + "--skip-update", + action="store_false", + dest="should_update", + help="When set, do not run a swift package update" + ) parser.add_argument( "--additional-build-args", type=str, @@ -123,10 +132,13 @@ def log_environment() -> None: logging.info(" --> %s=%r", key, value) -def get_swiftpm_bin_dir(config: Configuration) -> pathlib.Path: +def get_swiftpm_bin_dir( + *, + global_args: t.List[str], +) -> pathlib.Path: logging.info("Retrieving Swift PM binary directory.") swiftpm_bin_dir = pathlib.Path( - call_output(["swift", "build", "--configuration", config, "--show-bin-path"]) + call_output(["swift", "build", *global_args, "--show-bin-path"]) ) logging.info("SwiftPM BIN DIR: %s", swiftpm_bin_dir) return swiftpm_bin_dir @@ -136,10 +148,7 @@ def is_on_darwin() -> bool: return platform.system() == "Darwin" -def set_environment( - *, - swiftpm_bin_dir: pathlib.Path, -) -> None: +def set_environment() -> None: os.environ["SWIFTCI_IS_SELF_HOSTED"] = "1" # Ensure SDKROOT is configure @@ -189,6 +198,15 @@ class GlobalArgs: def filterIsTruthy(items: t.Iterable) -> t.Iterable: return list(filter(lambda x: x, items)) +def log_directory_contents(directory: pathlib.Path) -> None: + logging.info("Build path directory : %s", directory) + logging.info("Listing files in directory: %s", directory) + try: + for item in sorted(os.listdir(path=directory)): + logging.info(" -> %s", item) + except FileNotFoundError: + logging.warning("Directory %s does not exist.", directory) + def main() -> None: args = get_arguments() @@ -198,6 +216,7 @@ def main() -> None: globalArgsData = [ GlobalArgs(global_argument="--triple", value=args.triple), GlobalArgs(global_argument="--build-system", value=args.build_system), + GlobalArgs(global_argument="--configuration", value=args.config), ] global_args: t.Iterator[GlobalArgsValueType] = list( itertools.chain.from_iterable( @@ -206,9 +225,9 @@ def main() -> None: ) logging.debug("Global Args: %r", global_args) start_time = datetime.now() - with change_directory(REPO_ROOT_PATH): - swiftpm_bin_dir = get_swiftpm_bin_dir(config=args.config) - set_environment(swiftpm_bin_dir=swiftpm_bin_dir) + with change_directory(REPO_ROOT_PATH) as dir: + swiftpm_bin_dir = get_swiftpm_bin_dir(global_args=global_args) + set_environment() call( filterIsTruthy( @@ -219,39 +238,55 @@ def main() -> None: ) ) - call( - filterIsTruthy( - [ - "swift", - "package", - "update", - ] + if args.should_clean: + call( + filterIsTruthy( + [ + "swift", + "package", + *global_args, + "clean", + ] + ) ) - ) + + if args.should_update: + call( + filterIsTruthy( + [ + "swift", + "package", + *global_args, + "update", + ] + ) + ) + call( filterIsTruthy( [ "swift", "build", *global_args, - "--configuration", - args.config, + "--build-tests", *ignore_args, *args.additional_build_args.split(" ") ] ) ) + call( filterIsTruthy( [ "swift", "run", + *global_args, *ignore_args, *args.additional_run_args.split(" "), "swift-test", *global_args, - "--configuration", - args.config, + "--vv", + "--force-resolved-versions", "--parallel", "--scratch-path", ".test", diff --git a/cmake/modules/FindLLBuild.cmake b/cmake/modules/FindLLBuild.cmake index 505a67eedfa..be72d9e5e1f 100644 --- a/cmake/modules/FindLLBuild.cmake +++ b/cmake/modules/FindLLBuild.cmake @@ -1,10 +1,14 @@ -# This source file is part of the Swift open source project -# -# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See http://swift.org/LICENSE.txt for license information -# See http://swift.org/CONTRIBUTORS.txt for Swift project authors +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift open source project +## +## Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See http://swift.org/LICENSE.txt for license information +## See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## if(TARGET llbuildSwift) return()