From cdcfe04aadaa5e3e20c0758d60afa587fa4337c6 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 when using searched libs - remove the platform specifics from computeLibraryArgs (we cannot assume that all libraries have a lib prefix and what there suffix is.) So we now use the FileType prefix and remove any suffix when using searchPathFlagsForLD, moving this into the LinkerSpec.LibrarySpecifier extension, this allows for proper searching of libraries, and linking of dynamic libraries (especially on Windows). --- .../SpecImplementations/LinkerSpec.swift | 5 +- .../SWBCore/SpecImplementations/Specs.swift | 6 +- .../Tools/LinkerTools.swift | 89 +++++++---------- .../SWBGenericUnixPlatform/Specs/Unix.xcspec | 10 ++ .../SourcesTaskProducer.swift | 32 +++++-- .../RunDestinationTestSupport.swift | 7 +- .../Specs/ProductTypes.xcspec | 1 + .../Specs/StandardFileTypes.xcspec | 2 + Sources/SWBWindowsPlatform/Plugin.swift | 2 +- .../SWBWindowsPlatform/Specs/Windows.xcspec | 25 +++++ .../SWBAndroidPlatformTests.swift | 9 -- .../BuildDependencyInfoTests.swift | 6 -- .../BuildOperationTests.swift | 96 +++++++------------ .../CustomTaskBuildOperationTests.swift | 2 +- Tests/SWBBuildSystemTests/LinkerTests.swift | 3 +- .../SwiftCompilationCachingTests.swift | 4 +- .../SwiftDriverTests.swift | 8 +- Tests/SWBCoreTests/CommandLineSpecTests.swift | 9 +- .../SWBGenericUnixPlatformTests.swift | 10 -- .../SWBQNXPlatformTests.swift | 9 -- .../BuildActionTaskConstructionTests.swift | 4 +- .../InstallAPITaskConstructionTests.swift | 18 ++-- .../InstallTaskConstructionTests.swift | 20 ++-- .../MergeableLibraryTests.swift | 8 +- .../PackageProductConstructionTests.swift | 16 ++-- .../PostprocessingTaskConstructionTests.swift | 22 ++--- .../UnitTestTaskConstructionTests.swift | 3 +- .../SWBWebAssemblyPlatformTests.swift | 12 --- 28 files changed, 206 insertions(+), 232 deletions(-) diff --git a/Sources/SWBCore/SpecImplementations/LinkerSpec.swift b/Sources/SWBCore/SpecImplementations/LinkerSpec.swift index 5d728619..4c222862 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], prefixes: [String] = [], 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,7 @@ open class LinkerSpec : CommandLineToolSpec, @unchecked Sendable { self.dsymPath = dsymPath self.xcframeworkSourcePath = xcframeworkSourcePath self.privacyFile = privacyFile + self.libPrefix = prefixes.first } } diff --git a/Sources/SWBCore/SpecImplementations/Specs.swift b/Sources/SWBCore/SpecImplementations/Specs.swift index cb8cf844..d7c3b410 100644 --- a/Sources/SWBCore/SpecImplementations/Specs.swift +++ b/Sources/SWBCore/SpecImplementations/Specs.swift @@ -301,6 +301,9 @@ public class FileTypeSpec : Spec, SpecType, @unchecked Sendable { /// Returns `true` if the `isWrapperFolder` value is set in the XCSpec for the file spec. public let isWrapper: Bool + /// Returns any common prefix this file may have (currently used when specifying searched libraries to linker) + public let prefixes: [String] + required init(_ parser: SpecParser, _ basedOnSpec: Spec?) { let basedOnFileTypeSpec = basedOnSpec as? FileTypeSpec ?? nil @@ -318,8 +321,8 @@ public class FileTypeSpec : Spec, SpecType, @unchecked Sendable { self.isEmbeddableInProduct = parser.parseBool("IsEmbeddable") ?? false self.validateOnCopy = parser.parseBool("ValidateOnCopy") ?? false self.codeSignOnCopy = parser.parseBool("CodeSignOnCopy") ?? false - self.isWrapper = parser.parseBool("IsWrapperFolder") ?? false + self.prefixes = parser.parseStringList("Prefix") ?? [] // Parse and ignore keys we have no use for. // @@ -358,7 +361,6 @@ public class FileTypeSpec : Spec, SpecType, @unchecked Sendable { parser.parseStringList("MIMETypes") parser.parseString("Permissions") parser.parseString("PlistStructureDefinition") - parser.parseStringList("Prefix") parser.parseBool("RemoveHeadersOnCopy") parser.parseBool("RequiresHardTabs") parser.parseString("UTI") diff --git a/Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift b/Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift index 8c8e6bc3..5824aae0 100644 --- a/Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift +++ b/Sources/SWBCore/SpecImplementations/Tools/LinkerTools.swift @@ -1289,41 +1289,15 @@ 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 + let args = specifier.searchPathFlagsForLd() + if !args.isEmpty { // no search args, fallback to absolute path to library + return (args, []) + } } - 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 +1533,44 @@ 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 let prefix = libPrefix, path.basename.hasPrefix(prefix) { + strippedName = Path(path.basename).withoutSuffix.withoutPrefix(prefix) + } else { + if libPrefix != nil { // we need a prefix for linking with search paths + return [] // this will fallback to using absolute paths + } + 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,15 +1707,17 @@ 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")] - } - else { - // Locate using an absolute path: Add the path as an option and as an input to the task. - inputPaths.append(specifier.path) - return [specifier.path.str] + let basename = specifier.path.basename + let expectedPrefix = specifier.libPrefix ?? "lib" + if basename.hasPrefix(expectedPrefix) { + return ["-l" + Path(basename).withoutSuffix.withoutPrefix(expectedPrefix)] + } } + // Locate using an absolute path: Add the path as an option and as an input to the task. + inputPaths.append(specifier.path) + return [specifier.path.str] case .object: // Object files are added to linker inputs in the sources task producer and so end up in the link-file-list. diff --git a/Sources/SWBGenericUnixPlatform/Specs/Unix.xcspec b/Sources/SWBGenericUnixPlatform/Specs/Unix.xcspec index 446d925b..bb95f962 100644 --- a/Sources/SWBGenericUnixPlatform/Specs/Unix.xcspec +++ b/Sources/SWBGenericUnixPlatform/Specs/Unix.xcspec @@ -91,4 +91,14 @@ IconNamePrefix = "TargetPlugin"; DefaultTargetName = "Object File"; }, + { + Domain = generic-unix; + Type = FileType; + Identifier = compiled.mach-o.dylib; + BasedOn = compiled.mach-o; + Prefix = (lib); + Extensions = (so); + IsLibrary = YES; + IsDynamicLibrary = YES; + } ) diff --git a/Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift b/Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift index c8e6296f..2b3a3d13 100644 --- a/Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift +++ b/Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift @@ -507,6 +507,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F useSearchPaths: useSearchPaths, swiftModulePaths: swiftModulePaths, swiftModuleAdditionalLinkerArgResponseFilePaths: swiftModuleAdditionalLinkerArgResponseFilePaths, + prefixes: fileType.prefixes, privacyFile: privacyFile ) } else if fileType.conformsTo(context.lookupFileType(identifier: "compiled.mach-o.dylib")!) { @@ -517,6 +518,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F useSearchPaths: useSearchPaths, swiftModulePaths: [:], swiftModuleAdditionalLinkerArgResponseFilePaths: [:], + prefixes: fileType.prefixes, privacyFile: privacyFile ) } else if fileType.conformsTo(context.lookupFileType(identifier: "sourcecode.text-based-dylib-definition")!) { @@ -527,17 +529,18 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F useSearchPaths: useSearchPaths, swiftModulePaths: [:], swiftModuleAdditionalLinkerArgResponseFilePaths: [:], + prefixes: fileType.prefixes, privacyFile: privacyFile ) } else if fileType.conformsTo(context.lookupFileType(identifier: "wrapper.framework")!) { - func kindFromSettings(_ settings: Settings) -> LinkerSpec.LibrarySpecifier.Kind? { + func kindFromSettings(_ settings: Settings) -> (kind: LinkerSpec.LibrarySpecifier.Kind, prefixes: [String])? { switch settings.globalScope.evaluate(BuiltinMacros.MACH_O_TYPE) { case "staticlib": - return .static + return (.static, context.lookupFileType(identifier: "archive.ar")?.prefixes ?? []) case "mh_dylib": - return .dynamic + return (.dynamic, context.lookupFileType(identifier: "compiled.mach-o.dylib")?.prefixes ?? []) case "mh_object": - return .object + return (.object, []) default: return nil } @@ -547,9 +550,11 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F let path: Path let dsymPath: Path? let topLevelItemPath: Path? + let prefixes: [String] if let settingsForRef, let presumedKind = kindFromSettings(settingsForRef), !useSearchPaths { // If we have a Settings from a cross-project reference, use the _actual_ library path. This prevents downstream code from reconstituting the framework path by joining the framework path with the basename of the framework, which won't be correct for deep frameworks which also need the Versions/A path component. - kind = presumedKind + kind = presumedKind.kind + prefixes = presumedKind.prefixes path = settingsForRef.globalScope.evaluate(BuiltinMacros.TARGET_BUILD_DIR).join(settingsForRef.globalScope.evaluate(BuiltinMacros.EXECUTABLE_PATH)).normalize() topLevelItemPath = absolutePath if shouldGenerateDSYM(settingsForRef.globalScope) { @@ -563,6 +568,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F path = absolutePath topLevelItemPath = nil dsymPath = nil + prefixes = [] } return LinkerSpec.LibrarySpecifier( @@ -572,6 +578,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F useSearchPaths: useSearchPaths, swiftModulePaths: [:], swiftModuleAdditionalLinkerArgResponseFilePaths: [:], + prefixes: prefixes, topLevelItemPath: topLevelItemPath, dsymPath: dsymPath, privacyFile: privacyFile @@ -581,7 +588,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 @@ -621,10 +628,16 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F } let libraryKind: LinkerSpec.LibrarySpecifier.Kind + let prefixes: [String] switch library.libraryType { - case .framework: libraryKind = .framework; break - case .dynamicLibrary: libraryKind = .dynamic; break - case .staticLibrary: libraryKind = .static; break + case .framework: libraryKind = .framework; prefixes = [] + case .dynamicLibrary: + libraryKind = .dynamic; + prefixes = context.lookupFileType(identifier: "compiled.mach-o.dylib")?.prefixes ?? [] + case .staticLibrary: + libraryKind = .static + prefixes = context.lookupFileType(identifier: "archive.ar")?.prefixes ?? [] + break case let .unknown(fileExtension): // An error of type this type should have already been manifested. assertionFailure("unknown xcframework type: \(fileExtension)") @@ -651,6 +664,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F useSearchPaths: useSearchPaths, swiftModulePaths: [:], swiftModuleAdditionalLinkerArgResponseFilePaths: [:], + prefixes: prefixes, explicitDependencies: outputFilePaths, xcframeworkSourcePath: xcframeworkPath, privacyFile: nil diff --git a/Sources/SWBTestSupport/RunDestinationTestSupport.swift b/Sources/SWBTestSupport/RunDestinationTestSupport.swift index 9041f82d..832e1009 100644 --- a/Sources/SWBTestSupport/RunDestinationTestSupport.swift +++ b/Sources/SWBTestSupport/RunDestinationTestSupport.swift @@ -320,7 +320,7 @@ extension RunDestinationInfo { /// An `Environment` object with `PATH` or `LD_LIBRARY_PATH` set appropriately pointing into the toolchain to be able to run a built Swift binary in tests. /// /// - note: On macOS, the OS provided Swift runtime is used, so `DYLD_LIBRARY_PATH` is never set for Mach-O destinations. - package func hostRuntimeEnvironment(_ core: Core, initialEnvironment: Environment = Environment()) -> Environment { + package func hostRuntimeEnvironment(_ core: Core, initialEnvironment: Environment = Environment()) throws -> Environment { var environment = initialEnvironment guard let toolchain = core.toolchainRegistry.defaultToolchain else { return environment @@ -329,7 +329,10 @@ extension RunDestinationInfo { case .elf: environment.prependPath(key: "LD_LIBRARY_PATH", value: toolchain.path.join("usr/lib/swift/\(platform)").str) case .pe: - environment.prependPath(key: .path, value: core.developerPath.path.join("Runtimes").join(toolchain.version.description).join("usr/bin").str) + let currentPath = Environment.current[.path] ?? "" + let runtimePath = core.developerPath.path.join("Runtimes").join(toolchain.version.description).join("usr/bin").str + let newPath = currentPath.isEmpty ? "\(runtimePath)" : "\(runtimePath);\(currentPath)" + environment[.path] = newPath case .macho: // Fall back to the OS provided Swift runtime break 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/SWBUniversalPlatform/Specs/StandardFileTypes.xcspec b/Sources/SWBUniversalPlatform/Specs/StandardFileTypes.xcspec index 6afa5833..895169a5 100644 --- a/Sources/SWBUniversalPlatform/Specs/StandardFileTypes.xcspec +++ b/Sources/SWBUniversalPlatform/Specs/StandardFileTypes.xcspec @@ -903,6 +903,7 @@ Class = PBXMachOFileType; BasedOn = compiled.mach-o; Extensions = (dylib); + Prefix = (lib); IsLibrary = YES; IsDynamicLibrary = YES; CodeSignOnCopy = YES; @@ -939,6 +940,7 @@ Identifier = sourcecode.text-based-dylib-definition; BasedOn = sourcecode; Extensions = (tbd); + Prefix = (lib); IsLibrary = YES; IsDynamicLibrary = YES; CodeSignOnCopy = YES; 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/Sources/SWBWindowsPlatform/Specs/Windows.xcspec b/Sources/SWBWindowsPlatform/Specs/Windows.xcspec index 3ed0fccb..f4bcbfa8 100644 --- a/Sources/SWBWindowsPlatform/Specs/Windows.xcspec +++ b/Sources/SWBWindowsPlatform/Specs/Windows.xcspec @@ -48,6 +48,7 @@ Identifier = com.apple.product-type.bundle.unit-test; BasedOn = com.apple.product-type.library.dynamic; DefaultBuildProperties = { + ENABLE_TESTING_SEARCH_PATHS = YES; // Index store data is required to discover XCTest tests COMPILER_INDEX_STORE_ENABLE = YES; SWIFT_INDEX_STORE_ENABLE = YES; @@ -87,6 +88,7 @@ BasedOn = default:com.apple.product-type.library.dynamic; HasInfoPlist = NO; DefaultBuildProperties = { + EXECUTABLE_PREFIX = ""; PUBLIC_HEADERS_FOLDER_PATH = ""; PRIVATE_HEADERS_FOLDER_PATH = ""; }; @@ -111,4 +113,27 @@ Identifier = org.swift.product-type.common.object; BasedOn = com.apple.product-type.library.static; }, + + { + Domain = windows; + Type = FileType; + Identifier = archive.ar; + BasedOn = archive; + Extensions = (lib); + Prefix = (); + IsLibrary = YES; + IsStaticLibrary = YES; + ContainsNativeCode = YES; + }, + + { + Domain = windows; + Type = FileType; + Identifier = compiled.mach-o.dylib; + BasedOn = compiled.mach-o; + Prefix = (); + Extensions = (dll); + IsLibrary = YES; + IsDynamicLibrary = YES; + } ) diff --git a/Tests/SWBAndroidPlatformTests/SWBAndroidPlatformTests.swift b/Tests/SWBAndroidPlatformTests/SWBAndroidPlatformTests.swift index 6e3a3129..efde5c17 100644 --- a/Tests/SWBAndroidPlatformTests/SWBAndroidPlatformTests.swift +++ b/Tests/SWBAndroidPlatformTests/SWBAndroidPlatformTests.swift @@ -70,9 +70,6 @@ fileprivate struct AndroidBuildOperationTests: CoreBasedTests { buildConfigurations: [ TestBuildConfiguration("Debug", buildSettings: [ "DYLIB_INSTALL_NAME_BASE": "$ORIGIN", - - // FIXME: Find a way to make these default - "EXECUTABLE_PREFIX": "lib", ]) ], buildPhases: [ @@ -83,12 +80,6 @@ fileprivate struct AndroidBuildOperationTests: 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/SWBBuildServiceTests/BuildDependencyInfoTests.swift b/Tests/SWBBuildServiceTests/BuildDependencyInfoTests.swift index 0883a288..94dd09a7 100644 --- a/Tests/SWBBuildServiceTests/BuildDependencyInfoTests.swift +++ b/Tests/SWBBuildServiceTests/BuildDependencyInfoTests.swift @@ -112,12 +112,6 @@ import Foundation TestStandardTarget( "DylibTarget", type: .dynamicLibrary, - buildConfigurations: [ - TestBuildConfiguration("Config", - buildSettings: [ - "EXECUTABLE_PREFIX": "lib", - ]), - ], buildPhases: [ TestSourcesBuildPhase([ "DylibClass.swift", diff --git a/Tests/SWBBuildSystemTests/BuildOperationTests.swift b/Tests/SWBBuildSystemTests/BuildOperationTests.swift index 556c0783..0f68291d 100644 --- a/Tests/SWBBuildSystemTests/BuildOperationTests.swift +++ b/Tests/SWBBuildSystemTests/BuildOperationTests.swift @@ -86,29 +86,20 @@ 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: [ TestSourcesBuildPhase(["dynamic.swift"]), - ] + ], + productReferenceName: "$(EXECUTABLE_NAME)", ), 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"]), - ] + ], + productReferenceName: "$(EXECUTABLE_NAME)", ), ]) let core = try await getCore() @@ -271,29 +262,20 @@ 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: [ TestSourcesBuildPhase(["dynamic.swift"]), - ] + ], + productReferenceName: "$(EXECUTABLE_NAME)", ), 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"]), - ] + ], + productReferenceName: "$(EXECUTABLE_NAME)", ), ]) let core = try await getCore() @@ -414,29 +396,20 @@ 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: [ TestSourcesBuildPhase(["dynamic.swift"]), - ] + ], + productReferenceName: "$(EXECUTABLE_NAME)", ), 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"]), - ] + ], + productReferenceName: "$(EXECUTABLE_NAME)", ), ]) let core = try await getCore() @@ -546,7 +519,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 +555,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { buildPhases: [ TestSourcesBuildPhase(), TestFrameworksBuildPhase([ - "MyTests.so" + TestBuildFile(.target("MyTests")) ]) ], dependencies: ["MyTests"] @@ -593,7 +566,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 +577,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { ], dependencies: [ "library" ], - productReferenceName: "MyTests.so" + productReferenceName: "$(EXECUTABLE_NAME)" ), TestStandardTarget( "library", @@ -612,16 +585,13 @@ 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: [ TestSourcesBuildPhase(["library.swift"]), ], + productReferenceName: "$(EXECUTABLE_NAME)", ) ]) let core = try await getCore() @@ -656,21 +626,23 @@ fileprivate struct BuildOperationTests: CoreBasedTests { try await tester.checkBuild(runDestination: destination, persistent: true) { results in results.checkNoErrors() - let environment = destination.hostRuntimeEnvironment(core) + let environment = try destination.hostRuntimeEnvironment(core) do { let executionResult = try await Process.getOutput(url: URL(fileURLWithPath: projectDir.join("build").join("Debug\(destination.builtProductsDirSuffix)").join(core.hostOperatingSystem.imageFormat.executableName(basename: "UnitTestRunner")).str), arguments: [], environment: environment) + #expect(executionResult.exitStatus == .exit(0)) #expect(String(decoding: executionResult.stdout, as: UTF8.self).contains("Executed 1 test")) } do { let executionResult = try await Process.getOutput(url: URL(fileURLWithPath: projectDir.join("build").join("Debug\(destination.builtProductsDirSuffix)").join(core.hostOperatingSystem.imageFormat.executableName(basename: "UnitTestRunner")).str), arguments: ["--testing-library", "swift-testing"], environment: environment) + #expect(executionResult.exitStatus == .exit(0)) #expect(String(decoding: executionResult.stderr, as: UTF8.self).contains("Test run with 1 test ")) } } } } - @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 +680,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { buildPhases: [ TestSourcesBuildPhase(), TestFrameworksBuildPhase([ - "MyTests.so" + TestBuildFile(.target("MyTests")) ]) ], dependencies: ["MyTests"] @@ -719,7 +691,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 +702,7 @@ fileprivate struct BuildOperationTests: CoreBasedTests { ], dependencies: [ "library" ], - productReferenceName: "MyTests.so" + productReferenceName: "$(EXECUTABLE_NAME)" ), TestStandardTarget( "library", @@ -738,16 +710,13 @@ 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: [ TestSourcesBuildPhase(["library.swift"]), ], + productReferenceName: "$(EXECUTABLE_NAME)", ) ]) let core = try await getCore() @@ -783,15 +752,21 @@ fileprivate struct BuildOperationTests: CoreBasedTests { results.checkWarning(.prefix("Skipping XCTest discovery for 'MyTests' because it was not built for testing")) results.checkNoErrors() - let environment = destination.hostRuntimeEnvironment(core) + let environment = try destination.hostRuntimeEnvironment(core) do { let executionResult = try await Process.getOutput(url: URL(fileURLWithPath: projectDir.join("build").join("Debug\(destination.builtProductsDirSuffix)").join(core.hostOperatingSystem.imageFormat.executableName(basename: "UnitTestRunner")).str), arguments: [], environment: environment) + #expect(executionResult.exitStatus == .exit(0)) #expect(String(decoding: executionResult.stdout, as: UTF8.self).contains("Executed 0 tests")) } do { let executionResult = try await Process.getOutput(url: URL(fileURLWithPath: projectDir.join("build").join("Debug\(destination.builtProductsDirSuffix)").join(core.hostOperatingSystem.imageFormat.executableName(basename: "UnitTestRunner")).str), arguments: ["--testing-library", "swift-testing"], environment: environment) - #expect(String(decoding: executionResult.stderr, as: UTF8.self).contains("Test run with 1 test ")) + withKnownIssue("On windows the test output indicates no tests ran, needs investigation") { + #expect(executionResult.exitStatus == .exit(0)) + #expect(String(decoding: executionResult.stderr, as: UTF8.self).contains("Test run with 1 test ")) + } when: { + core.hostOperatingSystem == .windows + } } } } @@ -4732,7 +4707,6 @@ That command depends on command in Target 'agg2' (project \'aProject\'): script "Debug", buildSettings: [ "EXECUTABLE_EXTENSION": "dylib", - "EXECUTABLE_PREFIX": "lib", "CODE_SIGN_IDENTITY": "-", "CODE_SIGNING_ALLOWED": "YES", "LD_DYLIB_INSTALL_NAME": "@rpath/libTool.dylib", diff --git a/Tests/SWBBuildSystemTests/CustomTaskBuildOperationTests.swift b/Tests/SWBBuildSystemTests/CustomTaskBuildOperationTests.swift index 736b48d2..e92f796c 100644 --- a/Tests/SWBBuildSystemTests/CustomTaskBuildOperationTests.swift +++ b/Tests/SWBBuildSystemTests/CustomTaskBuildOperationTests.swift @@ -29,7 +29,7 @@ fileprivate struct CustomTaskBuildOperationTests: CoreBasedTests { try await withTemporaryDirectory { tmpDir in let destination: RunDestinationInfo = .host let core = try await getCore() - let environment = destination.hostRuntimeEnvironment(core) + let environment = try destination.hostRuntimeEnvironment(core) let testProject = TestProject( "aProject", diff --git a/Tests/SWBBuildSystemTests/LinkerTests.swift b/Tests/SWBBuildSystemTests/LinkerTests.swift index 8991b51e..ed6fa8cd 100644 --- a/Tests/SWBBuildSystemTests/LinkerTests.swift +++ b/Tests/SWBBuildSystemTests/LinkerTests.swift @@ -223,7 +223,8 @@ fileprivate struct LinkerTests: CoreBasedTests { TestSourcesBuildPhase([ "library.swift" ]) - ] + ], + productReferenceName: "$(EXECUTABLE_NAME)" ), ]) let tester = try await BuildOperationTester(getCore(), testProject, simulated: false) 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 facdb73a..06e9e7d8 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/CommandLineSpecTests.swift b/Tests/SWBCoreTests/CommandLineSpecTests.swift index fa1c49e1..a48f711b 100644 --- a/Tests/SWBCoreTests/CommandLineSpecTests.swift +++ b/Tests/SWBCoreTests/CommandLineSpecTests.swift @@ -1346,23 +1346,30 @@ import SWBMacro for useSearchPaths in [true, false] { let searchPathString = useSearchPaths ? "search" : "abs" for mode in LinkerSpec.LibrarySpecifier.Mode.allCases { + let prefixes: [String] let suffix = "_\(mode)_\(searchPathString)" let filePath: Path switch kind { case .static: filePath = Path.root.join("usr/lib/libfoo\(suffix).a") + prefixes = producer.lookupFileType(identifier: "archive.ar")?.prefixes ?? [] case .dynamic: filePath = Path.root.join("usr/lib/libbar\(suffix).dylib") + prefixes = producer.lookupFileType(identifier: "compiled.mach-o.dylib")?.prefixes ?? [] case .textBased: filePath = Path.root.join("usr/lib/libbaz\(suffix).tbd") + prefixes = producer.lookupFileType(identifier: "sourcecode.text-based-dylib-definition")?.prefixes ?? [] case .framework: filePath = Path.root.join("tmp/Foo\(suffix).framework") + prefixes = [] case .object: + prefixes = [] continue case .objectLibrary: + prefixes = [] continue } - result.append(LinkerSpec.LibrarySpecifier(kind: kind, path: filePath, mode: mode, useSearchPaths: useSearchPaths, swiftModulePaths: [:], swiftModuleAdditionalLinkerArgResponseFilePaths: [:])) + result.append(LinkerSpec.LibrarySpecifier(kind: kind, path: filePath, mode: mode, useSearchPaths: useSearchPaths, swiftModulePaths: [:], swiftModuleAdditionalLinkerArgResponseFilePaths: [:], prefixes: prefixes)) } } return result 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 6c9371a9..e30629c4 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/UnitTestTaskConstructionTests.swift b/Tests/SWBTaskConstructionTests/UnitTestTaskConstructionTests.swift index 74349f70..4b42e69b 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"]), ]