-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default to non static library loading for JNI
- Loading branch information
Showing
34 changed files
with
350 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
apriltag/src/test/java/edu/wpi/first/apriltag/AprilTagJniTestExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package edu.wpi.first.apriltag; | ||
|
||
import edu.wpi.first.apriltag.jni.AprilTagJNI; | ||
import edu.wpi.first.util.WPIUtilJNI; | ||
|
||
import java.io.IOException; | ||
import org.junit.jupiter.api.extension.BeforeAllCallback; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.extension.ExtensionContext.Namespace; | ||
|
||
public final class AprilTagJniTestExtension implements BeforeAllCallback { | ||
private static ExtensionContext getRoot(ExtensionContext context) { | ||
return context.getParent().map(AprilTagJniTestExtension::getRoot).orElse(context); | ||
} | ||
|
||
@Override | ||
public void beforeAll(ExtensionContext context) throws Exception { | ||
getRoot(context) | ||
.getStore(Namespace.GLOBAL) | ||
.getOrComputeIfAbsent( | ||
"April Tag Initialized", | ||
key -> { | ||
initializeNatives(); | ||
return true; | ||
}, | ||
Boolean.class); | ||
} | ||
|
||
private void initializeNatives() { | ||
try { | ||
WPIUtilJNI.forceLoad(); | ||
AprilTagJNI.forceLoad(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
apriltag/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
edu.wpi.first.apriltag.AprilTagJniTestExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
cscore/src/test/java/edu/wpi/first/cscore/CameraServerJniTestExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package edu.wpi.first.cscore; | ||
|
||
import edu.wpi.first.util.WPIUtilJNI; | ||
|
||
import java.io.IOException; | ||
import org.junit.jupiter.api.extension.BeforeAllCallback; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.extension.ExtensionContext.Namespace; | ||
|
||
public final class CameraServerJniTestExtension implements BeforeAllCallback { | ||
private static ExtensionContext getRoot(ExtensionContext context) { | ||
return context.getParent().map(CameraServerJniTestExtension::getRoot).orElse(context); | ||
} | ||
|
||
@Override | ||
public void beforeAll(ExtensionContext context) throws Exception { | ||
getRoot(context) | ||
.getStore(Namespace.GLOBAL) | ||
.getOrComputeIfAbsent( | ||
"CsCore Initialized", | ||
key -> { | ||
initializeNatives(); | ||
return true; | ||
}, | ||
Boolean.class); | ||
} | ||
|
||
private void initializeNatives() { | ||
try { | ||
WPIUtilJNI.forceLoad(); | ||
CameraServerJNI.forceLoad(); | ||
OpenCvLoader.forceLoad(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
cscore/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
edu.wpi.first.cscore.CameraServerJniTestExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
hal/src/test/java/edu/wpi/first/hal/HalJniTestExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package edu.wpi.first.hal; | ||
|
||
import edu.wpi.first.util.WPIUtilJNI; | ||
|
||
import java.io.IOException; | ||
import org.junit.jupiter.api.extension.BeforeAllCallback; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.extension.ExtensionContext.Namespace; | ||
|
||
public final class HalJniTestExtension implements BeforeAllCallback { | ||
private static ExtensionContext getRoot(ExtensionContext context) { | ||
return context.getParent().map(HalJniTestExtension::getRoot).orElse(context); | ||
} | ||
|
||
@Override | ||
public void beforeAll(ExtensionContext context) throws Exception { | ||
getRoot(context) | ||
.getStore(Namespace.GLOBAL) | ||
.getOrComputeIfAbsent( | ||
"HAL Initialized", | ||
key -> { | ||
initializeNatives(); | ||
return true; | ||
}, | ||
Boolean.class); | ||
} | ||
|
||
private void initializeNatives() { | ||
try { | ||
WPIUtilJNI.forceLoad(); | ||
JNIWrapper.forceLoad(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
hal/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
edu.wpi.first.hal.HalJniTestExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
ntcore/src/generated/main/java/edu/wpi/first/networktables/NetworkTablesJNI.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
ntcore/src/test/java/edu/wpi/first/networktables/NetworkTablesJniTestExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package edu.wpi.first.networktables; | ||
|
||
import edu.wpi.first.util.WPIUtilJNI; | ||
|
||
import java.io.IOException; | ||
import org.junit.jupiter.api.extension.BeforeAllCallback; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.extension.ExtensionContext.Namespace; | ||
|
||
public final class NetworkTablesJniTestExtension implements BeforeAllCallback { | ||
private static ExtensionContext getRoot(ExtensionContext context) { | ||
return context.getParent().map(NetworkTablesJniTestExtension::getRoot).orElse(context); | ||
} | ||
|
||
@Override | ||
public void beforeAll(ExtensionContext context) throws Exception { | ||
getRoot(context) | ||
.getStore(Namespace.GLOBAL) | ||
.getOrComputeIfAbsent( | ||
"Ntcore Initialized", | ||
key -> { | ||
initializeNatives(); | ||
return true; | ||
}, | ||
Boolean.class); | ||
} | ||
|
||
private void initializeNatives() { | ||
try { | ||
WPIUtilJNI.forceLoad(); | ||
NetworkTablesJNI.forceLoad(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
ntcore/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
edu.wpi.first.networktables.NetworkTablesJniTestExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
|
||
] |
Oops, something went wrong.