Skip to content

Commit 41dcbbf

Browse files
committed
lib paths: workaround for swiftly installed 6.0.2 lib path
1 parent 6750709 commit 41dcbbf

File tree

4 files changed

+41
-9
lines changed

4 files changed

+41
-9
lines changed

BuildLogic/src/main/kotlin/build-logic.java-common-conventions.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ fun javaLibraryPaths(dir: File): List<String> {
6969
} else {
7070
// assume macOS
7171
"/usr/lib/swift/"
72+
},
73+
if (isLinux) {
74+
System.getProperty("user.home") + "/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux"
75+
} else {
76+
// assume macOS
77+
"/usr/lib/swift/"
7278
}
7379
)
7480
}

Samples/SwiftKitSampleApp/src/test/java/com/example/swift/MySwiftClassTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,37 @@
1616

1717
import org.junit.jupiter.api.Disabled;
1818
import org.junit.jupiter.api.Test;
19+
import org.swift.swiftkit.SwiftKit;
20+
21+
import java.io.File;
22+
import java.util.stream.Stream;
1923

2024
import static org.junit.jupiter.api.Assertions.*;
2125

2226
public class MySwiftClassTest {
2327

28+
void checkPaths(Throwable throwable) {
29+
var paths = SwiftKit.getJavaLibraryPath().split(":");
30+
for (var path : paths) {
31+
System.out.println("CHECKING PATH: " + path);
32+
Stream.of(new File(path).listFiles())
33+
.filter(file -> !file.isDirectory())
34+
.forEach((file) -> {
35+
System.out.println(" - " + file.getPath());
36+
});
37+
}
38+
39+
throw new RuntimeException(throwable);
40+
}
41+
2442
@Test
2543
void test_MySwiftClass_voidMethod() {
26-
MySwiftClass o = new MySwiftClass(12, 42);
27-
o.voidMethod();
44+
try {
45+
MySwiftClass o = new MySwiftClass(12, 42);
46+
o.voidMethod();
47+
} catch (Throwable throwable) {
48+
checkPaths(throwable);
49+
}
2850
}
2951

3052
@Test

Sources/JExtractSwift/Swift2JavaTranslator+Printing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ extension Swift2JavaTranslator {
323323
private static SymbolLookup getSymbolLookup() {
324324
// Ensure Swift and our Lib are loaded during static initialization of the class.
325325
System.loadLibrary("swiftCore");
326-
System.loadLibrary("swiftKitSwift");
326+
System.loadLibrary("SwiftKitSwift");
327327
System.loadLibrary(LIB_NAME);
328328
329329
if (PlatformUtils.isMacOS()) {

buildSrc/src/main/groovy/org/swift/swiftkit/gradle/BuildUtils.groovy

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ final class BuildUtils {
4040
"${base}../../.build/${osArch}-apple-macosx/debug/"),
4141
]
4242
def releasePaths = debugPaths.collect { it.replaceAll("debug", "release") }
43-
def systemPaths = [
44-
// system paths
43+
def systemPaths =
4544
isLinux ?
46-
"/usr/lib/swift/linux" :
47-
// assume macOS
48-
"/usr/lib/swift/"
49-
]
45+
[
46+
"/usr/lib/swift/linux",
47+
// TODO: should we be Swiftly aware and then use the currently used path?
48+
System.getProperty("user.home") + "/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux"
49+
] :
50+
[
51+
// assume macOS
52+
"/usr/lib/swift/"
53+
]
5054

5155
return releasePaths + debugPaths + systemPaths
5256
}

0 commit comments

Comments
 (0)