Skip to content

Commit 1bc3afe

Browse files
committed
* Allow suffixing library names with : to specify exact relative paths to libraries, ignoring any additional prefix or suffix
1 parent 34597f5 commit 1bc3afe

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
* Allow suffixing library names with `:` to specify exact relative paths to libraries, ignoring any additional prefix or suffix
23
* Prevent `Loader.load()` from trying to load library files that do not exist or to create symbolic links to them
34
* Let `Loader.load()` extract libraries suffixed with `##`, but still ignored for copying by `Builder`
45
* Make sure `Loader.load()` also initializes classes that are passed explicitly

src/main/java/org/bytedeco/javacpp/Loader.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
11351135
*
11361136
* @param cls the Class whose package name and {@link ClassLoader} are used to extract from resources
11371137
* @param properties contains the directories to scan for if we fail to extract the library from resources
1138-
* @param libnameversion ":" to disable prefixes and suffixes + the name of the library + "@" + optional version tag
1138+
* @param libnameversion the name of the library + ":" + optional exact path to library + "@" + optional version tag
11391139
* + "#" + a second optional name used at extraction (or empty to prevent it, unless it is a second "#")
11401140
* + "!" to load all symbols globally
11411141
* @param pathsFirst search the paths first before bundled resources
@@ -1146,6 +1146,9 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
11461146
if (libnameversion.startsWith(":")) {
11471147
nostyle = true;
11481148
libnameversion = libnameversion.substring(1);
1149+
} else if (libnameversion.contains(":")) {
1150+
nostyle = true;
1151+
libnameversion = libnameversion.substring(libnameversion.indexOf(":") + 1);
11491152
}
11501153
if (libnameversion.endsWith("!")) {
11511154
libnameversion = libnameversion.substring(0, libnameversion.length() - 1);
@@ -1262,7 +1265,7 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
12621265
* Finally, if all fails, falls back on {@link System#loadLibrary(String)}.
12631266
*
12641267
* @param urls the URLs to try loading the library from
1265-
* @param libnameversion ":" to disable prefixes and suffixes + the name of the library + "@" + optional version tag
1268+
* @param libnameversion the name of the library + ":" + optional exact path to library + "@" + optional version tag
12661269
* + "#" + a second optional name used at extraction (or empty to prevent it, unless it is a second "#")
12671270
* + "!" to load all symbols globally
12681271
* @param preloaded libraries for which to create symbolic links in same cache directory
@@ -1276,6 +1279,8 @@ public static synchronized String loadLibrary(URL[] urls, String libnameversion,
12761279
}
12771280
if (libnameversion.startsWith(":")) {
12781281
libnameversion = libnameversion.substring(1);
1282+
} else if (libnameversion.contains(":")) {
1283+
libnameversion = libnameversion.substring(0, libnameversion.indexOf(":"));
12791284
}
12801285
boolean loadGlobally = false;
12811286
if (libnameversion.endsWith("!")) {
@@ -1429,6 +1434,8 @@ public static synchronized String loadLibrary(URL[] urls, String libnameversion,
14291434
public static String createLibraryLink(String filename, ClassProperties properties, String libnameversion, String ... paths) {
14301435
if (libnameversion != null && libnameversion.startsWith(":")) {
14311436
libnameversion = libnameversion.substring(1);
1437+
} else if (libnameversion != null && libnameversion.contains(":")) {
1438+
libnameversion = libnameversion.substring(0, libnameversion.indexOf(":"));
14321439
}
14331440
if (libnameversion != null && libnameversion.endsWith("!")) {
14341441
libnameversion = libnameversion.substring(0, libnameversion.length() - 1);

0 commit comments

Comments
 (0)