diff --git a/Generator/Sources/CodeWriters/CMake/CMakeListsWriter.swift b/Generator/Sources/CodeWriters/CMake/CMakeListsWriter.swift index f1f6bf4..a999400 100644 --- a/Generator/Sources/CodeWriters/CMake/CMakeListsWriter.swift +++ b/Generator/Sources/CodeWriters/CMake/CMakeListsWriter.swift @@ -23,8 +23,8 @@ public final class CMakeListsWriter { output.beginLine() argument.write(to: &output) } + output.write(")") } - output.write(")", endLine: true) } } diff --git a/Generator/Sources/SwiftWinRT/BuildSystemOptions.swift b/Generator/Sources/SwiftWinRT/BuildSystemOptions.swift index 188b4f2..6fa2f75 100644 --- a/Generator/Sources/SwiftWinRT/BuildSystemOptions.swift +++ b/Generator/Sources/SwiftWinRT/BuildSystemOptions.swift @@ -6,7 +6,8 @@ struct SPMOptions { public let excludeCMakeLists: Bool public func getLibraryName(moduleName: String) -> String { - "\(libraryPrefix)\(module)\(librarySuffix)" + guard !libraryPrefix.isEmpty || !librarySuffix.isEmpty else { return moduleName } + return "\(libraryPrefix)\(moduleName)\(librarySuffix)" } } @@ -16,6 +17,7 @@ struct CMakeOptions { public let dynamicLibraries: Bool public func getTargetName(moduleName: String) -> String { - "\(targetPrefix)\(module)\(targetSuffix)" + guard !targetPrefix.isEmpty || !targetSuffix.isEmpty else { return moduleName } + return "\(targetPrefix)\(moduleName)\(targetSuffix)" } } \ No newline at end of file diff --git a/Generator/Sources/SwiftWinRT/Writing/SwiftPackageFile.swift b/Generator/Sources/SwiftWinRT/Writing/SwiftPackageFile.swift index 436eeee..005ad4d 100644 --- a/Generator/Sources/SwiftWinRT/Writing/SwiftPackageFile.swift +++ b/Generator/Sources/SwiftWinRT/Writing/SwiftPackageFile.swift @@ -62,7 +62,9 @@ func writeSwiftPackageFile(_ projection: Projection, spmOptions: SPMOptions, toP // Create products for the projections and the ABI package.products.append(moduleProduct) - package.products.append(.library(name: module.abiModuleName, type: .static, targets: [abiModuleTarget.name])) + package.products.append(.library( + name: spmOptions.getLibraryName(moduleName: module.abiModuleName), + type: .static, targets: [abiModuleTarget.name])) } if spmOptions.excludeCMakeLists { diff --git a/Generator/Sources/SwiftWinRT/writeProjectionFiles.swift b/Generator/Sources/SwiftWinRT/writeProjectionFiles.swift index 5d053ca..ab8e3ae 100644 --- a/Generator/Sources/SwiftWinRT/writeProjectionFiles.swift +++ b/Generator/Sources/SwiftWinRT/writeProjectionFiles.swift @@ -41,7 +41,7 @@ fileprivate func writeModuleFiles( try writeNamespaceModuleFiles(module, directoryPath: "\(directoryPath)\\Namespaces", cmakeOptions: cmakeOptions) } - if let cmakeOptions { + if cmakeOptions != nil { let writer = CMakeListsWriter(output: FileTextOutputStream( path: "\(directoryPath)\\CMakeLists.txt", directoryCreation: .ancestors)) @@ -108,8 +108,8 @@ fileprivate func writeSwiftModuleFiles(_ module: Module, directoryPath: String, "PROPERTIES", "Swift_MODULE_NAME", .autoquote(module.name)) } writer.writeTargetLinkLibraries(targetName, .public, - [ SupportModules.WinRT.moduleName, SupportModules.WinRT.abiModuleName ] - + module.references.map { cmakeOptions.getTargetName(moduleName: $0.abiModuleName) }) + [ cmakeOptions.getTargetName(moduleName: module.abiModuleName), SupportModules.WinRT.moduleName ] + + module.references.map { cmakeOptions.getTargetName(moduleName: $0.name) }) } } @@ -143,7 +143,7 @@ fileprivate func writeNamespaceModuleFiles(_ module: Module, directoryPath: Stri } } - if let cmakeOptions, !compactNamespaces.isEmpty { + if cmakeOptions != nil, !compactNamespaces.isEmpty { let writer = CMakeListsWriter(output: FileTextOutputStream( path: "\(directoryPath)\\CMakeLists.txt", directoryCreation: .ancestors))