Skip to content

Commit dd96e73

Browse files
authored
Merge pull request #5 from OpenBCI/readme-update
GUI Helpers v2 Refactor
2 parents dd608e9 + 0400052 commit dd96e73

7 files changed

Lines changed: 164 additions & 157 deletions

File tree

.github/workflows/build_deploy.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Build and Deploy GUI Helpers Jar
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
branches: [ master ]
7+
8+
jobs:
9+
Build-Linux:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
- name: Install Dependencies
15+
run: |
16+
sudo apt-get -y install bluez libbluetooth-dev libdbus-1-dev
17+
- name: Build using Cmake
18+
id: cmake-build
19+
run: |
20+
mkdir build
21+
cd build
22+
cmake -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release ..
23+
make
24+
- name: Upload Artifacts
25+
uses: actions/upload-artifact@v3
26+
if: steps.cmake-build.outputs.exit_code == 0
27+
with:
28+
name: linux-artifacts
29+
path: java-package/openbci_gui_helpers/src/main/resources/
30+
retention-days: 1
31+
32+
Build-Mac:
33+
runs-on: macos-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v3
37+
- name: Setup Python
38+
uses: actions/setup-python@v4
39+
with:
40+
python-version: '3.9'
41+
cache: 'pip'
42+
- name: Install Dependencies
43+
run: |
44+
pip install ninja
45+
- name: Build using Cmake
46+
id: cmake-build
47+
run: |
48+
mkdir build
49+
cd build
50+
cmake -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 ..
51+
ninja
52+
- name: Upload Artifacts
53+
uses: actions/upload-artifact@v3
54+
if: steps.cmake-build.outputs.exit_code == 0
55+
with:
56+
name: mac-artifacts
57+
path: java-package/openbci_gui_helpers/src/main/resources/
58+
retention-days: 1
59+
60+
Build-Windows:
61+
runs-on: windows-2019
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v3
65+
- name: Build using Cmake
66+
id: cmake-build
67+
run: |
68+
mkdir build
69+
cd build
70+
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.19041.0 -DCMAKE_INSTALL_PREFIX=..\installed64\ ..
71+
cmake --build . --config Release
72+
- name: Upload Artifacts
73+
uses: actions/upload-artifact@v3
74+
if: steps.cmake-build.outputs.exit_code == 0
75+
with:
76+
name: windows-artifacts
77+
path: java-package/openbci_gui_helpers/src/main/resources/
78+
retention-days: 1
79+
80+
Package-And-Upload:
81+
runs-on: windows-2019
82+
needs: [Build-Linux, Build-Mac, Build-Windows]
83+
steps:
84+
- name: Checkout
85+
uses: actions/checkout@v3
86+
- name: Download Artifacts
87+
uses: actions/download-artifact@v3
88+
- name: Copy Dynamic Libraries
89+
run: |
90+
mkdir -p java-package/openbci_gui_helpers/src/main/resources/
91+
cp -r linux-artifacts/* java-package/openbci_gui_helpers/src/main/resources/
92+
cp -r mac-artifacts/* java-package/openbci_gui_helpers/src/main/resources/
93+
cp -r windows-artifacts/* java-package/openbci_gui_helpers/src/main/resources/
94+
ls -l java-package/openbci_gui_helpers/src/main/resources/
95+
- name: Build Jar
96+
id: build-jar
97+
run: |
98+
cd java-package/openbci_gui_helpers/
99+
mvn package
100+
- name: Upload Jar
101+
id: upload-jar
102+
uses: actions/upload-artifact@v3
103+
with:
104+
name: jar-artifact
105+
path: java-package\openbci_gui_helpers\target\openbci_gui_helpers.jar
106+
retention-days: 30
107+
# Remove dynamic libraries from artifacts if build and upload were successful
108+
- uses: geekyeggo/delete-artifact@v2
109+
if: steps.build-jar.outputs.exit_code == 0 && steps.upload-jar.outputs.exit_code == 0
110+
with:
111+
name: |
112+
linux-artifacts
113+
windows-artifacts

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ ASALocalRun/
339339
.vscode/
340340

341341
build*
342+
!build_deploy.yml
342343
installed*
343344
compiled/
344345
python/flowcat.egg-info/
@@ -361,3 +362,8 @@ matlab-package/lib/brainflow_boards.json
361362
python-package/brainflow/lib/brainflow_boards.json
362363
python-package/brainflow/lib/libBoardController.dylib
363364
python-package/brainflow/lib/libDataHandler.dylib
365+
java-package/openbci_gui_helpers/target/classes/openbci_gui_helpers/GUIHelper.class
366+
java-package/openbci_gui_helpers/target/classes/openbci_gui_helpers/GUIHelper$DllInterface.class
367+
java-package/openbci_gui_helpers/target/classes/openbci_gui_helpers/GUIHelper$DllNativeInterface.class
368+
java-package/openbci_gui_helpers/target/classes/openbci_gui_helpers/examples/TestDiscovery.class
369+
java-package/openbci_gui_helpers/target/classes/openbci_gui_helpers/examples/TestNativeDiscovery.class

.travis.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,16 @@
22

33
Helpers for [OpenBCI GUI](https://github.com/OpenBCI/OpenBCI_GUI)
44

5+
Built using Github Actions for all OS. The .dylib files for Mac are also provided as an artifact.
6+
7+
When updating this library in the GUI, use the following folder structure:
8+
9+
- GUI Repo Root Directory
10+
- OpenBCI_GUI
11+
- libraries
12+
- openbci_gui_helpers
13+
- library
14+
- `openbci_gui_helpers.jar`
15+
516
## License:
617
MIT

appveyor.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

java-package/openbci_gui_helpers/pom.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66

77
<groupId>openbci_gui_helpers</groupId>
88
<artifactId>openbci_gui_helpers</artifactId>
9-
<version>1.0-SNAPSHOT</version>
9+
<version>2.0.0</version>
1010

1111
<name>openbci_gui_helpers</name>
12-
<!-- FIXME change it to the project's website -->
13-
<url>http://www.openbci.com</url>
12+
<url>https://github.com/OpenBCI/OpenBCI_GUI_Helpers</url>
1413

1514
<properties>
1615
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17-
<maven.compiler.source>1.7</maven.compiler.source>
18-
<maven.compiler.target>1.7</maven.compiler.target>
16+
<maven.compiler.source>1.8</maven.compiler.source>
17+
<maven.compiler.target>1.8</maven.compiler.target>
1918
</properties>
2019

2120
<dependencies>

java-package/openbci_gui_helpers/src/main/java/openbci_gui_helpers/GUIHelper.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package openbci_gui_helpers;
22

3+
import java.io.BufferedReader;
34
import java.io.File;
45
import java.io.InputStream;
6+
import java.io.InputStreamReader;
57
import java.lang.reflect.Type;
8+
import java.nio.charset.StandardCharsets;
69
import java.nio.file.Files;
10+
import java.nio.file.Paths;
11+
import java.nio.file.Path;
712
import java.util.Map;
13+
import java.util.stream.Collectors;
814

915
import org.apache.commons.lang3.SystemUtils;
1016

@@ -27,9 +33,12 @@ private interface DllNativeInterface extends Library
2733

2834
private static DllInterface instance;
2935
private static DllNativeInterface instance_native;
36+
private static final String VERSION = "1.2.0";
3037

3138
static
3239
{
40+
System.out.println("OpenBCI_GUI_Helpers Version: " + VERSION);
41+
3342
String lib_name = "libGanglionScan.so";
3443
String lib_native_name = "libGanglionNativeScan.so";
3544
if (SystemUtils.IS_OS_WINDOWS)
@@ -53,17 +62,34 @@ private interface DllNativeInterface extends Library
5362

5463
private static String unpack_from_jar (String lib_name)
5564
{
65+
File file = null;
66+
InputStream link = null;
5667
try
5768
{
58-
File file = new File (lib_name);
69+
file = new File (lib_name);
5970
if (file.exists ())
6071
file.delete ();
61-
InputStream link = (GUIHelper.class.getResourceAsStream (lib_name));
62-
Files.copy (link, file.getAbsoluteFile ().toPath ());
72+
link = (GUIHelper.class.getResourceAsStream (lib_name));
73+
if (SystemUtils.IS_OS_MAC) {
74+
String jarPath = GUIHelper.class.getProtectionDomain().getCodeSource().getLocation().getPath();
75+
File jarFile = new File(jarPath);
76+
String libPathString = jarFile.getParentFile().getAbsolutePath() + File.separator + lib_name;
77+
Path libPath = Paths.get(libPathString);
78+
Files.copy (link, libPath);
79+
return libPathString;
80+
} else {
81+
Files.copy (link, file.getAbsoluteFile ().toPath ());
82+
}
6383
return file.getAbsolutePath();
6484
} catch (Exception io)
6585
{
66-
System.err.println ("native library: " + lib_name + " is not found in jar file");
86+
io.printStackTrace ();
87+
System.err.println("native library: " + lib_name + " is not found in jar file");
88+
System.err.println("file absolute to path: " + file.getAbsoluteFile().toPath());
89+
System.err.println("file get absolute path: " + file.getAbsolutePath());
90+
if (SystemUtils.IS_OS_MAC) {
91+
return file.getAbsolutePath();
92+
}
6793
return "";
6894
}
6995
}

0 commit comments

Comments
 (0)