Skip to content

Commit da85c08

Browse files
Make sure enso.lib is inside of native-image temporary directory
1 parent c2c42b8 commit da85c08

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

build.sbt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4041,9 +4041,11 @@ lazy val `engine-runner` = project
40414041
)
40424042
else Seq()
40434043
val linkOpts = if (Platform.isWindows) {
4044-
val ensoExp = file("enso.exp")
4044+
val ensoTarget = file("target")
4045+
val ensoExp = file("enso.exp")
40454046
Seq(
4046-
// "-H:NativeLinkerOption=" + ensoExp.getAbsolutePath,
4047+
"-H:NativeLinkerOption=" + ensoExp.getAbsolutePath,
4048+
"-H:TempDirectory=" + ensoTarget.getAbsolutePath,
40474049
"-H:+TraceNativeToolUsage"
40484050
)
40494051
} else {

engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import static scala.jdk.javaapi.CollectionConverters.asJava;
44

5+
import java.io.File;
56
import java.nio.file.Files;
67
import java.nio.file.Path;
8+
import java.nio.file.StandardCopyOption;
79
import java.util.LinkedHashSet;
810
import java.util.TreeSet;
911
import org.enso.compiler.core.EnsoParser;
@@ -16,6 +18,7 @@
1618
public final class EnsoLibraryFeature implements Feature {
1719
@Override
1820
public void beforeAnalysis(BeforeAnalysisAccess access) {
21+
makeEnsoLibAvailableForShims();
1922

2023
var libs = new LinkedHashSet<Path>();
2124
for (var p : access.getApplicationClassPath()) {
@@ -97,4 +100,28 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
97100
}
98101
System.err.println("Registered " + classes.size() + " classes for reflection");
99102
}
103+
104+
private void makeEnsoLibAvailableForShims() {
105+
boolean found = false;
106+
try {
107+
var from = new File("enso.lib").getAbsoluteFile();
108+
System.err.println("Distributing enso.lib to (temporary) directories. From " + from);
109+
var target = new File("target").getAbsoluteFile();
110+
assert target.isDirectory() : "It is a dir " + target;
111+
for (var ch : target.listFiles()) {
112+
if (ch.isDirectory() && ch.getName().contains("SVM")) {
113+
var to = new File(ch, "enso.lib");
114+
System.err.println(" file to : " + to);
115+
Files.copy(from.toPath(), to.toPath(), StandardCopyOption.REPLACE_EXISTING);
116+
found = true;
117+
}
118+
}
119+
} catch (Exception ex) {
120+
ex.printStackTrace();
121+
}
122+
if (!found) {
123+
throw new IllegalStateException(
124+
"Cannot copy enso.lib into temporary directory of native-image");
125+
}
126+
}
100127
}

0 commit comments

Comments
 (0)