Skip to content

Commit

Permalink
Merge branch 'main' into detect-chg
Browse files Browse the repository at this point in the history
  • Loading branch information
ReFil committed Dec 13, 2023
2 parents 87535dc + 2c50cff commit 6c1b3bf
Show file tree
Hide file tree
Showing 565 changed files with 6,103 additions and 1,505 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ fi
if [ -f "$WORKSPACE_DIR/zephyr/zephyr-env.sh" ]; then
source "$WORKSPACE_DIR/zephyr/zephyr-env.sh"
fi

if [ -d "$WORKSPACE_DIR/tools/bsim" ]; then
export BSIM_OUT_PATH="$WORKSPACE_DIR/tools/bsim/"
export BSIM_COMPONENTS_PATH="$WORKSPACE_DIR/tools/bsim/components/"
fi
10 changes: 7 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
"type=volume,source=zmk-zephyr-modules,target=${containerWorkspaceFolder}/modules",
"type=volume,source=zmk-zephyr-tools,target=${containerWorkspaceFolder}/tools"
],
"extensions": ["ms-vscode.cpptools"],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
"customizations": {
"vscode": {
"extensions": ["ms-vscode.cpptools"],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
}
}
},
"forwardPorts": [3000]
}
78 changes: 78 additions & 0 deletions .github/workflows/ble-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: BLE Tests

on:
push:
paths:
- ".github/workflows/ble-test.yml"
- "app/tests/ble/**"
- "app/src/**"
- "app/run-ble-test.sh"
pull_request:
paths:
- ".github/workflows/ble-test.yml"
- "app/tests/ble/**"
- "app/src/**"
- "app/run-ble-test.sh"

jobs:
collect-tests:
outputs:
test-dirs: ${{ steps.test-dirs.outputs.test-dirs }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Find test directories
id: test-dirs
run: |
cd app/tests/ble
export TESTS=$(ls -d * | grep -v central | jq -R -s -c 'split("\n")[:-1]')
echo "::set-output name=test-dirs::${TESTS}"
run-tests:
needs: collect-tests
strategy:
matrix:
test: ${{ fromJSON(needs.collect-tests.outputs.test-dirs) }}
runs-on: ubuntu-latest
container:
image: docker.io/zmkfirmware/zmk-build-arm:3.2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache west modules
uses: actions/[email protected]
env:
cache-name: cache-zephyr-modules
with:
path: |
modules/
tools/
zephyr/
bootloader/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('app/west.yml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
timeout-minutes: 2
continue-on-error: true
- name: Initialize workspace (west init)
run: west init -l app
- name: Enable babblesim group filter
run: west config manifest.group-filter -- +babblesim
- name: Update modules (west update)
run: west update
- name: Export Zephyr CMake package (west zephyr-export)
run: west zephyr-export
- name: Build BabbleSim components
working-directory: tools/bsim
run: make everything
- name: Test ${{ matrix.test }}
working-directory: app
run: BSIM_COMPONENTS_PATH="${GITHUB_WORKSPACE}/tools/bsim/components/" BSIM_OUT_PATH="${GITHUB_WORKSPACE}/tools/bsim/" ./run-ble-test.sh tests/ble/${{ matrix.test }}
- name: Archive artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: "log-files"
path: app/build/**/*.log
73 changes: 49 additions & 24 deletions .github/workflows/build-user-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,39 @@ jobs:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.build_matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Create build directory
run: |
echo "build_dir=$(mktemp -d)" >> $GITHUB_ENV
- name: Prepare variables
shell: sh -x {0}
env:
board: ${{ matrix.board }}
shield: ${{ matrix.shield }}
artifact_name: ${{ matrix.artifact-name }}
run: |
if [ -e zephyr/module.yml ]; then
export zmk_load_arg=" -DZMK_EXTRA_MODULES='${GITHUB_WORKSPACE}'"
export new_tmp_dir=$(mktemp -d)
echo "base_dir=${new_tmp_dir}" >> $GITHUB_ENV
else
echo "base_dir=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
fi
echo "zephyr_version=${ZEPHYR_VERSION}" >> $GITHUB_ENV
echo "extra_cmake_args=${shield:+-DSHIELD=\"$shield\"}" >> $GITHUB_ENV
echo "display_name=${shield:+$shield - }${{ matrix.board }}" >> $GITHUB_ENV
echo "artifact_name=${shield:+$shield-}${{ matrix.board }}-zmk" >> $GITHUB_ENV
echo "extra_cmake_args=${shield:+-DSHIELD=\"$shield\"}${zmk_load_arg}" >> $GITHUB_ENV
echo "display_name=${shield:+$shield - }${board}" >> $GITHUB_ENV
echo "artifact_name=${artifact_name:-${shield:+$shield-}${board}-zmk}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Copy config files to isolated temporary directory
run: |
if [ "${{ env.base_dir }}" != "${GITHUB_WORKSPACE}" ]; then
mkdir "${{ env.base_dir }}/${{ inputs.config_path }}"
cp -R ${{ inputs.config_path }}/* "${{ env.base_dir }}/${{ inputs.config_path }}/"
fi
- name: Cache west modules
uses: actions/[email protected]
Expand All @@ -72,48 +93,52 @@ jobs:
cache_name: cache-zephyr-${{ env.zephyr_version }}-modules
with:
path: |
modules/
tools/
zephyr/
bootloader/
zmk/
${{ env.base_dir }}/modules/
${{ env.base_dir }}/tools/
${{ env.base_dir }}/zephyr/
${{ env.base_dir }}/bootloader/
${{ env.base_dir }}/zmk/
key: ${{ runner.os }}-build-${{ env.cache_name }}-${{ hashFiles('**/west.yml', '**/build.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache_name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: West Init
run: west init -l "${{ inputs.config_path }}"
working-directory: ${{ env.base_dir }}
run: west init -l "${{ env.base_dir }}/${{ inputs.config_path }}"

- name: West Update
working-directory: ${{ env.base_dir }}
run: west update

- name: West Zephyr export
working-directory: ${{ env.base_dir }}
run: west zephyr-export

- name: West Build (${{ env.display_name }})
working-directory: ${{ env.base_dir }}
shell: sh -x {0}
run: west build -s zmk/app -b "${{ matrix.board }}" -- -DZMK_CONFIG="${GITHUB_WORKSPACE}/${{ inputs.config_path }}" ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }}
run: west build -s zmk/app -d "${{ env.build_dir }}" -b "${{ matrix.board }}" -- -DZMK_CONFIG=${{ env.base_dir }}/${{ inputs.config_path }} ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }}

- name: ${{ env.display_name }} Kconfig file
run: |
if [ -f build/zephyr/.config ]
if [ -f "${{ env.build_dir }}/zephyr/.config" ]
then
grep -v -e "^#" -e "^$" build/zephyr/.config | sort
grep -v -e "^#" -e "^$" "${{ env.build_dir }}/zephyr/.config" | sort
else
echo "No Kconfig output"
fi
if: ${{ !cancelled() }}

- name: ${{ env.display_name }} Devicetree file
run: |
if [ -f build/zephyr/zephyr.dts ]
if [ -f "${{ env.build_dir }}/zephyr/zephyr.dts" ]
then
cat build/zephyr/zephyr.dts
elif [ -f build/zephyr/zephyr.dts.pre ]
cat "${{ env.build_dir }}/zephyr/zephyr.dts"
elif [ -f "${{ env.build_dir }}/zephyr/zephyr.dts.pre" ]
then
cat -s build/zephyr/zephyr.dts.pre
cat -s "${{ env.build_dir }}/zephyr/zephyr.dts.pre"
else
echo "No Devicetree output"
fi
Expand All @@ -122,17 +147,17 @@ jobs:
- name: Rename artifacts
shell: sh -x {0}
run: |
mkdir build/artifacts
if [ -f build/zephyr/zmk.uf2 ]
mkdir "${{ env.build_dir }}/artifacts"
if [ -f "${{ env.build_dir }}/zephyr/zmk.uf2" ]
then
cp build/zephyr/zmk.uf2 "build/artifacts/${{ env.artifact_name }}.uf2"
elif [ -f build/zephyr/zmk.${{ inputs.fallback_binary }} ]
cp "${{ env.build_dir }}/zephyr/zmk.uf2" "${{ env.build_dir }}/artifacts/${{ env.artifact_name }}.uf2"
elif [ -f "${{ env.build_dir }}/zephyr/zmk.${{ inputs.fallback_binary }}" ]
then
cp "build/zephyr/zmk.${{ inputs.fallback_binary }}" "build/artifacts/${{ env.artifact_name }}.${{ inputs.fallback_binary }}"
cp "${{ env.build_dir }}/zephyr/zmk.${{ inputs.fallback_binary }}" "${{ env.build_dir }}/artifacts/${{ env.artifact_name }}.${{ inputs.fallback_binary }}"
fi
- name: Archive (${{ env.display_name }})
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.archive_name }}
path: build/artifacts
path: ${{ env.build_dir }}/artifacts
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
id: test-dirs
run: |
cd app/tests/
export TESTS=$(ls -d * | jq -R -s -c 'split("\n")[:-1]')
export TESTS=$(ls -d * | grep -v ble | jq -R -s -c 'split("\n")[:-1]')
echo "::set-output name=test-dirs::${TESTS}"
run-tests:
needs: collect-tests
Expand Down
17 changes: 9 additions & 8 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@ cmake_minimum_required(VERSION 3.13.1)

set(CONFIG_APPLICATION_DEFINED_SYSCALL true)

# Add our custom Zephyr module for drivers w/ syscalls, etc.
list(APPEND DTS_ROOT ${CMAKE_SOURCE_DIR}/drivers/zephyr)

set(ZephyrBuildConfiguration_ROOT ${CMAKE_SOURCE_DIR}/cmake)

list(APPEND ZEPHYR_EXTRA_MODULES
${CMAKE_CURRENT_SOURCE_DIR}/module
)
set(ZEPHYR_EXTRA_MODULES "${ZMK_EXTRA_MODULES};${CMAKE_CURRENT_SOURCE_DIR}/module;${CMAKE_CURRENT_SOURCE_DIR}/keymap-module")

# Find Zephyr. This also loads Zephyr's build system.
find_package(Zephyr REQUIRED HINTS ../zephyr)
project(zmk)

zephyr_linker_sources(SECTIONS include/linker/zmk-behaviors.ld)
zephyr_linker_sources(RODATA include/linker/zmk-events.ld)

# Add your source file to the "app" target. This must come after
# find_package(Zephyr) which defines the target.
target_include_directories(app PRIVATE include)
target_sources(app PRIVATE src/stdlib.c)
target_sources(app PRIVATE src/activity.c)
target_sources(app PRIVATE src/behavior.c)
target_sources(app PRIVATE src/kscan.c)
target_sources(app PRIVATE src/matrix_transform.c)
target_sources(app PRIVATE src/sensors.c)
Expand All @@ -31,12 +26,14 @@ target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/ext_power_generic.c)
target_sources(app PRIVATE src/events/activity_state_changed.c)
target_sources(app PRIVATE src/events/position_state_changed.c)
target_sources(app PRIVATE src/events/sensor_event.c)
target_sources(app PRIVATE src/events/mouse_button_state_changed.c)
target_sources_ifdef(CONFIG_ZMK_WPM app PRIVATE src/events/wpm_state_changed.c)
target_sources_ifdef(CONFIG_USB_DEVICE_STACK app PRIVATE src/events/usb_conn_state_changed.c)
target_sources(app PRIVATE src/behaviors/behavior_reset.c)
target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/behaviors/behavior_ext_power.c)
if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
target_sources(app PRIVATE src/hid.c)
target_sources_ifdef(CONFIG_ZMK_MOUSE app PRIVATE src/mouse.c)
target_sources(app PRIVATE src/behaviors/behavior_key_press.c)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_KEY_TOGGLE app PRIVATE src/behaviors/behavior_key_toggle.c)
target_sources(app PRIVATE src/behaviors/behavior_hold_tap.c)
Expand All @@ -54,6 +51,7 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_SENSOR_ROTATE app PRIVATE src/behaviors/behavior_sensor_rotate.c)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_SENSOR_ROTATE_VAR app PRIVATE src/behaviors/behavior_sensor_rotate_var.c)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_SENSOR_ROTATE_COMMON app PRIVATE src/behaviors/behavior_sensor_rotate_common.c)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_MOUSE_KEY_PRESS app PRIVATE src/behaviors/behavior_mouse_key_press.c)
target_sources(app PRIVATE src/combo.c)
target_sources(app PRIVATE src/behaviors/behavior_tap_dance.c)
target_sources(app PRIVATE src/behavior_queue.c)
Expand All @@ -65,6 +63,7 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
target_sources(app PRIVATE src/events/layer_state_changed.c)
target_sources(app PRIVATE src/events/modifiers_state_changed.c)
target_sources(app PRIVATE src/events/keycode_state_changed.c)
target_sources_ifdef(CONFIG_ZMK_HID_INDICATORS app PRIVATE src/hid_indicators.c)

if (CONFIG_ZMK_BLE)
target_sources(app PRIVATE src/events/ble_active_profile_changed.c)
Expand All @@ -80,6 +79,8 @@ target_sources_ifdef(CONFIG_ZMK_BACKLIGHT app PRIVATE src/behaviors/behavior_bac
target_sources_ifdef(CONFIG_ZMK_BATTERY_REPORTING app PRIVATE src/events/battery_state_changed.c)
target_sources_ifdef(CONFIG_ZMK_BATTERY_REPORTING app PRIVATE src/battery.c)

target_sources_ifdef(CONFIG_ZMK_HID_INDICATORS app PRIVATE src/events/hid_indicators_changed.c)

target_sources_ifdef(CONFIG_ZMK_SPLIT app PRIVATE src/events/split_peripheral_status_changed.c)
add_subdirectory(src/split)

Expand Down
Loading

0 comments on commit 6c1b3bf

Please sign in to comment.