Skip to content

Commit

Permalink
cmake update CI update
Browse files Browse the repository at this point in the history
  • Loading branch information
SmejkalJakub committed Aug 15, 2022
1 parent 1471fd8 commit 6bfc04b
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 5 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: main

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

env:
BUILD_TYPE: release
FW_VERSION: ${GITHUB_REF##*/}
REPOSITORY_NAME: ${GITHUB_REPOSITORY##*/}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup GNU Arm Embedded Toolchain
uses: carlosperate/arm-none-eabi-gcc-action@v1.4.0

- name: Setup env
if: ${{ github.event_name == 'release' }}
run: |
echo "REPORSIORY=${{env.REPOSITORY_NAME}}" >> "$GITHUB_ENV"
echo "FW_VERSION=${{env.FW_VERSION}}" >> "$GITHUB_ENV"
- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@v1.1

- name: Build firmware
run: |
FIRMWARE="generic-node-battery"
cmake -B ${{github.workspace}}/obj/${{env.BUILD_TYPE}} . -G Ninja -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/sdk/toolchain/toolchain.cmake -DTYPE=${{env.BUILD_TYPE}} -DFIRMWARE="${FIRMWARE}"
ninja -C ${{github.workspace}}/obj/${{env.BUILD_TYPE}}
mv ${{github.workspace}}/out/release/firmware.bin ${{env.REPOSITORY_NAME}}-battery-${{env.FW_VERSION}}.bin
FIRMWARE="generic-node-power-module-rgbw144"
cmake -B ${{github.workspace}}/obj/${{env.BUILD_TYPE}} . -G Ninja -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/sdk/toolchain/toolchain.cmake -DTYPE=${{env.BUILD_TYPE}} -DFIRMWARE="${FIRMWARE}" -DMODULE_POWER=1
ninja -C ${{github.workspace}}/obj/${{env.BUILD_TYPE}}
mv ${{github.workspace}}/out/release/firmware.bin ${{env.REPOSITORY_NAME}}-power-module-rgbw144-${{env.FW_VERSION}}.bin
FIRMWARE="generic-node-power-module-rgbw72"
cmake -B ${{github.workspace}}/obj/${{env.BUILD_TYPE}} . -G Ninja -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/sdk/toolchain/toolchain.cmake -DTYPE=${{env.BUILD_TYPE}} -DFIRMWARE="${FIRMWARE}" -DMODULE_POWER=1 -DLED_STRIP_COUNT=72
ninja -C ${{github.workspace}}/obj/${{env.BUILD_TYPE}}
mv ${{github.workspace}}/out/release/firmware.bin ${{env.REPOSITORY_NAME}}-power-module-rgbw72-${{env.FW_VERSION}}.bin
FIRMWARE="generic-node-power-module-rgb150"
cmake -B ${{github.workspace}}/obj/${{env.BUILD_TYPE}} . -G Ninja -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/sdk/toolchain/toolchain.cmake -DTYPE=${{env.BUILD_TYPE}} -DFIRMWARE="${FIRMWARE}" -DMODULE_POWER=1 -DLED_STRIP_COUNT=150 -DLED_STRIP_TYPE=3
ninja -C ${{github.workspace}}/obj/${{env.BUILD_TYPE}}
mv ${{github.workspace}}/out/release/firmware.bin ${{env.REPOSITORY_NAME}}-power-module-rgb150-${{env.FW_VERSION}}.bin
FIRMWARE="generic-node-power-module-rgb300"
cmake -B ${{github.workspace}}/obj/${{env.BUILD_TYPE}} . -G Ninja -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/sdk/toolchain/toolchain.cmake -DTYPE=${{env.BUILD_TYPE}} -DFIRMWARE="${FIRMWARE}" -DMODULE_POWER=1 -DLED_STRIP_COUNT=300 -DLED_STRIP_TYPE=3
ninja -C ${{github.workspace}}/obj/${{env.BUILD_TYPE}}
mv ${{github.workspace}}/out/release/firmware.bin ${{env.REPOSITORY_NAME}}-power-module-rgb300-${{env.FW_VERSION}}.bin
ls .
- name: Publish to GitHub Releases
if: ${{ github.event_name == 'release' }}
uses: softprops/action-gh-release@v0.1.5
env:
GITHUB_TOKEN: ${{ github.token }}
with:
files: |
${{ env.REPORSIORY }}-battery-${{ env.FW_VERSION }}.bin
${{ env.REPORSIORY }}-power-module-rgbw144-${{ env.FW_VERSION }}.bin
${{ env.REPORSIORY }}-power-module-rgbw72-${{ env.FW_VERSION }}.bin
${{ env.REPORSIORY }}-power-module-rgb150-${{ env.FW_VERSION }}.bin
${{ env.REPORSIORY }}-power-module-rgb300-${{ env.FW_VERSION }}.bin
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,29 @@ project(firmware LANGUAGES C ASM)

add_subdirectory(sdk)

if(DEFINED LED_STRIP_COUNT)
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC LED_STRIP_COUNT=${LED_STRIP_COUNT})
else()
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC LED_STRIP_COUNT=144)
endif()

if(DEFINED MODULE_POWER)
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC MODULE_POWER=${MODULE_POWER})
else()
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC MODULE_POWER=0)
endif()

if(DEFINED LED_STRIP_TYPE)
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC LED_STRIP_TYPE=${LED_STRIP_TYPE})
else()
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC LED_STRIP_TYPE=4)
endif()

if(DEFINED FIRMWARE)
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC FIRMWARE=${FIRMWARE})
endif()

target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC TWR_SCHEDULER_MAX_TASKS=64)

# If you need to add some source files to the project add them to the "src" folder and update CMakeLists there
add_subdirectory(src)
2 changes: 1 addition & 1 deletion src/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void application_init(void)
twr_led_set_mode(&led, TWR_LED_MODE_OFF);

twr_radio_init(RADIO_MODE);
twr_radio_pairing_request(FIRMWARE, VERSION);
twr_radio_pairing_request(FIRMWARE, FW_VERSION);

sensors_init();
sensors_set_event_handler(sensors_event_handler, NULL);
Expand Down
4 changes: 0 additions & 4 deletions src/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#define FIRMWARE "generic-node"
#endif

#ifndef VERSION
#define VERSION "vdev"
#endif

#include <twr.h>

typedef struct
Expand Down

0 comments on commit 6bfc04b

Please sign in to comment.