Skip to content

Commit b9661bf

Browse files
committed
Fix product path for cmodules, remove -working-dir flag
1 parent c601c10 commit b9661bf

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

Sources/Build/describe().swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,21 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
112112
//FIXME: Generate modulemaps if possible
113113
//Since we're not generating modulemaps currently we'll just emit empty module map file
114114
//if it not present
115-
if !module.path.isFile {
116-
try mkdir(module.path.parentDirectory)
117-
try fopen(module.path, mode: .Write) { fp in
115+
if !module.moduleMapPath.isFile {
116+
try mkdir(module.moduleMapPath.parentDirectory)
117+
try fopen(module.moduleMapPath, mode: .Write) { fp in
118118
try fputs("\n", fp)
119119
}
120120
}
121121

122122
let inputs = module.dependencies.map{ $0.targetName } + module.sources.paths
123-
let productPath = Path.join(prefix, "\(module.c99name).o")
123+
let productPath = Path.join(prefix, "lib\(module.c99name).so")
124124
let wd = Path.join(prefix, "\(module.c99name).build")
125125
mkdirs.insert(wd)
126126

127127
var args: [String] = []
128128
args += ["-fmodules", "-fmodule-name=\(module.name)"]
129-
args += ["-fmodule-map-file=\(module.path)", "-working-directory", Path.join(prefix, "\(module.c99name).build")]
129+
args += ["-fmodule-map-file=\(module.moduleMapPath)"]
130130

131131
switch conf {
132132
case .Debug:
@@ -136,7 +136,7 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
136136
}
137137

138138
args += module.sources.paths
139-
args += ["-shared", "-o", Path.join(prefix, "lib\(module.c99name).so")]
139+
args += ["-shared", "-o", productPath]
140140

141141
let clang = ShellTool(
142142
description: "Compiling \(module.name)",

Sources/Build/misc.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ func platformArgs() -> [String] {
2626
return args
2727
}
2828

29+
extension CModule {
30+
var moduleMapPath: String {
31+
return Path.join(path, "module.modulemap")
32+
}
33+
}
34+
2935
extension Module {
3036
var Xcc: [String] {
3137
return recursiveDependencies.flatMap { module -> [String] in
3238
if let module = module as? CModule {
33-
let moduleMapPath = Path.join(module.path, "module.modulemap")
34-
return ["-Xcc", "-fmodule-map-file=\(moduleMapPath)"]
35-
} else if let cmodule = module as? ClangModule {
36-
return ["-Xcc", "-fmodule-map-file=\(cmodule.path)"]
39+
return ["-Xcc", "-fmodule-map-file=\(module.moduleMapPath)"]
3740
} else {
3841
return []
3942
}

Sources/PackageType/Module.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public class ClangModule: CModule {
7575

7676
public init(name: String, sources: Sources) {
7777
self.sources = sources
78-
//TODO: generate this with swiftpm if layout supports
79-
super.init(name: name, path: sources.root + "/include/module.modulemap")
78+
//TODO: generate module map using swiftpm if layout can support
79+
super.init(name: name, path: sources.root + "/include")
8080
}
8181
}
8282

Sources/Transmute/fillModuleGraph().swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ func fillModuleGraph(packages: [Package], modulesForPackage: (Package) -> [Modul
2020
return false
2121
case let module as SwiftModule where module.type == .Library:
2222
return true
23-
case is ClangModule:
24-
return true
2523
case is CModule:
2624
return true
2725
default:

0 commit comments

Comments
 (0)