Closed Ali-RS closed 1 year ago
This could be managed by creating a static Boolean flag NativeBinaryLoader.isAutoLoad()
and it's setter method.
Notice, the flag should be true by default; because disabling the extraction process by default will break the test CI/CD workflow, so you will have to set this manually when implementing in jMonkeyEngine, before calling the NativeBufferAllocator.<cinit>
(the static initializer).
If you agree on these modifications, please let me know, so I could prepare my schedule to solve this issue.
If you also cannot think of a good place to make a call for NativeBinaryLoadr.setAutoLoad(false)
, please let me know, too.
What about using a system property? for example System.getProperty("com.jme3.alloc.librarypath")
NativeBinaryLoader can first check if the librarypath property is set and load it from there otherwise extract it automatically.
Edit:
Never mind, I think using NativeBinaryLoadr.setAutoLoad(false) is fine.
If you also cannot think of a good place to make a call for NativeBinaryLoadr.setAutoLoad(false), please let me know, too.
I think it should be in the class implementing JME BufferAllocator
interface. (i.e. LwjglBufferAllocator
).
public class LwjglBufferAllocator implements BufferAllocator {
static {
NativeBinaryLoadr.setAutoLoad(false);
NativeLibraryLoader.load(JmeAlloc);
}
@Override
public void destroyDirectBuffer(Buffer toBeDestroyed) {
NativeBufferAllocator.releaseDirectByteBuffer(toBeDestroyed);
}
@Override
public ByteBuffer allocate(int size) {
return NativeBufferAllocator.createDirectByteBuffer(size);
}
}
@Ali-RS Feel free to review PR #50.
It would be nice to add an option to be able to extract and load natives via JME NativeLibraryLoader. By default, JME (in the master branch) will export to
System.getProperty("java.io.tmpdir")
instead of extracting to the working directory (user.dir
) if no custom extraction folder is specified.