Skip to content

Commit

Permalink
Merge pull request #46 from thegecko/simple-ble
Browse files Browse the repository at this point in the history
Simple BLE
  • Loading branch information
thegecko committed May 30, 2023
2 parents a845bef + 65f580c commit 4a56b50
Show file tree
Hide file tree
Showing 37 changed files with 4,433 additions and 592 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
build
dist
docs
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2

updates:
# Maintain dependencies for the JavaScript package
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: build

on:
push:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: yarn install --ignore-scripts
- run: yarn build:ts
37 changes: 0 additions & 37 deletions .github/workflows/ci.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: docs

on:
push:
branches:
- master
workflow_dispatch:

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: yarn install --ignore-scripts
- run: yarn build:ts
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
enable_jekyll: false
75 changes: 75 additions & 0 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: prebuild

on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master
workflow_dispatch:

jobs:
prebuild:
strategy:
fail-fast: false
matrix:
include:
- name: darwin
os: macos-latest
node: x64
- name: win32-x86
os: windows-latest
node: x86
- name: win32-x64
os: windows-latest
node: x64
- name: linux-x64
os: ubuntu-latest
node: x64
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- if: matrix.node
uses: actions/setup-node@v3
with:
node-version: 16
architecture: ${{ matrix.node }}
- uses: actions/checkout@v3
with:
submodules: recursive
- if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y libdbus-1-dev
- if: contains(matrix.os, 'macos')
uses: jwlawson/actions-setup-cmake@v1.12
with:
cmake-version: '3.21.x'
- if: contains(matrix.os, 'windows')
uses: microsoft/setup-msbuild@v1.0.2
- run: yarn install --ignore-scripts
- run: yarn prebuild
- run: tar -zcvf ${{ matrix.name }}.tar.gz -C prebuilds .
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}.tar.gz
retention-days: 1
release:
needs: prebuild
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
path: artifacts
- uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: artifacts/*/*.tar.gz
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.DS_Store
node_modules
build
prebuilds
dist
docs
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "SimpleBLE"]
path = SimpleBLE
url = https://github.com/OpenBluetoothToolbox/SimpleBLE
47 changes: 47 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0042 NEW)

project(webbluetooth)

if (APPLE)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "macOS architecture" FORCE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "macOS target" FORCE)
elseif(WIN32)
set(CMAKE_SYSTEM_VERSION "10.0.22000.0" CACHE STRING "Windows version" FORCE)
endif()

add_subdirectory(SimpleBLE/simpleble)

# Add Node bindings.
execute_process(COMMAND node -p "require('node-addon-api').include_dir"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_library(simpleble-node SHARED
lib/adapter.h
lib/adapter.cpp
lib/bindings.cpp
lib/peripheral.h
lib/peripheral.cpp
${CMAKE_JS_SRC}
)
target_include_directories(simpleble-node PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/lib
${CMAKE_JS_INC}
${NODE_ADDON_API_DIR}
)
target_link_libraries(simpleble-node PRIVATE simpleble-c ${CMAKE_JS_LIB})
target_compile_definitions(simpleble-node PRIVATE NAPI_VERSION=6)
set_target_properties(simpleble-node PROPERTIES
OUTPUT_NAME "simpleble"
CXX_STANDARD 17
PREFIX ""
SUFFIX ".node"
)

if (MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
# Generate node.lib
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
endif()

0 comments on commit 4a56b50

Please sign in to comment.