Skip to content

Commit

Permalink
feat: allow override of detected architecture
Browse files Browse the repository at this point in the history
Closes: #795
  • Loading branch information
gotson committed Nov 7, 2022
1 parent 3a115b0 commit 9e9d144
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ You can use a specific version of the native library by setting the following JV
-Dorg.sqlite.lib.name=your-custom.dll
```

## Override detected architecture

If the detected architecture is incorrect for your system, thus loading the wrong native library, you can override the value setting the following JVM property:
```
-Dorg.sqlite.osinfo.architecture=arm
```

## Configure Connections
```java
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/sqlite/util/OSInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ static String resolveArmArchType() {
}

public static String getArchName() {
String override = System.getProperty("org.sqlite.osinfo.architecture");
if(override != null) {
return override;
}

String osArch = System.getProperty("os.arch");

if (osArch.startsWith("arm")) {
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/org/sqlite/util/OSInfoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,13 @@ public void testArm64NativePath() throws IOException, InterruptedException {
}
}
}

@Test
@SetSystemProperty(key = "org.sqlite.osinfo.architecture", value = "overridden")
@SetSystemProperty(key = "os.name", value = "Windows")
void testOverride() {
assertThat(OSInfo.getArchName()).isEqualTo("overridden");
assertThat(OSInfo.getNativeLibFolderPathForCurrentOS())
.isEqualTo("Windows/overridden");
}
}

0 comments on commit 9e9d144

Please sign in to comment.