Skip to content

Commit

Permalink
Merge pull request #5 from OpenBCI/readme-update
Browse files Browse the repository at this point in the history
GUI Helpers v2 Refactor
  • Loading branch information
retiutut authored Sep 15, 2023
2 parents dd608e9 + 0400052 commit dd96e73
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 157 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Build and Deploy GUI Helpers Jar
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
Build-Linux:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Dependencies
run: |
sudo apt-get -y install bluez libbluetooth-dev libdbus-1-dev
- name: Build using Cmake
id: cmake-build
run: |
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release ..
make
- name: Upload Artifacts
uses: actions/upload-artifact@v3
if: steps.cmake-build.outputs.exit_code == 0
with:
name: linux-artifacts
path: java-package/openbci_gui_helpers/src/main/resources/
retention-days: 1

Build-Mac:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install Dependencies
run: |
pip install ninja
- name: Build using Cmake
id: cmake-build
run: |
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 ..
ninja
- name: Upload Artifacts
uses: actions/upload-artifact@v3
if: steps.cmake-build.outputs.exit_code == 0
with:
name: mac-artifacts
path: java-package/openbci_gui_helpers/src/main/resources/
retention-days: 1

Build-Windows:
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build using Cmake
id: cmake-build
run: |
mkdir build
cd build
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.19041.0 -DCMAKE_INSTALL_PREFIX=..\installed64\ ..
cmake --build . --config Release
- name: Upload Artifacts
uses: actions/upload-artifact@v3
if: steps.cmake-build.outputs.exit_code == 0
with:
name: windows-artifacts
path: java-package/openbci_gui_helpers/src/main/resources/
retention-days: 1

Package-And-Upload:
runs-on: windows-2019
needs: [Build-Linux, Build-Mac, Build-Windows]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Copy Dynamic Libraries
run: |
mkdir -p java-package/openbci_gui_helpers/src/main/resources/
cp -r linux-artifacts/* java-package/openbci_gui_helpers/src/main/resources/
cp -r mac-artifacts/* java-package/openbci_gui_helpers/src/main/resources/
cp -r windows-artifacts/* java-package/openbci_gui_helpers/src/main/resources/
ls -l java-package/openbci_gui_helpers/src/main/resources/
- name: Build Jar
id: build-jar
run: |
cd java-package/openbci_gui_helpers/
mvn package
- name: Upload Jar
id: upload-jar
uses: actions/upload-artifact@v3
with:
name: jar-artifact
path: java-package\openbci_gui_helpers\target\openbci_gui_helpers.jar
retention-days: 30
# Remove dynamic libraries from artifacts if build and upload were successful
- uses: geekyeggo/delete-artifact@v2
if: steps.build-jar.outputs.exit_code == 0 && steps.upload-jar.outputs.exit_code == 0
with:
name: |
linux-artifacts
windows-artifacts
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ ASALocalRun/
.vscode/

build*
!build_deploy.yml
installed*
compiled/
python/flowcat.egg-info/
Expand All @@ -361,3 +362,8 @@ matlab-package/lib/brainflow_boards.json
python-package/brainflow/lib/brainflow_boards.json
python-package/brainflow/lib/libBoardController.dylib
python-package/brainflow/lib/libDataHandler.dylib
java-package/openbci_gui_helpers/target/classes/openbci_gui_helpers/GUIHelper.class
java-package/openbci_gui_helpers/target/classes/openbci_gui_helpers/GUIHelper$DllInterface.class
java-package/openbci_gui_helpers/target/classes/openbci_gui_helpers/GUIHelper$DllNativeInterface.class
java-package/openbci_gui_helpers/target/classes/openbci_gui_helpers/examples/TestDiscovery.class
java-package/openbci_gui_helpers/target/classes/openbci_gui_helpers/examples/TestNativeDiscovery.class
65 changes: 0 additions & 65 deletions .travis.yml

This file was deleted.

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,16 @@

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

Built using Github Actions for all OS. The .dylib files for Mac are also provided as an artifact.

When updating this library in the GUI, use the following folder structure:

- GUI Repo Root Directory
- OpenBCI_GUI
- libraries
- openbci_gui_helpers
- library
- `openbci_gui_helpers.jar`

## License:
MIT
83 changes: 0 additions & 83 deletions appveyor.yml

This file was deleted.

9 changes: 4 additions & 5 deletions java-package/openbci_gui_helpers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@

<groupId>openbci_gui_helpers</groupId>
<artifactId>openbci_gui_helpers</artifactId>
<version>1.0-SNAPSHOT</version>
<version>2.0.0</version>

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

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package openbci_gui_helpers;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.commons.lang3.SystemUtils;

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

private static DllInterface instance;
private static DllNativeInterface instance_native;
private static final String VERSION = "1.2.0";

static
{
System.out.println("OpenBCI_GUI_Helpers Version: " + VERSION);

String lib_name = "libGanglionScan.so";
String lib_native_name = "libGanglionNativeScan.so";
if (SystemUtils.IS_OS_WINDOWS)
Expand All @@ -53,17 +62,34 @@ private interface DllNativeInterface extends Library

private static String unpack_from_jar (String lib_name)
{
File file = null;
InputStream link = null;
try
{
File file = new File (lib_name);
file = new File (lib_name);
if (file.exists ())
file.delete ();
InputStream link = (GUIHelper.class.getResourceAsStream (lib_name));
Files.copy (link, file.getAbsoluteFile ().toPath ());
link = (GUIHelper.class.getResourceAsStream (lib_name));
if (SystemUtils.IS_OS_MAC) {
String jarPath = GUIHelper.class.getProtectionDomain().getCodeSource().getLocation().getPath();
File jarFile = new File(jarPath);
String libPathString = jarFile.getParentFile().getAbsolutePath() + File.separator + lib_name;
Path libPath = Paths.get(libPathString);
Files.copy (link, libPath);
return libPathString;
} else {
Files.copy (link, file.getAbsoluteFile ().toPath ());
}
return file.getAbsolutePath();
} catch (Exception io)
{
System.err.println ("native library: " + lib_name + " is not found in jar file");
io.printStackTrace ();
System.err.println("native library: " + lib_name + " is not found in jar file");
System.err.println("file absolute to path: " + file.getAbsoluteFile().toPath());
System.err.println("file get absolute path: " + file.getAbsolutePath());
if (SystemUtils.IS_OS_MAC) {
return file.getAbsolutePath();
}
return "";
}
}
Expand Down

0 comments on commit dd96e73

Please sign in to comment.