Respect relativePaths in local package paths (#1498)

* Respect relativePaths in local package paths

Before this a local package defined in an included file would not
respect relativePaths: true.

This fixes #1497.

* Test local package with relative path

* add relative paths support to localPackages syntax

---------

Co-authored-by: Yonas Kolb <yonaskolb@users.noreply.github.com>
This commit is contained in:
Juri Pakaste
2024-12-29 15:41:41 +02:00
committed by GitHub
parent 1aa7e281b7
commit 5644662e5b
8 changed files with 51 additions and 0 deletions
+2
View File
@@ -241,6 +241,8 @@ extension Project: PathContainer {
.object("aggregateTargets", AggregateTarget.pathProperties),
.object("schemes", Scheme.pathProperties),
.object("projectReferences", ProjectReference.pathProperties),
.object("packages", SwiftPackage.pathProperties),
.string("localPackages")
]
}
}
+10
View File
@@ -127,3 +127,13 @@ extension SwiftPackage.VersionRequirement: JSONUtilities.JSONObjectConvertible {
}
}
}
extension SwiftPackage: PathContainer {
static var pathProperties: [PathProperty] {
[
.dictionary([
.string("path"),
]),
]
}
}
@@ -1,6 +1,8 @@
include:
- recursive_test/recursive_test.yml
- same_relative_path_test/same_relative_path_test.yml
- path: relative_local_package/inc.yml
relativePaths: true
configFiles:
IncludedConfig: config
projectReferences:
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
@@ -0,0 +1,20 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "LocalPackage",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "LocalPackage",
targets: ["LocalPackage"]
)
],
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: "LocalPackage")
]
)
@@ -0,0 +1,2 @@
// The Swift Programming Language
// https://docs.swift.org/swift-book
@@ -0,0 +1,3 @@
packages:
LocalPackage:
path: LocalPackage
@@ -193,6 +193,10 @@ class SpecLoadingTests: XCTestCase {
test: .init(testPlans: [.init(path: "paths_test/TestPlan.xctestplan")])
)
]
try expect(project.packages) == [
"LocalPackage": .local(path: "paths_test/relative_local_package/LocalPackage", group: nil),
]
}
$0.it("respects directory expansion preference") {