Skip to content

Commit

Permalink
Merge pull request #1 from dexter93/native_hidapi
Browse files Browse the repository at this point in the history
sonixflasher: overhaul the build logic
  • Loading branch information
dexter93 authored Jun 1, 2023
2 parents 41ae51c + 1976010 commit 132d05b
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 104 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Make CI

on:
push:
branches: [ main ]
release:
types:
- published
pull_request:
workflow_dispatch:

jobs:
build-linux:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install libudev and libhidapi
run: sudo apt-get install -y libudev-dev libhidapi-dev

- name: Compile SonixFlasherC
run: |
make clean package
- name: Find artifact files
id: find-files
run: |
find . -type f -name "sonixflasher-*.zip" -print > artifact_files.txt
files=$(cat artifact_files.txt)
echo "FILES=$files" >> $GITHUB_ENV
- uses: actions/[email protected]
with:
name: SonixFlasherC-Linux
path: ${{ env.FILES }}

build-mac:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3

- name: Install hidapi
run: |
brew update
brew install hidapi
- name: Compile SonixFlasherC
run: |
make clean package
- name: Find artifact files
id: find-files
run: |
find . -type f -name "sonixflasher-*.zip" -print > artifact_files.txt
files=$(cat artifact_files.txt)
echo "FILES=$files" >> $GITHUB_ENV
- uses: actions/[email protected]
with:
name: SonixFlasherC-macOS
path: ${{ env.FILES }}

build-windows:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}

steps:
- uses: actions/checkout@v3
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: git p7zip dos2unix mingw-w64-x86_64-pkg-config mingw-w64-x86_64-cc mingw-w64-x86_64-hidapi make

- name: Compile SonixFlasherC
run: |
make clean sonixflasher package
- name: Find artifact files
id: find-files
run: |
find . -type f -name "sonixflasher-*.zip" -print > artifact_files.txt
files=$(cat artifact_files.txt)
echo "FILES=$files" >> $GITHUB_ENV
- uses: actions/[email protected]
with:
name: SonixFlasherC-Windows
path: ${{ env.FILES }}

publish_release:
name: Publish (Release)
runs-on: ubuntu-latest

needs: [build-linux, build-mac, build-windows]

if: github.event.release.tag_name

steps:
- uses: actions/download-artifact@v3

- uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ github.event.release.name }}
files: |
${{ github.workspace }}/*/*
fail_on_unmatched_files: true
80 changes: 0 additions & 80 deletions .github/workflows/c-cpp.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

19 changes: 8 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# path for HID
HIDAPI_DIR ?= ./hidapi

# try to do some autodetecting
UNAME := $(shell uname -s)
ARCH := $(shell uname -m)
Expand All @@ -24,18 +21,17 @@ endif
############# Mac
ifeq "$(OS)" "macos"

CFLAGS+=-arch x86_64 -arch arm64
LIBS=-framework IOKit -framework CoreFoundation -framework AppKit
OBJS=$(HIDAPI_DIR)/mac/hid.o
CFLAGS+=`pkg-config hidapi --cflags`
LIBS=-lhidapi -framework IOKit -framework CoreFoundation -framework AppKit
EXE=

endif

############# Windows
ifeq "$(OS)" "windows"

LIBS += -lsetupapi -Wl,--enable-auto-import -static-libgcc -static-libstdc++
OBJS = $(HIDAPI_DIR)/windows/hid.o
CFLAGS+=`pkg-config hidapi --cflags`
LIBS+= -lhidapi -lsetupapi -Wl,--enable-auto-import -static-libgcc -static-libstdc++
EXE=.exe

endif
Expand All @@ -44,15 +40,16 @@ endif
ifeq "$(OS)" "linux"

LIBS = `pkg-config libudev --libs`
OBJS = $(HIDAPI_DIR)/linux/hid.o
CFLAGS+=`pkg-config hidapi-libusb --cflags`
LIBS+=`pkg-config hidapi-libusb --libs`
EXE=

endif


############# common

CFLAGS+=-Wall -I $(HIDAPI_DIR)/hidapi
CFLAGS+=-Wall
OBJS += sonixflasher.o

all: sonixflasher
Expand All @@ -70,4 +67,4 @@ clean:

package: sonixflasher$(EXE)
@echo "Packaging up sonixflasher for '$(OS)-$(ARCH)'"
zip sonixflasher-$(OS)-$(ARCH).zip sonixflasher$(EXE)
7z a sonixflasher-$(OS)-$(ARCH).zip sonixflasher$(EXE)
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ Features:

### Dependencies

Clone this repository recursively:
Clone this repository:
```
git clone --recursive https://github.com/SonixQMK/SonixFlasherC
git clone https://github.com/SonixQMK/SonixFlasherC
```

[hidapi](https://github.com/libusb/hidapi) is a prequisite.
If using windows, please install MinGW

### Compiling
Expand Down
1 change: 0 additions & 1 deletion hidapi
Submodule hidapi deleted from e08ddc
Loading

0 comments on commit 132d05b

Please sign in to comment.