Skip to content

Commit

Permalink
Rewrite SQUIRREL
Browse files Browse the repository at this point in the history
* BREAKING: start over

* add basic structure

* feat: add basic structure and logic for consumer control, quantum functions and keyboard presses

* feat: add press and release key functions

* feat: add testing

* feat: include SQUIRREL in test

* tests: add test key

* feat: add a proper test

* feat: add github workflows and nix checks

* fix: reduce large logs from gh action

* feat: use variable arg functions for key funcs

* fix: keyboard_press_release fails

* feat: lib .a files as gh action asset

* feat: add more tests, add placeholder for quantum_passthrough_press_release

* feat: add expected error testing

* fix: linker issues from CMakeLists, quantum_passthrough functions, added an init function, moved key to squirrel_key

* fix: quantum_passthrough_press_release failing

* feat: add code coverage to tests

* fix: nix flake check run fails

* chore: rename keyboard functions to prepend 'keyboard_'

* feat: add tests for keyboard_get_keycodes consumer_press_release, add testing for errors in some tests, add consumer code functions to squirrel_quantum

* feat: switch from stdarg to void**, add tests for squirrel_key

* feat: add boilerplate and tests for layer_press_release functions

* feat: add tests for layer_press_release

* feat: add new tests, and fix the layer functions

* fix: check_key failing

* feat: deinit function

* feat: test copy of key to layer 16, rename init_keyboard to squirrel_init
  • Loading branch information
headblockhead authored Aug 26, 2024
1 parent dd34464 commit 798f6b9
Show file tree
Hide file tree
Showing 39 changed files with 2,297 additions and 439 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build-library.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build with Nix
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix build '.?submodules=1#squirrel'
- uses: actions/upload-artifact@v4
with:
name: libsquirrel.a
path: result/libsquirrel.a

13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test with Nix
on: [push, pull_request]

jobs:
run-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix flake check
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Nix ignores
result

# CMake ignores
CMakeLists.txt.user
CMakeCache.txt
Expand Down
70 changes: 59 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,62 @@ project(squirrel VERSION 0.0.1 DESCRIPTION "Simplified, runtime-configurable QMK

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Debug/Development build enabled")
# Create files for CCLS
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Autocomplete support
add_compile_options(-Og) # Enable debug optimizations
elseif(CMAKE_BUILD_TYPE STREQUAL "Testing")
message(STATUS "Testing enabled")
include(CTest)
enable_testing()

include_directories(include)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")
if(CMAKE_COMPILER_IS_GNUCXX)
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
setup_target_for_coverage_gcovr_html(squirrel squirrel_test coverage)
list(APPEND GCOVR_EXCLUDES "tests/")
endif()

add_executable(keyboard_press_release tests/keyboard_press_release.c)
target_link_libraries(keyboard_press_release squirrel)
add_test(NAME keyboard_press_release COMMAND keyboard_press_release)

add_executable(keyboard_modifier_press_release tests/keyboard_modifier_press_release.c)
target_link_libraries(keyboard_modifier_press_release squirrel)
add_test(NAME keyboard_modifier_press_release COMMAND keyboard_modifier_press_release)

add_executable(quantum_passthrough_press_release tests/quantum_passthrough_press_release.c)
target_link_libraries(quantum_passthrough_press_release squirrel)
add_test(NAME quantum_passthrough_press_release COMMAND quantum_passthrough_press_release)

add_executable(keyboard_get_keycodes tests/keyboard_get_keycodes.c)
target_link_libraries(keyboard_get_keycodes squirrel)
add_test(NAME keyboard_get_keycodes COMMAND keyboard_get_keycodes)

add_executable(consumer_press_release tests/consumer_press_release.c)
target_link_libraries(consumer_press_release squirrel)
add_test(NAME consumer_press_release COMMAND consumer_press_release)

add_executable(key tests/key.c)
target_link_libraries(key squirrel)
add_test(NAME key COMMAND key)

add_executable(layer_press_release tests/layer_press_release.c)
target_link_libraries(layer_press_release squirrel)
add_test(NAME layer_press_release COMMAND layer_press_release)

add_executable(consumer_activate_deactivate_get_consumer_code tests/consumer_activate_deactivate_get_consumer_code.c)
target_link_libraries(consumer_activate_deactivate_get_consumer_code squirrel)
add_test(NAME consumer_activate_deactivate_get_consumer_code COMMAND consumer_activate_deactivate_get_consumer_code)

add_executable(keyboard_activate_deactivate_keycode tests/keyboard_activate_deactivate_keycode.c)
target_link_libraries(keyboard_activate_deactivate_keycode squirrel)
add_test(NAME keyboard_activate_deactivate_keycode COMMAND keyboard_activate_deactivate_keycode)

add_executable(keyboard_activate_deactivate_get_modifier tests/keyboard_activate_deactivate_get_modifier.c)
target_link_libraries(keyboard_activate_deactivate_get_modifier squirrel)
add_test(NAME keyboard_activate_deactivate_get_modifier COMMAND keyboard_activate_deactivate_get_modifier)
else()
add_compile_options(-Os) # Enable size optimizations
endif()
Expand All @@ -15,18 +68,13 @@ endif()
add_library(squirrel STATIC
src/squirrel.c
src/squirrel_quantum.c
src/squirrel_keys.c
src/squirrel_constructors.c
src/squirrel_keyboard.c
src/squirrel_key.c
src/squirrel_consumer.c
src/squirrel_init.c
)

target_include_directories(squirrel PRIVATE include)

set_target_properties(squirrel PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(squirrel PROPERTIES PUBLIC_HEADER include/squirrel.h)

# Enable testing
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
message(STATUS "Testing enabled")
add_subdirectory(tests)
endif()

Loading

0 comments on commit 798f6b9

Please sign in to comment.