Skip to content

Commit

Permalink
Hotfix for finding parser library (#10123)
Browse files Browse the repository at this point in the history
* Hotfix for finding parser library

Since ydoc is now started by language server, parser is initialized
differently and attempts to find `libenso_parser.so` in
`component/runner` rather than `component` directory.

* Add fallbacks

* fix native image build
  • Loading branch information
hubertp authored May 29, 2024
1 parent e9452ea commit ca8d715
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@ private static void initializeLibraries() {
File parser = null;
try {
var whereAmI = Parser.class.getProtectionDomain().getCodeSource().getLocation();
File dir = new File(whereAmI.toURI()).getParentFile();
parser = new File(dir, name);
var d = new File(whereAmI.toURI()).getParentFile();
File path = null;
while (d != null) {
path = new File(d, name);
if (path.exists()) break;
d = d.getParentFile();
}
if (d == null) {
throw new LinkageError(
"Cannot find parser in " + new File(whereAmI.toURI()).getParentFile());
}
parser = path;
System.load(parser.getAbsolutePath());
} catch (URISyntaxException | LinkageError e) {
File root = new File(".").getAbsoluteFile();
Expand Down

0 comments on commit ca8d715

Please sign in to comment.