-
Notifications
You must be signed in to change notification settings - Fork 1.4k
suppress warnings from remote dependencies #5605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// swift-tools-version: 5.7 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "app", | ||
products: [ | ||
.executable(name: "app", targets: ["app"]) | ||
], | ||
dependencies: [ | ||
.package(url: "../dep1", from: "1.0.0"), | ||
.package(url: "../dep2", from: "1.0.0"), | ||
], | ||
targets: [ | ||
.executableTarget( | ||
name: "app", | ||
dependencies: [ | ||
.product(name: "dep1", package: "dep1"), | ||
.product(name: "dep2", package: "dep2") | ||
], | ||
path: "./" | ||
) | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import dep1 | ||
import dep2 | ||
|
||
@main | ||
struct App { | ||
var deprecated: DeprecatedApp | ||
|
||
public static func main() { | ||
print("hello, world!") | ||
} | ||
} | ||
|
||
@available(*, deprecated) | ||
struct DeprecatedApp { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// swift-tools-version: 5.7 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "dep1", | ||
products: [ | ||
.library(name: "dep1", targets: ["dep1"]) | ||
], | ||
targets: [ | ||
.target(name: "dep1", path: "./") | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
struct Dep1 { | ||
var deprecated: Deprecated1 | ||
} | ||
|
||
@available(*, deprecated) | ||
struct Deprecated1 { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// swift-tools-version: 5.7 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "dep2", | ||
products: [ | ||
.library(name: "dep2", targets: ["dep2"]) | ||
], | ||
targets: [ | ||
.target(name: "dep2", path: "./") | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
struct Dep2 { | ||
var deprecated: Deprecated2 | ||
} | ||
|
||
@available(*, deprecated) | ||
struct Deprecated2 { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -530,6 +530,8 @@ public final class ClangTargetBuildDescription { | |
|
||
/// Target description for a Swift target. | ||
public final class SwiftTargetBuildDescription { | ||
/// The package this target belongs to. | ||
public let package: ResolvedPackage | ||
|
||
/// The target described by this target. | ||
public let target: ResolvedTarget | ||
|
@@ -661,6 +663,7 @@ public final class SwiftTargetBuildDescription { | |
|
||
/// Create a new target description with target and build parameters. | ||
init( | ||
package: ResolvedPackage, | ||
target: ResolvedTarget, | ||
toolsVersion: ToolsVersion, | ||
additionalFileRules: [FileRuleDescription] = [], | ||
|
@@ -675,6 +678,7 @@ public final class SwiftTargetBuildDescription { | |
guard target.underlyingTarget is SwiftTarget else { | ||
throw InternalError("underlying target type mismatch \(target)") | ||
} | ||
self.package = package | ||
self.target = target | ||
self.toolsVersion = toolsVersion | ||
self.buildParameters = buildParameters | ||
|
@@ -869,6 +873,11 @@ public final class SwiftTargetBuildDescription { | |
args += ["-emit-module-interface-path", parseableModuleInterfaceOutputPath.pathString] | ||
} | ||
|
||
// suppress warnings if the package is remote | ||
if self.package.isRemote { | ||
args += ["-suppress-warnings"] | ||
} | ||
|
||
args += buildParameters.toolchain.extraSwiftCFlags | ||
// User arguments (from -Xswiftc) should follow generated arguments to allow user overrides | ||
args += buildParameters.swiftCompilerFlags | ||
|
@@ -1608,13 +1617,17 @@ public class BuildPlan { | |
var generateRedundant = generate | ||
var result: [(ResolvedProduct, SwiftTargetBuildDescription)] = [] | ||
for testProduct in graph.allProducts where testProduct.type == .test { | ||
guard let package = graph.package(for: testProduct) else { | ||
throw InternalError("package not found for \(testProduct)") | ||
} | ||
generateRedundant = generateRedundant && nil == testProduct.testManifestTarget | ||
// if test manifest exists, prefer that over test detection, | ||
// this is designed as an escape hatch when test discovery is not appropriate | ||
// and for backwards compatibility for projects that have existing test manifests (LinuxMain.swift) | ||
let toolsVersion = graph.package(for: testProduct)?.manifest.toolsVersion ?? .v5_5 | ||
if let testManifestTarget = testProduct.testManifestTarget, !generate { | ||
let desc = try SwiftTargetBuildDescription( | ||
package: package, | ||
target: testManifestTarget, | ||
toolsVersion: toolsVersion, | ||
buildParameters: buildParameters, | ||
|
@@ -1651,6 +1664,7 @@ public class BuildPlan { | |
) | ||
|
||
let target = try SwiftTargetBuildDescription( | ||
package: package, | ||
target: testManifestTarget, | ||
toolsVersion: toolsVersion, | ||
buildParameters: buildParameters, | ||
|
@@ -1716,7 +1730,11 @@ public class BuildPlan { | |
|
||
switch target.underlyingTarget { | ||
case is SwiftTarget: | ||
guard let package = graph.package(for: target) else { | ||
throw InternalError("package not found for \(target)") | ||
} | ||
targetMap[target] = try .swift(SwiftTargetBuildDescription( | ||
package: package, | ||
target: target, | ||
toolsVersion: toolsVersion, | ||
additionalFileRules: additionalFileRules, | ||
|
@@ -2303,8 +2321,19 @@ private func generateResourceInfoPlist( | |
return true | ||
} | ||
|
||
fileprivate extension TSCUtility.Triple { | ||
var isSupportingStaticStdlib: Bool { | ||
extension TSCUtility.Triple { | ||
fileprivate var isSupportingStaticStdlib: Bool { | ||
isLinux() || arch == .wasm32 | ||
} | ||
} | ||
|
||
extension ResolvedPackage { | ||
fileprivate var isRemote: Bool { | ||
switch self.underlyingPackage.manifest.packageKind { | ||
case .registry, .remoteSourceControl, .localSourceControl: | ||
return true | ||
case .root, .fileSystem: | ||
return false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to confirm, this would make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exactly |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 👏