Skip to content

Commit

Permalink
Initial bossa library and bossac utility
Browse files Browse the repository at this point in the history
- CXX Rust wrapper around bossa so it can be statically linked library
  into rust utilities (this is useful for Windows applications rather
  than relying on external processes).
  * To get the rust wrapper to work some C++ changes were necessary to
    cleanup the api. This probably would have been easier if the wider
    C++ apis were const'd correctly but I err'd on the side of minimal
    changes.
- bossac tries to be as close as possible to the C++ version of bossac
  (including cli args)
- Does not expose the complete bossa library api (only those necessary
  for bossac)
- An equivalent bossash should be possible, but I don't really use it so
  leaving it open to future contributions.
- The bossa WxWidgets utility is more difficult, but might be possible
  with https://github.com/kenz-gelsoft/wxRust2.
  Personally, I would probably recommend https://github.com/KDAB/cxx-qt.
  But I don't really use either so I'll leave these as open to future
  contributions.
- The existing C++ binaries should continue to function/build
- Fix formbuilder warning (info)
- Update wxWidgets mostly to 3.2
  * Keep Linux at 3.0 for Ubuntu GitHub Action
  • Loading branch information
haata committed Oct 12, 2023
1 parent a96c5a0 commit 4ef6c7a
Show file tree
Hide file tree
Showing 37 changed files with 1,704 additions and 1,514 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: "Audit Dependencies"
on:
push:
paths:
# Run if workflow changes
- '.github/workflows/audit.yml'
# Run on changed dependencies
- '**/Cargo.toml'
- '**/Cargo.lock'
# Run if the configuration file changes
- '**/audit.toml'
# Rerun periodicly to pick up new advisories
schedule:
- cron: '0 0 * * *'
# Run manually
workflow_dispatch:

permissions: read-all

jobs:
audit:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: dtolnay/rust-toolchain@nightly
- uses: actions-rust-lang/audit@v1
name: Audit Rust Dependencies
with:
ignore: RUSTSEC-2020-0071,RUSTSEC-2021-0139

deny:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: dtolnay/rust-toolchain@nightly
- name: cargo-binstall
run: |
mkdir -p ~/.cargo/bin
wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
tar xf cargo-binstall*.tgz -C ~/.cargo/bin
- run: cargo binstall --no-confirm cargo-deny
- name: Cargo Deny
run: cargo deny check licenses

pants:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: dtolnay/rust-toolchain@nightly
- name: cargo-binstall
run: |
mkdir -p ~/.cargo/bin
wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
tar xf cargo-binstall*.tgz -C ~/.cargo/bin
- run: cargo binstall --no-confirm cargo-pants
- name: Cargo Pants
run: cargo pants
59 changes: 44 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
name: Build Environment
name: Legacy Makefile Build Environment

on: [push, pull_request]

env:
PIPENV_ACTIVE: 1
deb_packages: >-
libreadline-dev
libwxgtk3.0-gtk3-dev
wx-common
wx3.0-headers
jobs:
linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libwxgtk3.0-dev libreadline-dev -y
sudo apt-get install -y ${{ env.deb_packages }}
- name: Build
run: |
make -j
make install
bin/bossac --help
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v3
if: always()
with:
name: linux
Expand All @@ -32,7 +39,9 @@ jobs:
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: Install dependencies
run: |
brew update
Expand All @@ -42,29 +51,49 @@ jobs:
make -j
make install
bin/bossac --help
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v3
if: always()
with:
name: macos
path: bin

# TODO: Not working currently!
windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- { sys: mingw32, env: i686 }
steps:
- uses: actions/checkout@v2
- uses: numworks/setup-msys2@v1
- uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- uses: msys2/setup-msys2@v2
with:
msystem: MSYS32
- run: msys2do pacman --noconfirm -S -noconfirm --noprogressbar
- run: msys2do pacman --noconfirm -U mingw-w64-*-any.pkg.tar.xz
- run: |
msystem: ${{matrix.sys}}
install: >-
base-devel
git
pacboy: >-
make
binutils
gcc
wxwidgets3.2-common
wxwidgets3.2-common-libs
wxwidgets3.2-gtk3
wxwidgets3.2-gtk3-libs
wxwidgets3.2-msw
wxwidgets3.2-msw-cb_headers
wxwidgets3.2-msw-libs
- name: Build
shell: msys2 {0}
run: |
set MSYSTEM=MINGW32
msys2do make -j
msys2do make install
mingw32-make -j
mingw32-make install
bin/bossac --help
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v3
if: always()
with:
name: windows
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/rust_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Rust Linux

on: [push, pull_request]

env:
deb_packages: >-
libreadline-dev
libwxgtk3.0-gtk3-dev
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y ${{ env.deb_packages }}
- name: Cargo Check
run: cargo check --all

build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y ${{ env.deb_packages }}
- name: ls
run: |
ls
pwd
- name: Cargo Build
run: cargo build --all
- name: Cargo Install
run: cargo install --path bossac --bins --root dist
- uses: actions/upload-artifact@v3
with:
name: linux_release_binaries
path: dist/bin

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y ${{ env.deb_packages }}
- name: Cargo Clippy
run: cargo clippy --all-targets -- -D warnings

udeps:
name: cargo-udeps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: dtolnay/rust-toolchain@nightly
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y ${{ env.deb_packages }}
- name: cargo-binstall
run: |
mkdir -p ~/.cargo/bin
wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
tar xf cargo-binstall*.tgz -C ~/.cargo/bin
- run: cargo binstall --no-confirm cargo-udeps
- name: Cargo Udeps
run: cargo udeps --all-targets
17 changes: 17 additions & 0 deletions .github/workflows/rust_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Rust macOS

on: [push, pull_request]

jobs:
build:
name: Build
runs-on: macOS-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- name: Cargo Install
run: cargo install --path bossac --bins --root dist
- uses: actions/upload-artifact@v3
with:
name: macos_release_binaries
path: dist/bin
17 changes: 17 additions & 0 deletions .github/workflows/rust_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Rust Windows

on: [push, pull_request]

jobs:
build:
name: Build
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- name: Cargo Install
run: cargo install --path bossac --bins --root dist
- uses: actions/upload-artifact@v3
with:
name: win_release_binaries
path: dist/bin
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
obj
*.exe
*~
bossa
bossac
bin
*.swp
tags
*.bak
install/*.crt
install/*.p12

Cargo.lock
target/

# Extras for building with MSVC
x64/
ipch/
Expand Down
19 changes: 19 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "bossa"
version = "2.0.0"
authors = ["Jacob Alexander <[email protected]>, Scott Shumate <[email protected]>"]
description = "Rust cxx wrapper around BOSSA SAM-BA library"
edition = "2021"
license = "BSD-3-Clause"
repository = "https://github.com/kiibohd/BOSSA"

[workspace]
members = [
"bossac"
]

[dependencies]
cxx = "1.0"

[build-dependencies]
cxx-build = "1.0"
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ OS:=$(shell uname -s | cut -c -7)
#
ifeq ($(OS),MINGW32)
# Use wxWindows development branch to work around font scaling issues on Windows
WXVERSION=3.1
WXVERSION=3.2
EXE=.exe
COMMON_SRCS+=WinSerialPort.cpp WinPortFactory.cpp
COMMON_LDFLAGS=-Wl,--enable-auto-import -static -static-libstdc++ -static-libgcc
COMMON_LIBS=-ltermcap -Wl,--as-needed -lsetupapi
COMMON_LIBS=-ltermcap -Wl,--as-needed -lsetupapi -lole32
COMMON_CXXFLAGS=-std=c++14
BOSSA_RC=BossaRes.rc
WIXDIR="C:\Program Files (x86)\WiX Toolset v3.11\bin"
CODE_SIGN=$(INSTALLDIR)\\code_sign.p12
Expand Down Expand Up @@ -85,7 +86,7 @@ endif
ifeq ($(OS),Linux)
COMMON_SRCS+=PosixSerialPort.cpp LinuxPortFactory.cpp
COMMON_LIBS=-Wl,--as-needed
COMMON_CXXFLAGS=-std=c++11
COMMON_CXXFLAGS=-std=c++14
WX_LIBS+=-lX11

MACHINE:=$(shell uname -m)
Expand All @@ -98,9 +99,10 @@ endif
# OS X rules
#
ifeq ($(OS),Darwin)
WXVERSION=3.2
COMMON_SRCS+=PosixSerialPort.cpp OSXPortFactory.cpp
COMMON_CXXFLAGS=-arch x86_64 -mmacosx-version-min=10.9
COMMON_LDFLAGS=-arch x86_64 -mmacosx-version-min=10.9
COMMON_CXXFLAGS=-arch x86_64 -mmacosx-version-min=11 -std=c++14
COMMON_LDFLAGS=-arch x86_64 -mmacosx-version-min=11
APP=BOSSA.app
DMG=bossa-$(VERSION).dmg
VOLUME=BOSSA
Expand Down
Loading

0 comments on commit 4ef6c7a

Please sign in to comment.