Skip to content

Commit 731368d

Browse files
committed
Add iquote to have dependencies between c modules
1 parent 2dca624 commit 731368d

File tree

10 files changed

+54
-3
lines changed

10 files changed

+54
-3
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import PackageDescription
2+
3+
let package = Package(
4+
name: "CLibraryiquote",
5+
targets: [
6+
Target(name: "Bar", dependencies: ["Foo"]),
7+
Target(name: "Baz", dependencies: ["Foo", "Bar"])]
8+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "include/Bar/Bar.h"
2+
#include "Foo/Foo.h"
3+
4+
int bar() {
5+
int a = foo();
6+
int b = a;
7+
a = b;
8+
return a;
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int bar();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Bar {
2+
header "Bar/Bar.h"
3+
link "Bar"
4+
export *
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Foo
2+
import Bar
3+
4+
let _ = foo()
5+
let _ = bar()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "include/Foo/Foo.h"
2+
3+
int foo() {
4+
int a = 5;
5+
int b = a;
6+
a = b;
7+
return a;
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int foo();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Foo {
2+
header "Foo/Foo.h"
3+
link "Foo"
4+
export *
5+
}

Sources/Build/describe().swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
126126

127127
var args: [String] = []
128128
args += ["-fmodules", "-fmodule-name=\(module.name)"]
129-
args += ["-fmodule-map-file=\(module.moduleMapPath)"]
129+
args += ["-L\(prefix)"]
130130

131-
for case let otherModule as ClangModule in modules where otherModule != module {
132-
args += ["-iquote", otherModule.path]
131+
for case let dep as ClangModule in module.dependencies {
132+
args += ["-iquote", dep.path]
133+
args += ["-l\(dep.c99name)"] //FIXME: giving path to other module's -fmodule-map-file is not linking that module
133134
}
134135

135136
switch conf {

Tests/Functional/TestCLangModules.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ class TestClangModulesTestCase: XCTestCase {
4747
XCTAssertDirectoryExists(prefix, "Bar/Packages/Foo-1.2.3")
4848
}
4949
}
50+
51+
func testiquoteDep() {
52+
fixture(name: "ClangModules/CLibraryiquote") { prefix in
53+
XCTAssertBuilds(prefix)
54+
XCTAssertFileExists(prefix, ".build", "debug", "libFoo.so")
55+
XCTAssertFileExists(prefix, ".build", "debug", "libBar.so")
56+
}
57+
}
5058
}
5159

5260

0 commit comments

Comments
 (0)