Skip to content

Commit 052abf5

Browse files
authored
chore: add nix derivation, update dependencies, readme (#82)
- add nix derivation - update readme to reflect support status and new nuphy keyboards - nodejs no longer required to build CLI - remove all submodules and replace with `find_package` invocations in CMake with `FetchContent` fallbacks
1 parent 5dea5a6 commit 052abf5

34 files changed

Lines changed: 785 additions & 21017 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
path: ./nudelta-x64.exe.zip
4040
linux:
4141
name: Build (Linux)
42-
runs-on: ubuntu-22.04
42+
runs-on: ubuntu-24.04
4343
steps:
4444
- name: Check out Git repository
4545
uses: actions/checkout@v4
@@ -113,7 +113,7 @@ jobs:
113113
path: ./nudelta-${{ matrix.os.arch }}.app.dmg
114114
publish:
115115
name: Publish
116-
runs-on: ubuntu-20.04
116+
runs-on: ubuntu-24.04
117117
needs: [macos, linux, windows]
118118
steps:
119119
- name: Check out Git repository

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ yarn-error.log
2727
!OSAcknowledgements.txt
2828

2929
# Python
30-
venv
30+
venv
31+
result

.gitmodules

Lines changed: 0 additions & 15 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ cmake_policy(SET CMP0042 NEW)
66

77
project(nudelta)
88

9-
if(NOT DEFINED NODE_RUNTIME)
10-
message( FATAL_ERROR "NODE_RUNTIME is not defined. Use `cmake-js` from the root of the repo." )
11-
endif()
12-
139
# Get version from package.json
1410
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/package.json PACKAGE_JSON)
1511
string(JSON NUDELTA_VERSION GET ${PACKAGE_JSON} "version")
@@ -19,86 +15,78 @@ set(CMAKE_CXX_STANDARD 17)
1915
set(CMAKE_CXX_STANDARD_REQUIRED True)
2016
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2117
set(BUILD_SHARED_LIBS FALSE)
22-
set(CMAKE_OSX_DEPLOYMENT_TARGET "11")
18+
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.3")
2319

2420
if(APPLE)
25-
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
26-
set(CMAKE_HAVE_THREADS_LIBRARY 1)
27-
set(CMAKE_USE_WIN32_THREADS_INIT 0)
28-
set(CMAKE_USE_PTHREADS_INIT 1)
29-
set(THREADS_PREFER_PTHREAD_FLAG ON)
21+
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
22+
set(CMAKE_HAVE_THREADS_LIBRARY 1)
23+
set(CMAKE_USE_WIN32_THREADS_INIT 0)
24+
set(CMAKE_USE_PTHREADS_INIT 1)
25+
set(THREADS_PREFER_PTHREAD_FLAG ON)
3026
endif()
3127

32-
# Hidapi does not use `option`
33-
set(HIDAPI_WITH_LIBUSB FALSE)
34-
set(HIDAPI_WITH_HIDRAW TRUE)
35-
add_subdirectory(submodules/hidapi)
36-
37-
option(YAML_CPP_BUILD_TOOLS OFF)
38-
add_subdirectory(submodules/yaml-cpp)
39-
40-
add_subdirectory(submodules/scope_guard)
41-
42-
add_subdirectory(submodules/fmt)
43-
44-
add_subdirectory(submodules/ssco)
28+
# Dependencies
29+
include(third_party/CMakeLists.txt)
4530

4631
# Common
4732
include_directories(include)
4833

4934
# YAML Data
5035
file (GLOB_RECURSE yml_files "res/**/*.yml")
36+
find_program(RUBY_EXECUTABLE ruby)
37+
if(RUBY_EXECUTABLE)
38+
message(STATUS "ruby found at: ${RUBY_EXECUTABLE}")
39+
else()
40+
message(FATAL_ERROR "ruby not found in PATH and is required for an intermediate build step.")
41+
endif()
5142
add_custom_command(
52-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/res.cpp
53-
COMMAND node ${CMAKE_CURRENT_LIST_DIR}/util/res_to_cpp.js ${CMAKE_CURRENT_LIST_DIR}/res > ${CMAKE_CURRENT_BINARY_DIR}/res.cpp
54-
DEPENDS ${yml_files} util/res_to_cpp.js
43+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/res.cpp
44+
COMMAND ${RUBY_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/util/res2cxx.rb ${CMAKE_CURRENT_LIST_DIR}/res > ${CMAKE_CURRENT_BINARY_DIR}/res.cpp
45+
DEPENDS ${yml_files} util/res2cxx.rb
5546
)
5647
add_custom_target(res_file ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/res.cpp)
5748

5849
include_directories(res)
5950

6051
# libnd
52+
include_directories(${CMAKE_JS_INC})
6153
file(GLOB nudelta_lib_src "lib/*.cpp")
6254
add_library(nd ${nudelta_lib_src} ${CMAKE_CURRENT_BINARY_DIR}/res.cpp)
6355
add_dependencies(nd res_file)
56+
target_link_libraries(nd PUBLIC fmt)
6457
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
65-
target_link_libraries(nd hidapi::hidraw)
58+
target_link_libraries(nd PUBLIC hidapi::hidraw)
6659
else()
67-
target_link_libraries(nd hidapi)
60+
target_link_libraries(nd PUBLIC hidapi)
6861
endif()
69-
target_link_libraries(nd yaml-cpp)
70-
target_link_libraries(nd fmt)
71-
target_link_libraries(nd scope_guard)
62+
target_link_libraries(nd PRIVATE yaml-cpp)
63+
target_link_libraries(nd PRIVATE $<COMPILE_ONLY:scope_guard>)
7264

7365
if(!MSVC)
7466
target_compile_options(nd -Wall -Wextra -Wpedantic -Werror)
7567
endif()
7668

69+
if(DEFINED NODE_RUNTIME)
70+
# node-libnd
71+
add_definitions(-DNAPI_VERSION=4)
72+
include_directories(${CMAKE_JS_INC})
73+
include_directories(${CMAKE_SOURCE_DIR}/node_modules/node-addon-api)
74+
include_directories(${CMAKE_SOURCE_DIR}/node_modules/node-api-headers/include)
7775

78-
# node-libnd
79-
add_definitions(-DNAPI_VERSION=4)
80-
include_directories(${CMAKE_JS_INC})
81-
include_directories(${CMAKE_SOURCE_DIR}/node_modules/node-addon-api)
82-
include_directories(${CMAKE_SOURCE_DIR}/node_modules/node-api-headers/include)
83-
add_library(node-libnd SHARED src/node.cpp ${CMAKE_JS_SRC})
84-
target_link_libraries(node-libnd nd)
85-
target_link_libraries(node-libnd ${CMAKE_JS_LIB})
76+
add_library(node-libnd SHARED src/node.cpp ${CMAKE_JS_SRC})
77+
target_link_libraries(node-libnd nd)
78+
target_link_libraries(node-libnd ${CMAKE_JS_LIB})
8679

87-
set_target_properties(node-libnd PROPERTIES PREFIX "" SUFFIX ".node")
80+
set_target_properties(node-libnd PROPERTIES PREFIX "" SUFFIX ".node")
81+
endif()
8882

8983
# nudelta
90-
add_executable(nudelta src/main.cpp)
84+
add_executable(nudelta-cli src/main.cpp)
9185
add_compile_definitions(NUDELTA_VERSION="${CMAKE_PROJECT_VERSION}")
92-
target_link_libraries(nudelta nd)
93-
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
94-
target_link_libraries(nudelta hidapi::hidraw)
95-
else()
96-
target_link_libraries(nudelta hidapi)
97-
endif()
98-
target_link_libraries(nudelta yaml-cpp)
99-
target_link_libraries(nudelta fmt)
100-
target_link_libraries(nudelta ssco)
101-
target_link_libraries(nudelta scope_guard)
86+
target_link_libraries(nudelta-cli PUBLIC nd)
87+
target_link_libraries(nudelta-cli PRIVATE $<COMPILE_ONLY:scope_guard>)
88+
target_link_libraries(nudelta-cli PRIVATE ssco)
89+
10290

10391

104-
install(TARGETS nudelta)
92+
install(TARGETS nudelta-cli)

Changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# 0.9.0
2+
3+
This update has no functional changes to Nudelta itself.
4+
5+
- Add Nix derivation
6+
- Update readme to reflect support status and status of new NuPhy keyboards
7+
- Nodejs no longer required to build CLI
8+
- Remove all submodules and replace with `find_package` invocations in CMake
9+
with `FetchContent` fallbacks
10+
111
# 0.8.0
212
- Build macOS architectures independently using both Intel and Apple Silicon Mac
313
free GitHub Actions runners, rectifying a long-standing issue where writing

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM quay.io/pypa/manylinux_2_28_x86_64
22

33
# Dependencies
4-
## Python
4+
## CMake (pip is the most reliable option)
55
RUN python3 -m ensurepip
66
RUN python3 -m pip install --upgrade pip wheel
77
RUN python3 -m pip install cmake
@@ -15,6 +15,9 @@ RUN npm i -g yarn
1515
## LibUSB
1616
RUN yum install -y libudev-devel
1717

18+
## Ruby
19+
RUN yum install -y ruby
20+
1821
##
1922
WORKDIR /nudelta
2023
COPY . .

0 commit comments

Comments
 (0)