From 28f9f41b9a8285396afdbadc9a73215f21dd9cdc Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Mon, 28 Aug 2023 10:44:29 +0300 Subject: [PATCH] Fix indices for brackets + macOS Universal Builds (#62) Resolves #61 --- .github/workflows/ci.yml | 21 ++++++---- CMakeLists.txt | 80 +++++++++++++++++++++------------------ Changelog.md | 5 +++ package.json | 12 ++++-- res/Air75/indices_mac.yml | 4 +- res/Air75/indices_win.yml | 4 +- 6 files changed, 74 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ded0bfb..e7a38b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,12 +81,12 @@ jobs: run: | yarn yarn build - cp -r ./dist/*.zip ./nudelta-amd64.app.zip + cp -r ./dist/*.dmg ./nudelta-universal.app.dmg - name: Upload App uses: actions/upload-artifact@v3 with: name: mac-app - path: ./nudelta-amd64.app.zip + path: ./nudelta-universal.app.dmg publish: name: Publish runs-on: ubuntu-20.04 @@ -139,13 +139,20 @@ jobs: A Windows `.exe`, a macOS `.app` and a Linux `.AppImage` have all been built. - On Windows, you will need to download and unzip the `.exe` file. You may see a Windows SmartScreen warning- you can safely ignore it. + On Windows, you will need to download and unzip the `.exe` file. + You may see a Windows SmartScreen warning- you can safely ignore it. - On macOS, you will need to download and unzip the `.app` file, then **Right-click > Open** the app on macOS. The app is not code-signed or notarized. - * Please note that you may need Rosetta 2 as there is no Apple Silicon build at the moment: first, though, please see the [Rosetta advisory in the Readme](https://github.com/donn/nudelta#rosetta). + On macOS, you will need to download the `.dmg` file, drag it into + your Applications folder, then **Right-click > Open** the app on + macOS. The app is not code-signed or notarized, and while it is + universal, writing only works on x86-64 + (see: https://github.com/donn/nudelta/issues/37). + Use at your own risk. - On Linux, download the `.AppImage`, enable "allow executing file as program" in its properties (shown below), then double-click it. - * You may need to install `libudev` separately- on Ubuntu, you can run `sudo apt-get install -y libudev`. + On Linux, download the `.AppImage`, enable "allow executing file as + program" in its properties (shown below), then double-click it. + * You may need to install `libudev` separately- on Ubuntu, you can + run `sudo apt-get install -y libudev`. ![Setting Linux execute permission with the GNOME File Browser](https://raw.githubusercontent.com/donn/nudelta/main/res/linux_exec_permission.png) files: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 006ad0b..6af00ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ cmake_policy(SET CMP0042 NEW) project(nudelta) +if(NOT DEFINED NODE_RUNTIME) + message( FATAL_ERROR "NODE_RUNTIME is not defined. Use `cmake-js` from the root of the repo." ) +endif() + # Get version from package.json file(READ ${CMAKE_CURRENT_SOURCE_DIR}/package.json PACKAGE_JSON) string(JSON NUDELTA_VERSION GET ${PACKAGE_JSON} "version") @@ -13,9 +17,19 @@ set(PROJECT_VERSION ${NUDELTA_VERSION}) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) -set(CMAKE_OSX_ARCHITECTURES x86_64) +set(CMAKE_OSX_ARCHITECTURES arm64;x86_64) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(BUILD_SHARED_LIBS FALSE) +set(CMAKE_OSX_DEPLOYMENT_TARGET "11") + +if(APPLE) + set(NODE_ARCH arm64;x86_64) + set(CMAKE_THREAD_LIBS_INIT "-lpthread") + set(CMAKE_HAVE_THREADS_LIBRARY 1) + set(CMAKE_USE_WIN32_THREADS_INIT 0) + set(CMAKE_USE_PTHREADS_INIT 1) + set(THREADS_PREFER_PTHREAD_FLAG ON) +endif() # Hidapi does not use `option` set(HIDAPI_WITH_LIBUSB FALSE) @@ -26,7 +40,9 @@ option(YAML_CPP_BUILD_TOOLS OFF) add_subdirectory(submodules/yaml-cpp) add_subdirectory(submodules/scope_guard) + add_subdirectory(submodules/fmt) + add_subdirectory(submodules/ssco) # Common @@ -48,53 +64,43 @@ file(GLOB nudelta_lib_src "lib/*.cpp") add_library(nd ${nudelta_lib_src} ${CMAKE_CURRENT_BINARY_DIR}/res.cpp) add_dependencies(nd res_file) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - target_link_libraries(nd PRIVATE hidapi::hidraw) -else () - target_link_libraries(nd PRIVATE hidapi) -endif () -target_link_libraries(nd PRIVATE yaml-cpp) -target_link_libraries(nd PRIVATE fmt) -target_link_libraries(nd PRIVATE scope_guard) + target_link_libraries(nd hidapi::hidraw) +else() + target_link_libraries(nd hidapi) +endif() +target_link_libraries(nd yaml-cpp) +target_link_libraries(nd fmt) +target_link_libraries(nd scope_guard) if(!MSVC) - target_compile_options(nd PRIVATE -Wall -Wextra -Wpedantic -Werror) + target_compile_options(nd -Wall -Wextra -Wpedantic -Werror) endif() # node-libnd -if (NODE_RUNTIME) - add_definitions(-DNAPI_VERSION=4) - include_directories(${CMAKE_JS_INC}) - include_directories(${CMAKE_SOURCE_DIR}/node_modules/node-addon-api) - include_directories(${CMAKE_SOURCE_DIR}/node_modules/node-api-headers/include) - add_library(node-libnd SHARED src/node.cpp ${CMAKE_JS_SRC}) - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - target_link_libraries(node-libnd PRIVATE hidapi::hidraw) - else () - target_link_libraries(node-libnd PRIVATE hidapi) - endif () - target_link_libraries(node-libnd PRIVATE yaml-cpp) - target_link_libraries(node-libnd PRIVATE fmt) - target_link_libraries(node-libnd PRIVATE scope_guard) - target_link_libraries(node-libnd PRIVATE nd) - target_link_libraries(node-libnd PRIVATE ${CMAKE_JS_LIB}) - - set_target_properties(node-libnd PROPERTIES PREFIX "" SUFFIX ".node") -endif() +add_definitions(-DNAPI_VERSION=4) +include_directories(${CMAKE_JS_INC}) +include_directories(${CMAKE_SOURCE_DIR}/node_modules/node-addon-api) +include_directories(${CMAKE_SOURCE_DIR}/node_modules/node-api-headers/include) +add_library(node-libnd SHARED src/node.cpp ${CMAKE_JS_SRC}) +target_link_libraries(node-libnd nd) +target_link_libraries(node-libnd ${CMAKE_JS_LIB}) + +set_target_properties(node-libnd PROPERTIES PREFIX "" SUFFIX ".node") # nudelta add_executable(nudelta src/main.cpp) add_compile_definitions(NUDELTA_VERSION="${CMAKE_PROJECT_VERSION}") -target_link_libraries(nudelta PRIVATE nd) +target_link_libraries(nudelta nd) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - target_link_libraries(nudelta PRIVATE hidapi::hidraw) -else () - target_link_libraries(nudelta PRIVATE hidapi) -endif () -target_link_libraries(nudelta PRIVATE yaml-cpp) -target_link_libraries(nudelta PRIVATE fmt) -target_link_libraries(nudelta PRIVATE ssco) -target_link_libraries(nudelta PRIVATE scope_guard) + target_link_libraries(nudelta hidapi::hidraw) +else() + target_link_libraries(nudelta hidapi) +endif() +target_link_libraries(nudelta yaml-cpp) +target_link_libraries(nudelta fmt) +target_link_libraries(nudelta ssco) +target_link_libraries(nudelta scope_guard) install(TARGETS nudelta) \ No newline at end of file diff --git a/Changelog.md b/Changelog.md index 7a90918..3a36471 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,8 @@ +# 0.7.4 +- Fix internal indices for `[` and `]` for Air75 +- Build universal binary for macOS +- Internal changes to build system + # 0.7.3 - Fix USB handle mixup affecting Windows builds - Fix GUI bug with remapping alternate IDs diff --git a/package.json b/package.json index 492850f..05108c5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nudelta", "author": "Mohamed Gaber ", - "version": "0.7.3", + "version": "0.7.4", "license": "GPL-3.0-or-later", "homepage": "https://github.com/donn/nudelta#readme", "description": "An open-source alternative to the NuPhy Console", @@ -44,8 +44,7 @@ "main": "index.cjs", "cmake-js": { "runtime": "electron", - "runtimeVersion": "21.2.1", - "arch": "x64" + "runtimeVersion": "21.2.1" }, "build": { "appId": "website.donn.nudelta", @@ -58,7 +57,12 @@ "mac": { "category": "public.app-category.utilities", "target": [ - "zip" + { + "target": "dmg", + "arch": [ + "universal" + ] + } ], "icon": "./res/nudelta.icns" }, diff --git a/res/Air75/indices_mac.yml b/res/Air75/indices_mac.yml index dab9423..977723c 100644 --- a/res/Air75/indices_mac.yml +++ b/res/Air75/indices_mac.yml @@ -65,8 +65,8 @@ semicolon: 63 minus: 67 equal: 73 quote: 69 -lbracket: 68 -rbracket: 159 +lbracket: 159 +rbracket: 68 backslash: 160 fwdslash: 64 comma: 164 diff --git a/res/Air75/indices_win.yml b/res/Air75/indices_win.yml index 46e73eb..8fa1b9f 100644 --- a/res/Air75/indices_win.yml +++ b/res/Air75/indices_win.yml @@ -70,8 +70,8 @@ semicolon: 63 minus: 67 equal: 73 quote: 69 -lbracket: 68 -rbracket: 159 +lbracket: 159 +rbracket: 68 backslash: 160 fwdslash: 64 comma: 164