From c224e9e304a531703444a5203a0a1b54d131e894 Mon Sep 17 00:00:00 2001 From: Dave Inglis Date: Mon, 3 Nov 2025 10:34:12 -0500 Subject: [PATCH] Change how libraries are specified to the linker - remove the platform specifics from computeLibraryArgs, we now just use LIBRARY_PREFIX and remove any suffix for searchPathFlagsForLD, and moved this into the LinkerSpec.LibrarySpecifier extension, this allows for proper searching of libraries, and linking of dynamic libraries on Windows. --- Sources/SWBCore/Settings/BuiltinMacros.swift | 2 + .../SpecImplementations/LinkerSpec.swift | 11 ++- .../Tools/LinkerTools.swift | 71 +++++++------------ .../SourcesTaskProducer.swift | 6 +- .../Specs/ProductTypes.xcspec | 1 + Sources/SWBWindowsPlatform/Plugin.swift | 2 +- .../BuildOperationTests.swift | 50 +++---------- .../SwiftCompilationCachingTests.swift | 4 +- .../SwiftDriverTests.swift | 8 +-- .../TargetDependencyResolverTests.swift | 2 +- .../SWBGenericUnixPlatformTests.swift | 10 --- .../SWBQNXPlatformTests.swift | 9 --- .../BuildActionTaskConstructionTests.swift | 4 +- .../InstallAPITaskConstructionTests.swift | 18 ++--- .../InstallTaskConstructionTests.swift | 20 +++--- .../MergeableLibraryTests.swift | 8 +-- .../PackageProductConstructionTests.swift | 16 ++--- .../PostprocessingTaskConstructionTests.swift | 22 +++--- .../TaskConstructionTests.swift | 9 +-- .../UnitTestTaskConstructionTests.swift | 3 +- .../SWBWebAssemblyPlatformTests.swift | 12 ---- 21 files changed, 107 insertions(+), 181 deletions(-) diff --git a/Sources/SWBCore/Settings/BuiltinMacros.swift b/Sources/SWBCore/Settings/BuiltinMacros.swift index 247f44de..a6cbde94 100644 --- a/Sources/SWBCore/Settings/BuiltinMacros.swift +++ b/Sources/SWBCore/Settings/BuiltinMacros.swift @@ -685,6 +685,7 @@ public final class BuiltinMacros { public static let EXECUTABLE_DEBUG_DYLIB_MAPPED_PLATFORM = BuiltinMacros.declareStringMacro("EXECUTABLE_DEBUG_DYLIB_MAPPED_PLATFORM") public static let EXECUTABLE_BLANK_INJECTION_DYLIB_PATH = BuiltinMacros.declareStringMacro("EXECUTABLE_BLANK_INJECTION_DYLIB_PATH") + public static let EXECUTABLE_PREFIX = BuiltinMacros.declareStringMacro("EXECUTABLE_PREFIX") public static let EXECUTABLE_SUFFIX = BuiltinMacros.declareStringMacro("EXECUTABLE_SUFFIX") public static let EXECUTABLE_VARIANT_SUFFIX = BuiltinMacros.declareStringMacro("EXECUTABLE_VARIANT_SUFFIX") public static let EXPORTED_SYMBOLS_FILE = BuiltinMacros.declarePathMacro("EXPORTED_SYMBOLS_FILE") @@ -1764,6 +1765,7 @@ public final class BuiltinMacros { EXECUTABLE_DEBUG_DYLIB_MAPPED_INSTALL_NAME, EXECUTABLE_DEBUG_DYLIB_MAPPED_PLATFORM, EXECUTABLE_BLANK_INJECTION_DYLIB_PATH, + EXECUTABLE_PREFIX, EXECUTABLE_SUFFIX, EXECUTABLE_VARIANT_SUFFIX, EXCLUDED_ARCHS, diff --git a/Sources/SWBCore/SpecImplementations/LinkerSpec.swift b/Sources/SWBCore/SpecImplementations/LinkerSpec.swift index 5d728619..59f3d22c 100644 --- a/Sources/SWBCore/SpecImplementations/LinkerSpec.swift +++ b/Sources/SWBCore/SpecImplementations/LinkerSpec.swift @@ -89,7 +89,9 @@ open class LinkerSpec : CommandLineToolSpec, @unchecked Sendable { /// The path to the privacy file, if one exists. public let privacyFile: Path? - public init(kind: Kind, path: Path, mode: Mode, useSearchPaths: Bool, swiftModulePaths: [String: Path], swiftModuleAdditionalLinkerArgResponseFilePaths: [String: Path], explicitDependencies: [Path] = [], topLevelItemPath: Path? = nil, dsymPath: Path? = nil, xcframeworkSourcePath: Path? = nil, privacyFile: Path? = nil) { + public let libPrefix: String + + public init(kind: Kind, path: Path, mode: Mode, useSearchPaths: Bool, swiftModulePaths: [String: Path], swiftModuleAdditionalLinkerArgResponseFilePaths: [String: Path], refSettings: Settings? = nil, explicitDependencies: [Path] = [], topLevelItemPath: Path? = nil, dsymPath: Path? = nil, xcframeworkSourcePath: Path? = nil, privacyFile: Path? = nil) { self.kind = kind self.path = path self.mode = mode @@ -101,6 +103,13 @@ open class LinkerSpec : CommandLineToolSpec, @unchecked Sendable { self.dsymPath = dsymPath self.xcframeworkSourcePath = xcframeworkSourcePath self.privacyFile = privacyFile + let prefix = refSettings?.globalScope.evaluate(BuiltinMacros.EXECUTABLE_PREFIX) ?? "" + #if os(Windows) + let default_prefix = "" + #else + let default_prefix = "lib" + #endif + self.libPrefix = prefix == "" ? default_prefix : prefix } } diff --git a/Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift b/Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift index 6e8bdf85..13422297 100644 --- a/Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift +++ b/Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift @@ -1289,41 +1289,12 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec private static func computeLibraryArgs(_ libraries: [LibrarySpecifier], scope: MacroEvaluationScope) -> (args: [String], inputs: [Path]) { // Construct the library arguments. return libraries.compactMap { specifier -> (args: [String], inputs: [Path]) in - let basename = specifier.path.basename - - // FIXME: This isn't a good system, we need to redesign how we talk to the linker w.r.t. search paths and our notion of paths. switch specifier.kind { - case .static: - if specifier.useSearchPaths, basename.hasPrefix("lib"), basename.hasSuffix(".a") { - return (specifier.searchPathFlagsForLd(basename.withoutPrefix("lib").withoutSuffix(".a")), []) - } - return (specifier.absolutePathFlagsForLd(), [specifier.path]) - case .dynamic: - let suffix = ".\(scope.evaluate(BuiltinMacros.DYNAMIC_LIBRARY_EXTENSION))" - if specifier.useSearchPaths, basename.hasPrefix("lib"), basename.hasSuffix(suffix) { - return (specifier.searchPathFlagsForLd(basename.withoutPrefix("lib").withoutSuffix(suffix)), []) - } - return (specifier.absolutePathFlagsForLd(), [specifier.path]) - case .textBased: - if specifier.useSearchPaths, basename.hasPrefix("lib"), basename.hasSuffix(".tbd") { - // .merge and .reexport are not supported for text-based libraries. - return (specifier.searchPathFlagsForLd(basename.withoutPrefix("lib").withoutSuffix(".tbd")), []) - } - return (specifier.absolutePathFlagsForLd(), [specifier.path]) - case .framework: - let frameworkName = Path(basename).withoutSuffix + case .static, .dynamic, .textBased, .framework: if specifier.useSearchPaths { - return (specifier.searchPathFlagsForLd(frameworkName), []) - } - let absPathArgs = specifier.absolutePathFlagsForLd() - let returnPath: Path - if let pathArg = absPathArgs.last, Path(pathArg).basename == frameworkName { - returnPath = Path(pathArg) - } - else { - returnPath = specifier.path + return (specifier.searchPathFlagsForLd(), []) } - return (absPathArgs, [returnPath]) + return (specifier.absolutePathFlagsForLd(), [specifier.path]) case .object: // Object files are added to linker inputs in the sources task producer. return ([], []) @@ -1559,35 +1530,41 @@ public final class LdLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @unchec /// Extensions to `LinkerSpec.LibrarySpecifier` specific to the dynamic linker. fileprivate extension LinkerSpec.LibrarySpecifier { - func searchPathFlagsForLd(_ name: String) -> [String] { + func searchPathFlagsForLd() -> [String] { + let strippedName: String + if path.basename.hasPrefix(libPrefix) { + strippedName = Path(path.basename).withoutSuffix.withoutPrefix(libPrefix) + } else { + strippedName = Path(path.basename).withoutSuffix + } switch (kind, mode) { case (.dynamic, .normal): - return ["-l" + name] + return ["-l" + strippedName] case (.dynamic, .reexport): - return ["-Xlinker", "-reexport-l" + name] + return ["-Xlinker", "-reexport-l" + strippedName] case (.dynamic, .merge): - return ["-Xlinker", "-merge-l" + name] + return ["-Xlinker", "-merge-l" + strippedName] case (.dynamic, .reexport_merge): - return ["-Xlinker", "-no_merge-l" + name] + return ["-Xlinker", "-no_merge-l" + strippedName] case (.dynamic, .weak): - return ["-weak-l" + name] + return ["-weak-l" + strippedName] case (.static, .weak), (.textBased, .weak): - return ["-weak-l" + name] + return ["-weak-l" + strippedName] case (.static, _), (.textBased, _): // Other modes are not supported for these kinds. - return ["-l" + name] + return ["-l" + strippedName] case (.framework, .normal): - return ["-framework", name] + return ["-framework", strippedName] case (.framework, .reexport): - return ["-Xlinker", "-reexport_framework", "-Xlinker", name] + return ["-Xlinker", "-reexport_framework", "-Xlinker", strippedName] case (.framework, .merge): - return ["-Xlinker", "-merge_framework", "-Xlinker", name] + return ["-Xlinker", "-merge_framework", "-Xlinker", strippedName] case (.framework, .reexport_merge): - return ["-Xlinker", "-no_merge_framework", "-Xlinker", name] + return ["-Xlinker", "-no_merge_framework", "-Xlinker", strippedName] case (.framework, .weak): - return ["-weak_framework", name] + return ["-weak_framework", strippedName] case (.object, _): // Object files are added to linker inputs in the sources task producer. return [] @@ -1724,9 +1701,9 @@ public final class LibtoolLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @u delegate.warning("Product \(cbc.output.basename) cannot weak-link \(specifier.kind) \(basename)") } - if specifier.useSearchPaths, basename.hasPrefix("lib"), basename.hasSuffix(".a") { + if specifier.useSearchPaths { // Locate using search paths: Add a -l option and *don't* add the path to the library as an input to the task. - return ["-l" + basename.withoutPrefix("lib").withoutSuffix(".a")] + return ["-l" + Path(specifier.path.basename).withoutSuffix.withoutPrefix(specifier.libPrefix)] } else { // Locate using an absolute path: Add the path as an option and as an input to the task. diff --git a/Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift b/Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift index c02f73e2..59117bba 100644 --- a/Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift +++ b/Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift @@ -506,6 +506,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F useSearchPaths: useSearchPaths, swiftModulePaths: swiftModulePaths, swiftModuleAdditionalLinkerArgResponseFilePaths: swiftModuleAdditionalLinkerArgResponseFilePaths, + refSettings: settingsForRef, privacyFile: privacyFile ) } else if fileType.conformsTo(context.lookupFileType(identifier: "compiled.mach-o.dylib")!) { @@ -516,6 +517,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F useSearchPaths: useSearchPaths, swiftModulePaths: [:], swiftModuleAdditionalLinkerArgResponseFilePaths: [:], + refSettings: settingsForRef, privacyFile: privacyFile ) } else if fileType.conformsTo(context.lookupFileType(identifier: "sourcecode.text-based-dylib-definition")!) { @@ -526,6 +528,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F useSearchPaths: useSearchPaths, swiftModulePaths: [:], swiftModuleAdditionalLinkerArgResponseFilePaths: [:], + refSettings: settingsForRef, privacyFile: privacyFile ) } else if fileType.conformsTo(context.lookupFileType(identifier: "wrapper.framework")!) { @@ -571,6 +574,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F useSearchPaths: useSearchPaths, swiftModulePaths: [:], swiftModuleAdditionalLinkerArgResponseFilePaths: [:], + refSettings: settingsForRef, topLevelItemPath: topLevelItemPath, dsymPath: dsymPath, privacyFile: privacyFile @@ -580,7 +584,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F kind: .object, path: absolutePath, mode: buildFile.shouldLinkWeakly ? .weak : .normal, - useSearchPaths: useSearchPaths, + useSearchPaths: false, swiftModulePaths: swiftModulePaths, swiftModuleAdditionalLinkerArgResponseFilePaths: swiftModuleAdditionalLinkerArgResponseFilePaths, privacyFile: privacyFile diff --git a/Sources/SWBUniversalPlatform/Specs/ProductTypes.xcspec b/Sources/SWBUniversalPlatform/Specs/ProductTypes.xcspec index fbe68f45..1f6250cd 100644 --- a/Sources/SWBUniversalPlatform/Specs/ProductTypes.xcspec +++ b/Sources/SWBUniversalPlatform/Specs/ProductTypes.xcspec @@ -82,6 +82,7 @@ FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)"; MACH_O_TYPE = "mh_dylib"; REZ_EXECUTABLE = YES; + EXECUTABLE_PREFIX = "lib"; EXECUTABLE_SUFFIX = ".$(EXECUTABLE_EXTENSION)"; EXECUTABLE_EXTENSION = "$(DYNAMIC_LIBRARY_EXTENSION:default=dylib)"; PUBLIC_HEADERS_FOLDER_PATH = "/usr/local/include"; diff --git a/Sources/SWBWindowsPlatform/Plugin.swift b/Sources/SWBWindowsPlatform/Plugin.swift index b3c095ef..c4e07e67 100644 --- a/Sources/SWBWindowsPlatform/Plugin.swift +++ b/Sources/SWBWindowsPlatform/Plugin.swift @@ -170,7 +170,7 @@ struct WindowsSDKRegistryExtension: SDKRegistryExtension { "GENERATE_INTERMEDIATE_TEXT_BASED_STUBS": "NO", "LIBRARY_SEARCH_PATHS": "$(inherited) $(SDKROOT)/usr/lib/swift/windows/$(CURRENT_ARCH)", - "TEST_LIBRARY_SEARCH_PATHS": .plString("\(testingLibraryPath.strWithPosixSlashes)/Testing-$(SWIFT_TESTING_VERSION)/usr/lib/swift/windows/$(CURRENT_ARCH) \(testingLibraryPath.strWithPosixSlashes)/XCTest-$(XCTEST_VERSION)/usr/lib/swift/windows/$(CURRENT_ARCH)"), + "TEST_LIBRARY_SEARCH_PATHS": .plString("\(testingLibraryPath.strWithPosixSlashes)/Testing-$(SWIFT_TESTING_VERSION)/usr/lib/swift/windows/ \(testingLibraryPath.strWithPosixSlashes)/Testing-$(SWIFT_TESTING_VERSION)/usr/lib/swift/windows/$(CURRENT_ARCH) \(testingLibraryPath.strWithPosixSlashes)/XCTest-$(XCTEST_VERSION)/usr/lib/swift/windows/$(CURRENT_ARCH) \(testingLibraryPath.strWithPosixSlashes)/XCTest-$(XCTEST_VERSION)/usr/lib/swift/windows"), "OTHER_SWIFT_FLAGS": "$(inherited) -libc $(DEFAULT_USE_RUNTIME)", "DEFAULT_USE_RUNTIME": "MD", diff --git a/Tests/SWBBuildSystemTests/BuildOperationTests.swift b/Tests/SWBBuildSystemTests/BuildOperationTests.swift index 556c0783..89509f4d 100644 --- a/Tests/SWBBuildSystemTests/BuildOperationTests.swift +++ b/Tests/SWBBuildSystemTests/BuildOperationTests.swift @@ -86,10 +86,6 @@ fileprivate struct BuildOperationTests: CoreBasedTests { TestBuildConfiguration("Debug", buildSettings: [ "DYLIB_INSTALL_NAME_BASE": "$ORIGIN", "DYLIB_INSTALL_NAME_BASE[sdk=macosx*]": "@rpath", - - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", - "EXECUTABLE_PREFIX[sdk=windows*]": "", ]) ], buildPhases: [ @@ -99,13 +95,6 @@ fileprivate struct BuildOperationTests: CoreBasedTests { TestStandardTarget( "staticlib", type: .staticLibrary, - buildConfigurations: [ - TestBuildConfiguration("Debug", buildSettings: [ - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", - "EXECUTABLE_PREFIX[sdk=windows*]": "", - ]) - ], buildPhases: [ TestSourcesBuildPhase(["static.swift"]), ] @@ -271,10 +260,6 @@ fileprivate struct BuildOperationTests: CoreBasedTests { TestBuildConfiguration("Debug", buildSettings: [ "DYLIB_INSTALL_NAME_BASE": "$ORIGIN", "DYLIB_INSTALL_NAME_BASE[sdk=macosx*]": "@rpath", - - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", - "EXECUTABLE_PREFIX[sdk=windows*]": "", ]) ], buildPhases: [ @@ -284,13 +269,6 @@ fileprivate struct BuildOperationTests: CoreBasedTests { TestStandardTarget( "staticlib", type: .staticLibrary, - buildConfigurations: [ - TestBuildConfiguration("Debug", buildSettings: [ - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", - "EXECUTABLE_PREFIX[sdk=windows*]": "", - ]) - ], buildPhases: [ TestSourcesBuildPhase(["static.swift"]), ] @@ -414,10 +392,6 @@ fileprivate struct BuildOperationTests: CoreBasedTests { TestBuildConfiguration("Debug", buildSettings: [ "DYLIB_INSTALL_NAME_BASE": "$ORIGIN", "DYLIB_INSTALL_NAME_BASE[sdk=macosx*]": "@rpath", - - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", - "EXECUTABLE_PREFIX[sdk=windows*]": "", ]) ], buildPhases: [ @@ -546,7 +520,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { } } - @Test(.requireSDKs(.host), .skipHostOS(.macOS), .skipHostOS(.windows, "cannot find testing library")) + @Test(.requireSDKs(.host), .skipHostOS(.macOS)) func unitTestWithGeneratedEntryPoint() async throws { try await withTemporaryDirectory(removeTreeOnDeinit: false) { (tmpDir: Path) in let testProject = try await TestProject( @@ -582,7 +556,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { buildPhases: [ TestSourcesBuildPhase(), TestFrameworksBuildPhase([ - "MyTests.so" + TestBuildFile(.target("MyTests")) ]) ], dependencies: ["MyTests"] @@ -593,7 +567,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ "LD_RUNPATH_SEARCH_PATHS": "$(RPATH_ORIGIN)", - "LD_DYLIB_INSTALL_NAME": "MyTests.so" + "LD_DYLIB_INSTALL_NAME": "$(EXECUTABLE_NAME)" ]) ], buildPhases: [ @@ -604,7 +578,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { ], dependencies: [ "library" ], - productReferenceName: "MyTests.so" + productReferenceName: "$(EXECUTABLE_NAME)" ), TestStandardTarget( "library", @@ -612,11 +586,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ "LD_RUNPATH_SEARCH_PATHS": "$(RPATH_ORIGIN)", - "LD_DYLIB_INSTALL_NAME": "liblibrary.so", - - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", - "EXECUTABLE_PREFIX[sdk=windows*]": "", + "LD_DYLIB_INSTALL_NAME": "$(EXECUTABLE_NAME)", ]) ], buildPhases: [ @@ -670,7 +640,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { } } - @Test(.requireSDKs(.host), .skipHostOS(.macOS), .skipHostOS(.windows, "cannot find testing library")) + @Test(.requireSDKs(.host), .skipHostOS(.macOS)) func unitTestWithGeneratedEntryPoint_testabilityDisabled() async throws { try await withTemporaryDirectory(removeTreeOnDeinit: false) { (tmpDir: Path) in let testProject = try await TestProject( @@ -708,7 +678,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { buildPhases: [ TestSourcesBuildPhase(), TestFrameworksBuildPhase([ - "MyTests.so" + TestBuildFile(.target("MyTests")) ]) ], dependencies: ["MyTests"] @@ -719,7 +689,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ "LD_RUNPATH_SEARCH_PATHS": "$(RPATH_ORIGIN)", - "LD_DYLIB_INSTALL_NAME": "MyTests.so" + "LD_DYLIB_INSTALL_NAME": "$(EXECUTABLE_NAME)" ]) ], buildPhases: [ @@ -730,7 +700,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { ], dependencies: [ "library" ], - productReferenceName: "MyTests.so" + productReferenceName: "$(EXECUTABLE_NAME)" ), TestStandardTarget( "library", @@ -738,7 +708,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ "LD_RUNPATH_SEARCH_PATHS": "$(RPATH_ORIGIN)", - "LD_DYLIB_INSTALL_NAME": "liblibrary.so", + "LD_DYLIB_INSTALL_NAME": "$(EXECUTABLE_NAME)", // FIXME: Find a way to make these default "EXECUTABLE_PREFIX": "lib", diff --git a/Tests/SWBBuildSystemTests/SwiftCompilationCachingTests.swift b/Tests/SWBBuildSystemTests/SwiftCompilationCachingTests.swift index ff197e51..86c27282 100644 --- a/Tests/SWBBuildSystemTests/SwiftCompilationCachingTests.swift +++ b/Tests/SWBBuildSystemTests/SwiftCompilationCachingTests.swift @@ -155,7 +155,7 @@ fileprivate struct SwiftCompilationCachingTests: CoreBasedTests { TestStandardTarget( "Bar", type: .dynamicLibrary, - buildConfigurations: [TestBuildConfiguration("Debug", buildSettings: ["PRODUCT_NAME": "Bar", "EXECUTABLE_PREFIX": "lib"])], + buildConfigurations: [TestBuildConfiguration("Debug", buildSettings: ["PRODUCT_NAME": "Bar"])], buildPhases: [TestSourcesBuildPhase(["Bar.swift"])])]) let package = TestPackageProject( @@ -172,7 +172,7 @@ fileprivate struct SwiftCompilationCachingTests: CoreBasedTests { TestStandardTarget( "Foo", type: .dynamicLibrary, - buildConfigurations: [TestBuildConfiguration("Debug", buildSettings: ["PRODUCT_NAME": "Foo", "EXECUTABLE_PREFIX": "lib"])], + buildConfigurations: [TestBuildConfiguration("Debug", buildSettings: ["PRODUCT_NAME": "Foo"])], buildPhases: [ TestSourcesBuildPhase(["Foo.swift"]), TestFrameworksBuildPhase([TestBuildFile(.target("BarProduct"))])], diff --git a/Tests/SWBBuildSystemTests/SwiftDriverTests.swift b/Tests/SWBBuildSystemTests/SwiftDriverTests.swift index e872fd5f..2ec1008d 100644 --- a/Tests/SWBBuildSystemTests/SwiftDriverTests.swift +++ b/Tests/SWBBuildSystemTests/SwiftDriverTests.swift @@ -939,8 +939,6 @@ fileprivate struct SwiftDriverTests: CoreBasedTests { "BUILD_VARIANTS": "normal", "SWIFT_USE_INTEGRATED_DRIVER": "YES", "CODE_SIGNING_ALLOWED": "NO", - "EXECUTABLE_PREFIX": "lib", - "EXECUTABLE_PREFIX[sdk=windows*]": "", setting: "YES", ]) ], @@ -2958,7 +2956,7 @@ fileprivate struct SwiftDriverTests: CoreBasedTests { "DynamicLibrary", type: .dynamicLibrary, buildConfigurations: [ - TestBuildConfiguration("Debug", buildSettings: ["PRODUCT_NAME": "libDylib"]), + TestBuildConfiguration("Debug", buildSettings: ["PRODUCT_NAME": "Dylib"]), ], buildPhases: [ TestSourcesBuildPhase([ @@ -2979,7 +2977,7 @@ fileprivate struct SwiftDriverTests: CoreBasedTests { file <<< """ import Fwk - import libDylib + import Dylib @main public struct Tool { static func main() { _ = InternalStruct() @@ -3038,7 +3036,7 @@ fileprivate struct SwiftDriverTests: CoreBasedTests { try results.checkTaskFollows(linkToolTask, .matchTargetName("Fwk"), .matchRule(["SwiftEmitModule", "normal", "arm64e", "Emitting module for Fwk"])) try results.checkTaskFollows(linkToolTask, .matchTargetName("Fwk"), .matchRuleType("GenerateTAPI")) try results.checkTaskDoesNotFollow(linkToolTask, .matchTargetName("Fwk"), .matchRuleType("Ld")) - try results.checkTaskFollows(linkToolTask, .matchTargetName("DynamicLibrary"), .matchRule(["SwiftEmitModule", "normal", "arm64e", "Emitting module for libDylib"])) + try results.checkTaskFollows(linkToolTask, .matchTargetName("DynamicLibrary"), .matchRule(["SwiftEmitModule", "normal", "arm64e", "Emitting module for Dylib"])) try results.checkTaskFollows(linkToolTask, .matchTargetName("DynamicLibrary"), .matchRuleType("GenerateTAPI")) try results.checkTaskDoesNotFollow(linkToolTask, .matchTargetName("DynamicLibrary"), .matchRuleType("Ld")) } diff --git a/Tests/SWBCoreTests/TargetDependencyResolverTests.swift b/Tests/SWBCoreTests/TargetDependencyResolverTests.swift index d0b55948..4c2c5c1e 100644 --- a/Tests/SWBCoreTests/TargetDependencyResolverTests.swift +++ b/Tests/SWBCoreTests/TargetDependencyResolverTests.swift @@ -2735,7 +2735,7 @@ fileprivate enum TargetPlatformSpecializationMode { ], buildPhases: [ TestCopyFilesBuildPhase([ - "aTool", + TestBuildFile(.target("aTool")), ], destinationSubfolder: .frameworks), ] ) diff --git a/Tests/SWBGenericUnixPlatformTests/SWBGenericUnixPlatformTests.swift b/Tests/SWBGenericUnixPlatformTests/SWBGenericUnixPlatformTests.swift index 87e97a6e..80ed8eab 100644 --- a/Tests/SWBGenericUnixPlatformTests/SWBGenericUnixPlatformTests.swift +++ b/Tests/SWBGenericUnixPlatformTests/SWBGenericUnixPlatformTests.swift @@ -94,25 +94,15 @@ fileprivate struct GenerixUnixBuildOperationTests: CoreBasedTests { buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ "DYLIB_INSTALL_NAME_BASE": "$ORIGIN", - - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", ]) ], buildPhases: [ TestSourcesBuildPhase(["dynamic.c"]), ], - productReferenceName: "libdynamiclib.so" ), TestStandardTarget( "staticlib", type: .staticLibrary, - buildConfigurations: [ - TestBuildConfiguration("Debug", buildSettings: [ - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", - ]) - ], buildPhases: [ TestSourcesBuildPhase(["static.c"]), ] diff --git a/Tests/SWBQNXPlatformTests/SWBQNXPlatformTests.swift b/Tests/SWBQNXPlatformTests/SWBQNXPlatformTests.swift index bdce751c..ee7c2b14 100644 --- a/Tests/SWBQNXPlatformTests/SWBQNXPlatformTests.swift +++ b/Tests/SWBQNXPlatformTests/SWBQNXPlatformTests.swift @@ -67,9 +67,6 @@ fileprivate struct QNXBuildOperationTests: CoreBasedTests { buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ "DYLIB_INSTALL_NAME_BASE": "$ORIGIN", - - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", ]) ], buildPhases: [ @@ -80,12 +77,6 @@ fileprivate struct QNXBuildOperationTests: CoreBasedTests { TestStandardTarget( "staticlib", type: .staticLibrary, - buildConfigurations: [ - TestBuildConfiguration("Debug", buildSettings: [ - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", - ]) - ], buildPhases: [ TestSourcesBuildPhase(["static.c"]), ] diff --git a/Tests/SWBTaskConstructionTests/BuildActionTaskConstructionTests.swift b/Tests/SWBTaskConstructionTests/BuildActionTaskConstructionTests.swift index 20913228..02e465da 100644 --- a/Tests/SWBTaskConstructionTests/BuildActionTaskConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/BuildActionTaskConstructionTests.swift @@ -320,7 +320,7 @@ fileprivate struct BuildActionTaskConstructionTests: CoreBasedTests { await tester.checkBuild(runDestination: .macOS, buildRequest: buildRequest) { results in results.checkTarget("DynamicLibraryTarget") { target in // There should be one symlink task. - results.checkTask(.matchTarget(target), .matchRule(["SymLink", "/tmp/Test/aProject/build/Release/DynamicLibraryTarget.tbd", "../../../../aProject.dst/usr/local/lib/DynamicLibraryTarget.tbd"])) { _ in } + results.checkTask(.matchTarget(target), .matchRule(["SymLink", "/tmp/Test/aProject/build/Release/libDynamicLibraryTarget.tbd", "../../../../aProject.dst/usr/local/lib/libDynamicLibraryTarget.tbd"])) { _ in } results.checkTask(.matchTarget(target), .matchRuleType("GenerateTAPI")) { _ in } @@ -388,7 +388,7 @@ fileprivate struct BuildActionTaskConstructionTests: CoreBasedTests { await tester.checkBuild(BuildParameters(action: .installAPI, configuration: "Release", overrides: overrides), runDestination: .macOS) { results in results.checkTarget("DynamicLibraryTarget") { target in // There should be one symlink task. - results.checkTask(.matchTarget(target), .matchRule(["SymLink", "/tmp/Test/aProject/build/Release/DynamicLibraryTarget.tbd", "../../../../aProject.dst/usr/local/lib/DynamicLibraryTarget.tbd"])) { _ in } + results.checkTask(.matchTarget(target), .matchRule(["SymLink", "/tmp/Test/aProject/build/Release/libDynamicLibraryTarget.tbd", "../../../../aProject.dst/usr/local/lib/libDynamicLibraryTarget.tbd"])) { _ in } results.checkTask(.matchTarget(target), .matchRuleType("GenerateTAPI")) { _ in } diff --git a/Tests/SWBTaskConstructionTests/InstallAPITaskConstructionTests.swift b/Tests/SWBTaskConstructionTests/InstallAPITaskConstructionTests.swift index 10338052..c9c31f2b 100644 --- a/Tests/SWBTaskConstructionTests/InstallAPITaskConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/InstallAPITaskConstructionTests.swift @@ -90,10 +90,10 @@ fileprivate struct InstallAPITaskConstructionTests: CoreBasedTests { results.checkNoTask(.matchRuleType("CodeSign"), .matchRuleItemBasename("FwkNoPlist.tbd")) results.checkNoTask(.matchRuleType("GenerateTAPI"), .matchRuleItemBasename("FwkNoSrc.tbd")) results.checkNoTask(.matchRuleType("CodeSign"), .matchRuleItemBasename("FwkNoSrc.tbd")) - results.checkTask(.matchRuleType("CodeSign"), .matchRuleItemBasename("Dylib.tbd")) { _ in } - results.checkNoTask(.matchRuleType("GenerateTAPI"), .matchRuleItemBasename("DylibNoSrc.tbd")) - results.checkNoTask(.matchRuleType("CodeSign"), .matchRuleItemBasename("DylibNoSrc.tbd")) - results.checkNoTask(.matchRuleType("CodeSign"), .matchRuleItemBasename("Tool.tbd")) + results.checkTask(.matchRuleType("CodeSign"), .matchRuleItemBasename("libDylib.tbd")) { _ in } + results.checkNoTask(.matchRuleType("GenerateTAPI"), .matchRuleItemBasename("libDylibNoSrc.tbd")) + results.checkNoTask(.matchRuleType("CodeSign"), .matchRuleItemBasename("libDylibNoSrc.tbd")) + results.checkNoTask(.matchRuleType("CodeSign"), .matchRuleItemBasename("libTool.tbd")) } } @@ -671,7 +671,6 @@ fileprivate struct InstallAPITaskConstructionTests: CoreBasedTests { buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ "CODE_SIGN_IDENTITY": "-", - "EXECUTABLE_PREFIX": "lib", "PRODUCT_NAME": "$(TARGET_NAME)", "SUPPORTS_TEXT_BASED_API": "YES", "TAPI_EXEC": tapiToolPath.str, @@ -813,7 +812,6 @@ fileprivate struct InstallAPITaskConstructionTests: CoreBasedTests { TestFile("Core.c")]), buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ - "EXECUTABLE_PREFIX": "lib", "PRODUCT_NAME": "$(TARGET_NAME)", "SUPPORTS_TEXT_BASED_API": "YES", "TAPI_EXEC": tapiToolPath.str, @@ -955,7 +953,6 @@ fileprivate struct InstallAPITaskConstructionTests: CoreBasedTests { TestFile("Core.c")]), buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ - "EXECUTABLE_PREFIX": "lib", "PRODUCT_NAME": "$(TARGET_NAME)", "GENERATE_TEXT_BASED_STUBS": "YES", "SKIP_INSTALL": "NO"])], @@ -1002,7 +999,6 @@ fileprivate struct InstallAPITaskConstructionTests: CoreBasedTests { TestFile("Core.c")]), buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ - "EXECUTABLE_PREFIX": "lib", "PRODUCT_NAME": "$(TARGET_NAME)", "GENERATE_INFOPLIST_FILE": "YES", "GENERATE_TEXT_BASED_STUBS": "YES", @@ -1603,7 +1599,7 @@ fileprivate struct InstallAPITaskConstructionTests: CoreBasedTests { "builtin-Swift-Compilation-Requirements", "--", .suffix("swiftc"), .anySequence, "-emit-tbd", "-emit-tbd-path", .suffix("x86_64/Swift-API.tbd"), .anySequence, // Check we pass the TBD install name. - "-Xfrontend", "-tbd-install_name", "-Xfrontend", "/usr/local/lib/ProductName.dylib", + "-Xfrontend", "-tbd-install_name", "-Xfrontend", "/usr/local/lib/libProductName.dylib", // Check we pass the TBD dylib version flags "-Xfrontend", "-tbd-current-version", "-Xfrontend", "1", "-Xfrontend", "-tbd-compatibility-version", "-Xfrontend", "1", .anySequence, @@ -1618,7 +1614,7 @@ fileprivate struct InstallAPITaskConstructionTests: CoreBasedTests { } // Check that we generated correct TAPI installapi invocation. - results.checkTask(.matchRuleType("GenerateTAPI"), .matchRuleItemBasename("ProductName.tbd"), .matchTarget(target)) { task in + results.checkTask(.matchRuleType("GenerateTAPI"), .matchRuleItemBasename("libProductName.tbd"), .matchTarget(target)) { task in // check TAPI options. task.checkCommandLineMatches([ StringPattern.equal(tapiToolPath.str), "installapi", "--verify-mode=ErrorsOnly", .anySequence, @@ -1634,7 +1630,7 @@ fileprivate struct InstallAPITaskConstructionTests: CoreBasedTests { .anySequence, - "-o", "/tmp/ProjectName.dst/usr/local/lib/ProductName.tbd", + "-o", "/tmp/ProjectName.dst/usr/local/lib/libProductName.tbd", StringPattern.and(.prefix("-L/"), .contains(".xctoolchain/")), StringPattern.and(.prefix("-L/"), .suffix(".sdk/usr/lib/swift")), "-exclude-public-header", "/TEST/build/ProjectName.build/Debug/TargetName.build/DerivedSources/ProductName-Swift.h", diff --git a/Tests/SWBTaskConstructionTests/InstallTaskConstructionTests.swift b/Tests/SWBTaskConstructionTests/InstallTaskConstructionTests.swift index c0a1113f..46474d62 100644 --- a/Tests/SWBTaskConstructionTests/InstallTaskConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/InstallTaskConstructionTests.swift @@ -144,16 +144,16 @@ fileprivate struct InstallTaskConstructionTests: CoreBasedTests { results.checkTarget("PublicLibrary") { target in // There should be a symlink command for each build variant in the BUILT_PRODUCTS_DIR. - results.checkTask(.matchTarget(target), .matchRule(["SymLink", "/tmp/symroot/Release/BuiltProducts/MyLibrary.dylib", "../../../dstroot/usr/lib/MyLibrary.dylib"])) { task in - task.checkCommandLine(["/bin/ln", "-sfh", "../../../dstroot/usr/lib/MyLibrary.dylib", "/tmp/symroot/Release/BuiltProducts/MyLibrary.dylib"]) + results.checkTask(.matchTarget(target), .matchRule(["SymLink", "/tmp/symroot/Release/BuiltProducts/libMyLibrary.dylib", "../../../dstroot/usr/lib/libMyLibrary.dylib"])) { task in + task.checkCommandLine(["/bin/ln", "-sfh", "../../../dstroot/usr/lib/libMyLibrary.dylib", "/tmp/symroot/Release/BuiltProducts/libMyLibrary.dylib"]) } - results.checkTask(.matchTarget(target), .matchRule(["SymLink", "/tmp/symroot/Release/BuiltProducts/MyLibrary_profile.dylib", "../../../dstroot/usr/lib/MyLibrary_profile.dylib"])) { task in - task.checkCommandLine(["/bin/ln", "-sfh", "../../../dstroot/usr/lib/MyLibrary_profile.dylib", "/tmp/symroot/Release/BuiltProducts/MyLibrary_profile.dylib"]) + results.checkTask(.matchTarget(target), .matchRule(["SymLink", "/tmp/symroot/Release/BuiltProducts/libMyLibrary_profile.dylib", "../../../dstroot/usr/lib/libMyLibrary_profile.dylib"])) { task in + task.checkCommandLine(["/bin/ln", "-sfh", "../../../dstroot/usr/lib/libMyLibrary_profile.dylib", "/tmp/symroot/Release/BuiltProducts/libMyLibrary_profile.dylib"]) } // The copied-aside products should be at the INSTALL_PATH inside the SYMROOT. - results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/usr/lib/MyLibrary.dylib", "/tmp/dstroot/usr/lib/MyLibrary.dylib"])) { _ in } - results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/usr/lib/MyLibrary_profile.dylib", "/tmp/dstroot/usr/lib/MyLibrary_profile.dylib"])) { _ in } + results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/usr/lib/libMyLibrary.dylib", "/tmp/dstroot/usr/lib/libMyLibrary.dylib"])) { _ in } + results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/usr/lib/libMyLibrary_profile.dylib", "/tmp/dstroot/usr/lib/libMyLibrary_profile.dylib"])) { _ in } } results.checkTarget("LocalLibrary") { target in @@ -161,8 +161,8 @@ fileprivate struct InstallTaskConstructionTests: CoreBasedTests { results.checkNoTask(.matchTarget(target), .matchRuleItem("SymLink")) // The copied-aside products should be at the INSTALL_PATH inside the SYMROOT. - results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/usr/local/lib/MyLibrary.dylib", "/tmp/dstroot/usr/local/lib/MyLibrary.dylib"])) { _ in } - results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/usr/local/lib/MyLibrary_profile.dylib", "/tmp/dstroot/usr/local/lib/MyLibrary_profile.dylib"])) { _ in } + results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/usr/local/lib/libMyLibrary.dylib", "/tmp/dstroot/usr/local/lib/libMyLibrary.dylib"])) { _ in } + results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/usr/local/lib/libMyLibrary_profile.dylib", "/tmp/dstroot/usr/local/lib/libMyLibrary_profile.dylib"])) { _ in } } results.checkTarget("UninstalledLibrary") { target in @@ -170,8 +170,8 @@ fileprivate struct InstallTaskConstructionTests: CoreBasedTests { results.checkNoTask(.matchTarget(target), .matchRuleItem("SymLink")) // The copied-aside products should be inside UninstalledProducts inside the SYMROOT. - results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/UninstalledProducts/aProject/UninstalledLibrary/MyLibrary.dylib", "/tmp/objroot/UninstalledProducts/macosx/MyLibrary.dylib"])) { _ in } - results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/UninstalledProducts/aProject/UninstalledLibrary/MyLibrary_profile.dylib", "/tmp/objroot/UninstalledProducts/macosx/MyLibrary_profile.dylib"])) { _ in } + results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/UninstalledProducts/aProject/UninstalledLibrary/libMyLibrary.dylib", "/tmp/objroot/UninstalledProducts/macosx/libMyLibrary.dylib"])) { _ in } + results.checkTask(.matchTarget(target), .matchRule(["Copy", "/tmp/symroot/UninstalledProducts/aProject/UninstalledLibrary/libMyLibrary_profile.dylib", "/tmp/objroot/UninstalledProducts/macosx/libMyLibrary_profile.dylib"])) { _ in } } results.checkTarget("UninstalledTool") { target in diff --git a/Tests/SWBTaskConstructionTests/MergeableLibraryTests.swift b/Tests/SWBTaskConstructionTests/MergeableLibraryTests.swift index 4584f5d4..d3b73da3 100644 --- a/Tests/SWBTaskConstructionTests/MergeableLibraryTests.swift +++ b/Tests/SWBTaskConstructionTests/MergeableLibraryTests.swift @@ -227,7 +227,7 @@ fileprivate struct MergeableLibraryTests: CoreBasedTests { } results.checkTarget("DylibTarget1") { target in let targetName = target.target.name - let FULL_PRODUCT_NAME = "\(targetName).dylib" + let FULL_PRODUCT_NAME = "lib\(targetName).dylib" results.checkTask(.matchTarget(target), .matchRuleType("Ld")) { task in task.checkCommandLineContains([ ["clang"], @@ -428,7 +428,7 @@ fileprivate struct MergeableLibraryTests: CoreBasedTests { } results.checkTarget("DylibTarget1") { target in let targetName = target.target.name - let FULL_PRODUCT_NAME = "\(targetName).dylib" + let FULL_PRODUCT_NAME = "lib\(targetName).dylib" let INSTALL_PATH = "/usr/local/lib" results.checkTask(.matchTarget(target), .matchRuleType("Ld")) { task in task.checkCommandLineContains([ @@ -519,8 +519,8 @@ fileprivate struct MergeableLibraryTests: CoreBasedTests { results.checkTaskFollows(task, [.matchTarget(target), .matchRuleType("Copy"), .matchRuleItemBasename(FWK_FULL_PRODUCT_NAME)]) } } - results.checkNoTask(.matchTarget(target), .matchRuleType("Copy"), .matchRuleItemBasename("DylibTarget1.dylib")) - results.checkNoTask(.matchTarget(target), .matchRuleType("CodeSign"), .matchRuleItemBasename("DylibTarget1.dylib")) + results.checkNoTask(.matchTarget(target), .matchRuleType("Copy"), .matchRuleItemBasename("libDylibTarget1.dylib")) + results.checkNoTask(.matchTarget(target), .matchRuleType("CodeSign"), .matchRuleItemBasename("libDylibTarget1.dylib")) do { let fwkTargetName = "MergedFwkTarget" let FWK_FULL_PRODUCT_NAME = "\(fwkTargetName).framework" diff --git a/Tests/SWBTaskConstructionTests/PackageProductConstructionTests.swift b/Tests/SWBTaskConstructionTests/PackageProductConstructionTests.swift index 607a280b..036a461b 100644 --- a/Tests/SWBTaskConstructionTests/PackageProductConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/PackageProductConstructionTests.swift @@ -254,7 +254,7 @@ fileprivate struct PackageProductConstructionTests: CoreBasedTests { results.checkNoDiagnostics() results.checkTarget("DynamicJSON") { target in results.checkTask(.matchTarget(target), .matchRuleType("Ld")) { task in - task.checkCommandLineContains(["-o", "/tmp/aWorkspace/aProject/build/Debug/DynamicJSON.dylib", "/tmp/aWorkspace/Package/build/Package.build/Debug/SwiftyJSON.build/Objects-normal/x86_64/SwiftyJSON.swiftmodule"]) + task.checkCommandLineContains(["-o", "/tmp/aWorkspace/aProject/build/Debug/libDynamicJSON.dylib", "/tmp/aWorkspace/Package/build/Package.build/Debug/SwiftyJSON.build/Objects-normal/x86_64/SwiftyJSON.swiftmodule"]) task.checkCommandLineNoMatch([.any, "-Xlinker", "-add_ast_path", "-Xlinker", "/tmp/aWorkspace/aProject/build/aProject.build/Debug/DynamicJSON.build/Objects-normal/x86_64/DynamicJSON.swiftmodule", .any]) } @@ -278,13 +278,13 @@ fileprivate struct PackageProductConstructionTests: CoreBasedTests { results.checkTarget("DynamicJSON") { target in results.checkTask(.matchTarget(target), .matchRuleType("SymLink")) { task in - task.checkCommandLineContains(["../UninstalledProducts/macosx/DynamicJSON.dylib", "/tmp/aWorkspace/aProject/build/Debug/DynamicJSON.dylib"]) + task.checkCommandLineContains(["../UninstalledProducts/macosx/libDynamicJSON.dylib", "/tmp/aWorkspace/aProject/build/Debug/libDynamicJSON.dylib"]) } } results.checkTarget("DynamicUtility") { target in results.checkTask(.matchTarget(target), .matchRuleType("SymLink")) { task in - task.checkCommandLineContains(["../UninstalledProducts/macosx/DynamicUtility.dylib", "/tmp/aWorkspace/aProject/build/Debug/DynamicUtility.dylib"]) + task.checkCommandLineContains(["../UninstalledProducts/macosx/libDynamicUtility.dylib", "/tmp/aWorkspace/aProject/build/Debug/libDynamicUtility.dylib"]) } } } @@ -656,14 +656,14 @@ fileprivate struct PackageProductConstructionTests: CoreBasedTests { ) } - func findInput(for name: String, in tasks: GenericSequence) -> (any PlannedNode)? { + func findInput(for name: String, in tasks: GenericSequence, sourceLocation: SourceLocation = #_sourceLocation) -> (any PlannedNode)? { guard let task = tasks.filter({ $0.outputs.first?.path.basename == name }).first else { - Issue.record("could not find linker tasks for \(name)") + Issue.record("could not find linker tasks for \(name)", sourceLocation: sourceLocation) return nil } guard let input = task.inputs.filter({ $0.path.basename.hasSuffix("PackageLib.o") }).first else { - Issue.record("could not find linked package lib in linker task for \(name)") + Issue.record("could not find linked package lib in linker task for \(name)", sourceLocation: sourceLocation) return nil } @@ -719,7 +719,7 @@ fileprivate struct PackageProductConstructionTests: CoreBasedTests { for platform in allPlatforms { let dylibSuffix = core.sdkRegistry.lookup(platform.name)?.defaultVariant?.llvmTargetTripleVendor == "apple" ? "dylib" : "so" - guard let input = findInput(for: "\(platform.name)Lib.\(dylibSuffix)", in: tasks) else { + guard let input = findInput(for: "lib\(platform.name)Lib.\(dylibSuffix)", in: tasks) else { return } @@ -732,7 +732,7 @@ fileprivate struct PackageProductConstructionTests: CoreBasedTests { if macCatalystTarget != nil { // Check package got specialized correctly for MacCatalyst. - guard let input = findInput(for: "MacCatalystLib.dylib", in: tasks) else { + guard let input = findInput(for: "libMacCatalystLib.dylib", in: tasks) else { return // `findInput()` will already error if there's no matching task or input } #expect(input.path.str.hasSuffix("Debug\(MacCatalystInfo.publicSDKBuiltProductsDirSuffix)/PackageLib.o"), "incorrect linker input path for MacCatalyst: \(input.path.str)") diff --git a/Tests/SWBTaskConstructionTests/PostprocessingTaskConstructionTests.swift b/Tests/SWBTaskConstructionTests/PostprocessingTaskConstructionTests.swift index 85fd06e1..c430ec5a 100644 --- a/Tests/SWBTaskConstructionTests/PostprocessingTaskConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/PostprocessingTaskConstructionTests.swift @@ -74,11 +74,11 @@ fileprivate struct PostprocessingTaskConstructionTests: CoreBasedTests { for (buildVariant, task) in zip(buildVariants, tasks.sorted(by: \.identifier)) { let suffix = buildVariant == "normal" ? "" : "_\(buildVariant)" - task.checkRuleInfo(["SetOwnerAndGroup", "exampleUser:exampleGroup", "/tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib"]) - task.checkCommandLine(["/usr/sbin/chown", "-RH", "exampleUser:exampleGroup", "/tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib"]) + task.checkRuleInfo(["SetOwnerAndGroup", "exampleUser:exampleGroup", "/tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib"]) + task.checkCommandLine(["/usr/sbin/chown", "-RH", "exampleUser:exampleGroup", "/tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib"]) task.checkInputs([ - .path("/tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib"), + .path("/tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib"), .namePattern(.and(.prefix("target-"), .suffix("-Barrier-StripSymbols"))), .namePattern(.and(.prefix("target-"), .suffix("-will-sign"))), // Postprocessing tasks depend on the end phase nodes of earlier task producers. @@ -86,21 +86,21 @@ fileprivate struct PostprocessingTaskConstructionTests: CoreBasedTests { ]) task.checkOutputs([ - .path("/tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib"), - .name("SetOwner /tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib")]) + .path("/tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib"), + .name("SetOwner /tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib")]) } } results.checkTasks(.matchTarget(target), .matchRuleType("SetMode")) { tasks in for (buildVariant, task) in zip(buildVariants, tasks.sorted(by: \.identifier)) { let suffix = buildVariant == "normal" ? "" : "_\(buildVariant)" - task.checkRuleInfo(["SetMode", "u+w,go-w,a+rX", "/tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib"]) - task.checkCommandLine(["/bin/chmod", "-RH", "u+w,go-w,a+rX", "/tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib"]) + task.checkRuleInfo(["SetMode", "u+w,go-w,a+rX", "/tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib"]) + task.checkCommandLine(["/bin/chmod", "-RH", "u+w,go-w,a+rX", "/tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib"]) task.checkInputs([ // Set mode artificially orders itself relative to the chown task. - .path("/tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib"), - .name("SetOwner /tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib"), + .path("/tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib"), + .name("SetOwner /tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib"), .namePattern(.and(.prefix("target-"), .suffix("-Barrier-StripSymbols"))), .namePattern(.and(.prefix("target-"), .suffix("-will-sign"))), // Postprocessing tasks depend on the end phase nodes of earlier task producers. @@ -108,8 +108,8 @@ fileprivate struct PostprocessingTaskConstructionTests: CoreBasedTests { ]) task.checkOutputs([ - .path("/tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib"), - .name("SetMode /tmp/aProject.dst/usr/local/lib/Library\(suffix).dylib")]) + .path("/tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib"), + .name("SetMode /tmp/aProject.dst/usr/local/lib/libLibrary\(suffix).dylib")]) } } } diff --git a/Tests/SWBTaskConstructionTests/TaskConstructionTests.swift b/Tests/SWBTaskConstructionTests/TaskConstructionTests.swift index e9250240..c385e995 100644 --- a/Tests/SWBTaskConstructionTests/TaskConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/TaskConstructionTests.swift @@ -4975,7 +4975,7 @@ fileprivate struct TaskConstructionTests: CoreBasedTests { ], buildPhases: [ TestSourcesBuildPhase(["File.c"]), - TestFrameworksBuildPhase(["libStaticLib1.a"]), + TestFrameworksBuildPhase([TestBuildFile(.target("StaticLib1"))]), ], dependencies: ["StaticLib1"] ), @@ -4989,9 +4989,9 @@ fileprivate struct TaskConstructionTests: CoreBasedTests { buildPhases: [ TestSourcesBuildPhase(["File.c"]), TestFrameworksBuildPhase([ - "libDynamicLib1.dylib", + TestBuildFile(.target("DynamicLib1")), "Object.o", - TestBuildFile(.auto("libStaticLib2.a"), shouldLinkWeakly: true), + TestBuildFile(.target("StaticLib2"), shouldLinkWeakly: true), TestBuildFile(.auto("libAnotherStatic.a"), shouldLinkWeakly: false), TestBuildFile("Framework.framework", shouldLinkWeakly: true), ]), @@ -5624,7 +5624,8 @@ fileprivate struct TaskConstructionTests: CoreBasedTests { type: .commandLineTool, buildPhases: [ TestSourcesBuildPhase(["main.c"]), - TestFrameworksBuildPhase(["libCore.a", "libOther.a"])], + TestFrameworksBuildPhase([TestBuildFile(.target("Core")), TestBuildFile(.target("Other"))]) + ], dependencies: ["Core", "Other"]), TestStandardTarget( "Other", diff --git a/Tests/SWBTaskConstructionTests/UnitTestTaskConstructionTests.swift b/Tests/SWBTaskConstructionTests/UnitTestTaskConstructionTests.swift index 777d0f2f..d4e7ca43 100644 --- a/Tests/SWBTaskConstructionTests/UnitTestTaskConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/UnitTestTaskConstructionTests.swift @@ -355,7 +355,6 @@ fileprivate struct UnitTestTaskConstructionTests: CoreBasedTests { ]) ], dependencies: [], - productReferenceName: "$(EXCTABLE_NAME)" ), ]) let core = try await getCore() @@ -384,7 +383,7 @@ fileprivate struct UnitTestTaskConstructionTests: CoreBasedTests { ]) task.checkInputs([ .pathPattern(.suffix("UnitTestTarget.LinkFileList")), - .pathPattern(.or(.suffix("UnitTestTarget.so"), .suffix("UnitTestTarget.dll"))), + .pathPattern(.or(.suffix("/libUnitTestTarget.so"), .suffix("\\UnitTestTarget.dll"))), .namePattern(.any), .namePattern(.any), ]) diff --git a/Tests/SWBWebAssemblyPlatformTests/SWBWebAssemblyPlatformTests.swift b/Tests/SWBWebAssemblyPlatformTests/SWBWebAssemblyPlatformTests.swift index 3f1eddc1..1abed039 100644 --- a/Tests/SWBWebAssemblyPlatformTests/SWBWebAssemblyPlatformTests.swift +++ b/Tests/SWBWebAssemblyPlatformTests/SWBWebAssemblyPlatformTests.swift @@ -69,12 +69,6 @@ fileprivate struct SWBWebAssemblyPlatformTests: CoreBasedTests { TestStandardTarget( "staticlib", type: .staticLibrary, - buildConfigurations: [ - TestBuildConfiguration("Debug", buildSettings: [ - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", - ]) - ], buildPhases: [ TestSourcesBuildPhase(["static.swift"]), ] @@ -182,12 +176,6 @@ fileprivate struct SWBWebAssemblyPlatformTests: CoreBasedTests { TestStandardTarget( "Cstaticlib", type: .staticLibrary, - buildConfigurations: [ - TestBuildConfiguration("Debug", buildSettings: [ - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", - ]) - ], buildPhases: [ TestSourcesBuildPhase(["static1.c", "static2.cpp"]), ]