Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Formatting code base
19ab5e34677a7fea521b682ee35c974f7aaac0fb
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ jobs:
license_header_check_enabled: false
unacceptable_language_check_enabled: false
api_breakage_check_enabled: false
format_check_enabled: false
format_check_enabled: true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

chore (blocking): We need to exclude the Fixtures directory from the formatting check since it contains code that does not compile.

shell_check_enabled: false
13 changes: 13 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"lineLength": 10000,
"indentation": {
Copy link
Contributor Author

@bkhouri bkhouri Aug 8, 2025

Choose a reason for hiding this comment

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

suggestion: I haven't read the documentation, but based on the setting name, we should consider "multiElementCollectionTrailingCommas" : true,.

Copy link
Contributor

Choose a reason for hiding this comment

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

That corresponds to:

[
    "a",
    "b"
]

vs

[
    "a",
    "b",
]

Support for the latter was added to Swift some time ago, the argument being that it helps reduce the SCM diff as new lines are added to the bottom.

I'd be fine with enabling that rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want the latter :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also want

[1, 3]

to format to

[
    1,
    3,
]

"spaces": 4
},
"lineBreakBeforeEachArgument": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

This rule feels a little too opinionated to me, not sure if anyone else has an opinion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this option helps make the diff ever-so-slightly cleaner to read.

Copy link
Contributor

Choose a reason for hiding this comment

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

This would result in a pretty huge diff. While I agree it can enhance readability in some cases, I'm not sure we should make the jump right away. I'd omit this for now and maybe we should have a wider discussion first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to get to the following

func foo(a: Int, b: String) {
}

to

func foo(
    a: Int,
    b: String,
) {
}

"maximumBlankLines" : 1,
"multiElementCollectionTrailingCommas" : true,
"rules": {
},
Copy link
Contributor Author

@bkhouri bkhouri Aug 8, 2025

Choose a reason for hiding this comment

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

suggestion: I haven't read the documentation ,but based on the setting name, we should consider the following, eventually:

  "rules" : {
    "AllPublicDeclarationsHaveDocumentation" : false,
  }

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to strive towards, but we should not add that immediately as I think for SwiftPM in particular there's a lot which is public but which maybe shouldn't be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100% agree :). Something to consider for the future.

"tabWidth": 4
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
@_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly)
import Basics
@_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly) import Basics
import Benchmark
import Foundation
import PackageModel

@_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly)
import func PackageGraph.loadModulesGraph
@_spi(DontAdoptOutsideOfSwiftPMExposedForBenchmarksAndTestsOnly) import func PackageGraph.loadModulesGraph

import Workspace

let benchmarks = {
let defaultMetrics: [BenchmarkMetric]
if let envVar = ProcessInfo.processInfo.environment["SWIFTPM_BENCHMARK_ALL_METRICS"],
envVar.lowercased() == "true" || envVar == "1" {
envVar.lowercased() == "true" || envVar == "1"
{
defaultMetrics = .all
} else {
defaultMetrics = [
Expand All @@ -23,23 +22,26 @@ let benchmarks = {

let modulesGraphDepth: Int
if let envVar = ProcessInfo.processInfo.environment["SWIFTPM_BENCHMARK_MODULES_GRAPH_DEPTH"],
let parsedValue = Int(envVar) {
let parsedValue = Int(envVar)
{
modulesGraphDepth = parsedValue
} else {
modulesGraphDepth = 150
}

let modulesGraphWidth: Int
if let envVar = ProcessInfo.processInfo.environment["SWIFTPM_BENCHMARK_MODULES_GRAPH_WIDTH"],
let parsedValue = Int(envVar) {
let parsedValue = Int(envVar)
{
modulesGraphWidth = parsedValue
} else {
modulesGraphWidth = 150
}

let packagesGraphDepth: Int
if let envVar = ProcessInfo.processInfo.environment["SWIFTPM_BENCHMARK_PACKAGES_GRAPH_DEPTH"],
let parsedValue = Int(envVar) {
let parsedValue = Int(envVar)
{
packagesGraphDepth = parsedValue
} else {
packagesGraphDepth = 10
Expand Down Expand Up @@ -103,18 +105,18 @@ let benchmarks = {
)
) { benchmark in
try syntheticModulesGraph(
benchmark,
modulesGraphDepth: modulesGraphDepth,
benchmark,
modulesGraphDepth: modulesGraphDepth,
modulesGraphWidth: modulesGraphWidth,
includeMacros: true
)
}
}

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:
Expand All @@ -137,9 +139,12 @@ func syntheticModulesGraph(
let macrosDependenciesModules: [TargetDescription]
if includeMacros {
macrosModules = try (0..<modulesGraphWidth / macrosDenominator).map { i in
try TargetDescription(name: "Macros\(i)", dependencies: (0..<min(i, modulesGraphDepth)).map {
.target(name: "MacrosDependency\($0)")
})
try TargetDescription(
name: "Macros\(i)",
dependencies: (0..<min(i, modulesGraphDepth)).map {
.target(name: "MacrosDependency\($0)")
}
)
}
macrosDependenciesModules = try (0..<modulesGraphWidth / macrosDenominator).map { i in
try TargetDescription(name: "MacrosDependency\(i)")
Expand Down
6 changes: 3 additions & 3 deletions Benchmarks/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import PackageDescription
let package = Package(
name: "SwiftPMBenchmarks",
platforms: [
.macOS("14"),
.macOS("14")
],
dependencies: [
.package(path: "../"),
Expand All @@ -31,8 +31,8 @@ let package = Package(
],
path: "Benchmarks/PackageGraphBenchmarks",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark"),
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
),
)
]
)
10 changes: 8 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -43,6 +43,12 @@ If you are preparing to make a contribution you should fork the repository first

SwiftPM is typically built with a pre-existing version of SwiftPM present on the system, but there are multiple ways to setup your development environment:

Once the repository is clone, configure your local repository so blame ignores some commits:

```
git config blame.ignoreRevsFile .git-blame-ignore-revs
```

### Using Xcode (Easiest)

1. Install Xcode from [https://developer.apple.com/xcode](https://developer.apple.com/xcode) (including betas!).
Expand Down Expand Up @@ -510,5 +516,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*
6 changes: 3 additions & 3 deletions Examples/package-info/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ let package = Package(
name: "package-info",
platforms: [
.macOS(.v13),
.iOS(.v13)
.iOS(.v13),
],
dependencies: [
// This just points to the SwiftPM at the root of this repository.
.package(name: "swift-package-manager", path: "../../"),
.package(name: "swift-package-manager", path: "../../")
// You will want to depend on a stable semantic version instead:
// .package(url: "https://github.com/swiftlang/swift-package-manager", .exact("0.4.0"))
],
Expand All @@ -20,6 +20,6 @@ let package = Package(
dependencies: [
.product(name: "SwiftPM", package: "swift-package-manager")
]
),
)
]
)
Loading
Loading