brainflow icon indicating copy to clipboard operation
brainflow copied to clipboard

[Java] Can there be a solution that is better than `BoardShim.unpack_from_jar`?

Open mgroth0 opened this issue 3 years ago • 6 comments

It is not ideal that .dylib files are appearing in the project folder on gradle run. Can there be an option to use another location?

This doc gives some useful information for different places that these files can be. "Context class loader classpath" seems like a good option.

mgroth0 avatar Jul 04 '22 20:07 mgroth0

Welcome to BrainFlow project and thanks for your contribution! We will try to fix your issue ASAP. Make sure that you have read about issue format in the docs.

github-actions[bot] avatar Jul 04 '22 20:07 github-actions[bot]

Hi, idk, I didnt find a better option when I was writting it. If context loader classpath works for you feel free to send a PR, it will be great. Another approach to try can be to change env variables

Andrey1994 avatar Jul 04 '22 21:07 Andrey1994

I want to help if I can.

Where are the native library files located originally during java runtime? I don't understand how they are packaged with the java code.

I have cloned the project, and ran mvn package inside of brainflow/java_package/brainflow. The build was successful but looking inside the brainflow-jar-withdependencies.jar, I do not see any library files.

Given the line InputStream link = (BoardShim.class.getResourceAsStream (lib_name)); inside BoardShim.java I expected the library files to somehow be a resource file included in the jar. I must just be misunderstanding something.

mgroth0 avatar Jul 04 '22 22:07 mgroth0

you need to compile it first using build.py https://brainflow.readthedocs.io/en/stable/BuildBrainFlow.html#compilation-of-core-module-and-c-binding

And as far as I understand you need to copy files to subfolder like linux-x64, etc https://github.com/brainflow-dev/brainflow/blob/master/java_package/brainflow/pom.xml#L50. Maybe you will need to change files like build.cmake(there are a lot of them, you probably need to run smth like find . -name build.cmake https://github.com/brainflow-dev/brainflow/blob/master/src/board_controller/build.cmake#L172

Andrey1994 avatar Jul 04 '22 22:07 Andrey1994

Also, when you compile it locally you do it only for one OS, while in jar file for releases there are libs for all OSes so this jar is x-platform. Its done by this CI job https://github.com/brainflow-dev/brainflow/blob/master/.github/workflows/deploy.yml, it copies files for all OSes from AWS

Andrey1994 avatar Jul 04 '22 22:07 Andrey1994

Thank you for all the helpful instructions. Here is my PR. It works correctly for Mac but still needs to be generalized to other platforms.

mgroth0 avatar Jul 06 '22 04:07 mgroth0

completed

Andrey1994 avatar Oct 01 '23 10:10 Andrey1994