Skip to content

Commit 4d9db59

Browse files
committed
Use -I for other packages
1 parent 731368d commit 4d9db59

File tree

11 files changed

+50
-1
lines changed

11 files changed

+50
-1
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: "Bar",
5+
dependencies: [
6+
.Package(url: "../Foo", majorVersion: 1)
7+
]
8+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <Foo/Foo.h>
2+
3+
void cool() {
4+
foo();
5+
}

Fixtures/DependencyResolution/External/CUsingCDep/Bar/Sources/SeaLover/include/Sea.h

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module SeaLover {
2+
header "Sea/Sea.h"
3+
link "SeaLover"
4+
export *
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Foo
2+
3+
foo()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
void foo() {
2+
3+
}

Fixtures/DependencyResolution/External/CUsingCDep/Foo/Package.swift

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void 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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,20 @@ public func describe(prefix: String, _ conf: Configuration, _ modules: [Module],
125125
mkdirs.insert(wd)
126126

127127
var args: [String] = []
128+
#if os(Linux)
129+
args += ["-fPIC"]
130+
#endif
128131
args += ["-fmodules", "-fmodule-name=\(module.name)"]
129132
args += ["-L\(prefix)"]
130133

131134
for case let dep as ClangModule in module.dependencies {
132-
args += ["-iquote", dep.path]
135+
let includeFlag: String
136+
if dep.path.parentDirectory.parentDirectory.basename == "Packages" { //Do better
137+
includeFlag = "-I"
138+
} else {
139+
includeFlag = "-iquote"
140+
}
141+
args += [includeFlag, dep.path]
133142
args += ["-l\(dep.c99name)"] //FIXME: giving path to other module's -fmodule-map-file is not linking that module
134143
}
135144

Tests/Functional/TestCLangModules.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ class TestClangModulesTestCase: XCTestCase {
5555
XCTAssertFileExists(prefix, ".build", "debug", "libBar.so")
5656
}
5757
}
58+
59+
func testCUsingCDep() {
60+
fixture(name: "DependencyResolution/External/CUsingCDep") { prefix in
61+
XCTAssertBuilds(prefix, "Bar")
62+
XCTAssertFileExists(prefix, "Bar/.build/debug/libFoo.so")
63+
XCTAssertDirectoryExists(prefix, "Bar/Packages/Foo-1.2.3")
64+
}
65+
}
5866
}
5967

6068

@@ -65,6 +73,8 @@ extension TestClangModulesTestCase {
6573
("testSingleModuleCLibraryInSources", testSingleModuleCLibraryInSources),
6674
("testMixedSwiftAndC", testMixedSwiftAndC),
6775
("testExternalSimpleCDep", testExternalSimpleCDep),
76+
("testiquoteDep", testiquoteDep),
77+
("testCUsingCDep", testCUsingCDep),
6878
]
6979
}
7080
}

0 commit comments

Comments
 (0)