Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-can-bridge: Add support for Linux and macOS #21

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b0ca096
add serialdriver for other platforms then windows
Moose1301 May 11, 2024
5d0a1a5
macOS: Compilation now succeeds, linking still fails though
qwertychouskie Jun 3, 2024
7362fe8
Manifest GitHub Actions workflows
garrettsummerfi3ld Jun 5, 2024
7278259
build.yml: Install distutils
qwertychouskie Jun 6, 2024
c58a3fd
build.yml: Disable caching `pip` (unbreak build)
qwertychouskie Jun 6, 2024
439c5d0
release.yml: Install distutils
qwertychouskie Jun 6, 2024
92e225f
release.yml: Fix action name
qwertychouskie Jun 6, 2024
c67db7f
Disable job cancel on build failure
garrettsummerfi3ld Jun 6, 2024
b54a763
Fix CI release job on every push to `main`
garrettsummerfi3ld Jun 6, 2024
ab1a3c9
Partial revert of commit `c67db7fbf74d82e71682f62f6f5a8477df2cdc66`
garrettsummerfi3ld Jun 6, 2024
b68b454
Merge pull request #1 from unofficial-rev-port/ci/setup
garrettsummerfi3ld Jun 23, 2024
45ab8d8
Update download-CanBridge.mjs
garrettsummerfi3ld Jun 12, 2024
50943a3
Major refactor for handling CANBridge
garrettsummerfi3ld Jun 22, 2024
3929fbd
Fix multiarch movement for CANBridge
garrettsummerfi3ld Jun 22, 2024
b609d96
Add macOS and Linux platforms
garrettsummerfi3ld Jun 23, 2024
5115898
Enable exception handling to allow Linux compilation
garrettsummerfi3ld Jun 23, 2024
70988aa
Unbreak macOS arm64 build
qwertychouskie Jun 24, 2024
7526628
Fix some warnings
qwertychouskie Jun 24, 2024
4b14281
Partial fix for Windows build regression
garrettsummerfi3ld Jun 30, 2024
8230825
chore: Bump CANBridge tag
garrettsummerfi3ld Jul 1, 2024
c67f0e3
fix: Reimplement stopHeartbeats function to fix MSVC builds
garrettsummerfi3ld Jul 1, 2024
3f673e6
binding.gyp: Change `darwin-x64` to `darwin-osxuniversal`
qwertychouskie Jul 1, 2024
90e8926
chore: Bump CANBridge tag
garrettsummerfi3ld Jul 1, 2024
5140afc
chore: Update build workflow to include pretest step
garrettsummerfi3ld Jul 1, 2024
79ab7e6
Update `README.md`
garrettsummerfi3ld Jul 1, 2024
5712827
Fix exceptions on macOS
qwertychouskie Jul 1, 2024
c9232a4
chore: Update npm dependencies
garrettsummerfi3ld Jul 2, 2024
955f5e9
Merge pull request #5 from unofficial-rev-port/sanity/node-gyp
garrettsummerfi3ld Jul 2, 2024
9a442f4
ci: Remove `setuptools` step
garrettsummerfi3ld Jul 7, 2024
822a510
Revert changes made to `canWrapper.cc`
garrettsummerfi3ld Jul 18, 2024
1f84037
Merge pull request #6 from unofficial-rev-port/ci/setuptools-removal
garrettsummerfi3ld Jul 22, 2024
9827e48
[ci skip] chore: Rename release workflow job
garrettsummerfi3ld Aug 13, 2024
a0152c2
Merge remote-tracking branch 'upstream/main'
qwertychouskie Aug 22, 2024
0ef46b6
Remove `CanBridgeInitializationError` custom error
qwertychouskie Aug 22, 2024
cb581d3
Merge pull request #8 from unofficial-rev-port/fix/canwrapper
garrettsummerfi3ld Aug 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build

on:
push:
branches:
- main
pull_request:
branches:
- '*'

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: "Build - ${{ matrix.os }}"

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install Python setup tools
run: |
pip install setuptools
qwertychouskie marked this conversation as resolved.
Show resolved Hide resolved

- name: Install dependencies
run: npm install

- name: Pretest
run: npm run pretest

- name: Test
run: npm test
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: "Release - ${{ matrix.os }}"

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Python setup tools
run: |
pip install setuptools

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Create release
uses: softprops/action-gh-release@v2
with:
files: dist/*
tag_name: ${{ github.ref }}
name: ${{ github.ref }}
body: |
This is a release for version ${{ github.ref }}.
It contains the compiled files from the build process.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@

This package enables Node.js applications to use a CAN bus over USB.

## Making a release
## Compiling

### Prerequisites

- Supported version of NodeJS (preferably a LTS version)
- A C/C++ compiler that supports C++20
- Internet connection to pull from upstream [CANBridge](https://github.com/unofficial-rev-port/CANBridge)

### Steps

1. Clone repository
2. Run `npm i` to install dependencies and compile the Node APIs
3. To test, run `npm run pretest` to prepare the testing and `npm test` to actually perform the testing of the repository

## Making a release (for repository owners)

1. Check out the `main` branch
2. Update `version` field in `package.json`
3. Run `npm install`
4. Commit change to git
5. Run `git tag v<version>`
6. Run `git push`
7. Run `git push --tags`
7. Run `git push --tags`
8. Run `npm publish --access public`
9. Create a new release on GitHub with an explanation of the changes
75 changes: 58 additions & 17 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'sources': [
'src/addon.cc',
'src/canWrapper.cc',
],
],
'include_dirs': [
"src/",
"externalCompileTimeDeps/include",
Expand All @@ -15,30 +15,71 @@
"NAPI_VERSION=<(napi_build_version)"
],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'libraries': [
# These files were placed by download-CanBridge.mjs
'<(module_root_dir)/externalCompileTimeDeps/CANBridge.lib',
'<(module_root_dir)/externalCompileTimeDeps/wpiHal.lib',
'<(module_root_dir)/externalCompileTimeDeps/wpiutil.lib',
'conditions': [
['OS=="mac"', {
'libraries': [
# These files were placed by download-CanBridge.mjs
'<(module_root_dir)/externalCompileTimeDeps/libCANBridge.a',
],
'copies': [{
'destination': './build/Release',
'files': [
# These files were placed in the prebuilds folder by download-CanBridge.mjs
'<(module_root_dir)/prebuilds/darwin-osxuniversal/libCANBridge.dylib',
'<(module_root_dir)/prebuilds/darwin-osxuniversal/libwpiHal.dylib',
'<(module_root_dir)/prebuilds/darwin-osxuniversal/libwpiutil.dylib',
]
}],
}],
['OS=="win"', {
'libraries': [
# These files were placed by download-CanBridge.mjs
'<(module_root_dir)/externalCompileTimeDeps/CANBridge.lib',
'<(module_root_dir)/externalCompileTimeDeps/wpiHal.lib',
'<(module_root_dir)/externalCompileTimeDeps/wpiutil.lib',
],
'copies': [{
'destination': './build/Release',
'files': [
# These files were placed in the prebuilds folder by download-CanBridge.mjs
'<(module_root_dir)/prebuilds/win32-x64/CANBridge.dll',
'<(module_root_dir)/prebuilds/win32-x64/wpiHal.dll',
'<(module_root_dir)/prebuilds/win32-x64/wpiutil.dll',
]
}],
}],
['OS=="linux"', {
'libraries': [
# These files were placed by download-CanBridge.mjs
'<(module_root_dir)/externalCompileTimeDeps/libCANBridge.a',
],
'copies': [{
'destination': './build/Release',
'files': [
# These files were placed in the prebuilds folder by download-CanBridge.mjs
'<(module_root_dir)/prebuilds/linux-x64/libCANBridge.so',
'<(module_root_dir)/prebuilds/linux-x64/libwpiHal.so',
'<(module_root_dir)/prebuilds/linux-x64/libwpiutil.so',
]
}],
}],
],
'copies': [{
'destination': './build/Release',
'files': [
# These files were placed in the prebuilds folder by download-CanBridge.mjs
'<(module_root_dir)/prebuilds/win32-x64/CANBridge.dll',
'<(module_root_dir)/prebuilds/win32-x64/wpiHal.dll',
'<(module_root_dir)/prebuilds/win32-x64/wpiutil.dll',
]
}],
'msvs_settings': {
'VCCLCompilerTool': {
'ExceptionHandling': 1,
'AdditionalOptions': [ '-std:c++20' ],
'RuntimeLibrary': 0
},
},
"cflags_cc!": ["-std=c++20", '-fno-exceptions'],
"cflags!": ["-std=c++20", '-fno-exceptions'],
"xcode_settings": {
"CLANG_CXX_LANGUAGE_STANDARD": "c++20",
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'GCC_ENABLE_CPP_RTTI': 'YES',
"OTHER_CPLUSPLUSFLAGS": ["-fexceptions"],
# 'MACOSX_DEPLOYMENT_TARGET': '14.0',
},
"cflags_cc": ["-std=c++20", '-fexceptions'],
"cflags": ["-std=c++20", '-fexceptions'],
}
]
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rev-robotics/can-bridge",
"version": "3.2.0",
"version": "3.2.6",
"author": "REV Robotics",
"description": "Access CAN Data from a USB device in Node.js",
"license": "MIT",
Expand All @@ -24,9 +24,9 @@
"typescript": "^5.0.2"
},
"scripts": {
"install": "node-gyp-build \"node scripts/download-CanBridge.mjs\"",
"install": "node scripts/download-CanBridge.mjs && node-gyp rebuild",
"prepublishOnly": "node scripts/download-CanBridge.mjs && tsc && prebuildify --napi",
"pretest": "node-gyp-build && tsc",
"pretest": "node-gyp rebuild && tsc",
qwertychouskie marked this conversation as resolved.
Show resolved Hide resolved
"test": "node --napi-modules test/test_binding.js"
},
"engines": {
Expand Down
Loading