Skip to content

Commit

Permalink
add a post-build command to patch board config into .bin/.uf2
Browse files Browse the repository at this point in the history
this starts the replacement of BoardConfig.h + migration code with
shipped protobuf configs. this should help cleanup some code, and one
day will hopefully replace the need for per-board builds entirely,
greatly speeding up the GitHub build/creation of board binaries
  • Loading branch information
bsstephan committed Apr 14, 2024
1 parent 5723f47 commit 5357b89
Show file tree
Hide file tree
Showing 34 changed files with 126 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ add_compile_options(-Wall
include(compile_proto.cmake)
compile_proto()

include(patch_board_config.cmake)
patch_board_config()

#pull in tinyUSB
set(PICO_TINYUSB_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb")

Expand Down
1 change: 1 addition & 0 deletions compile_proto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function (compile_proto)
DEPENDS ${CMAKE_SOURCE_DIR}/lib/nanopb/extra/requirements.txt
COMMAND ${Python3_EXECUTABLE} -m venv ${VENV}
COMMAND ${VENV_BIN_DIR}/pip --disable-pip-version-check install -r ${CMAKE_SOURCE_DIR}/lib/nanopb/extra/requirements.txt
COMMAND ${VENV_BIN_DIR}/pip --disable-pip-version-check install gp2040ce-binary-tools
COMMAND ${VENV_BIN_DIR}/pip freeze > ${VENV_FILE}
OUTPUT ${VENV_FILE}
COMMENT "Setting up Python Virtual Environment"
Expand Down
3 changes: 3 additions & 0 deletions configs/BentoBox/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/FightboardV3/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/FightboardV3Mirrored/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/FlatboxRev4/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/FlatboxRev5/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/FlatboxRev5RGB/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/FlatboxRev5Southpaw/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/Granola/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/Haute42COSMOX/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/KB2040/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/KeyboardConverter/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/Liatris/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/Mavercade/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/OpenCore0/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/OpenCore0WASD/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/Pico/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/PicoAnn/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/PicoFightingBoard/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/PicoW/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/RP2040AdvancedBreakoutBoard/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/RP2040MiniBreakoutBoard/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/RanaTadpole/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/ReflexCtrlSNES/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/ReflexEncodeV1.2/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/ReflexEncodeV2.0/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/SGFBridget/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/SGFFaust/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/SparkFunProMicro/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/Stress/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
3 changes: 3 additions & 0 deletions configs/WaveshareZero/board-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"boardVersion": "v0.7.8"
}
29 changes: 29 additions & 0 deletions patch_board_config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function (patch_board_config)
find_package(Python3 REQUIRED COMPONENTS Interpreter)

set(VENV ${CMAKE_CURRENT_BINARY_DIR}/venv)
if(CMAKE_HOST_WIN32)
set(VENV_BIN_DIR ${VENV}/Scripts)
else()
set(VENV_BIN_DIR ${VENV}/bin)
endif()

add_custom_target(
PatchBoardConfig ALL
DEPENDS ${PROJECT_NAME}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${VENV_BIN_DIR}/concatenate
-P ./proto
-P ./lib/nanopb/generator/proto
./build/${PROJECT_NAME}_${CMAKE_PROJECT_VERSION}_${GP2040_BOARDCONFIG}.bin
--json-board-config-filename ./configs/${GP2040_BOARDCONFIG}/board-config.json
--new-filename ./build/${PROJECT_NAME}_${CMAKE_PROJECT_VERSION}_${GP2040_BOARDCONFIG}.uf2
COMMAND ${VENV_BIN_DIR}/concatenate
-P ./proto
-P ./lib/nanopb/generator/proto
./build/${PROJECT_NAME}_${CMAKE_PROJECT_VERSION}_${GP2040_BOARDCONFIG}.bin
--json-board-config-filename ./configs/${GP2040_BOARDCONFIG}/board-config.json
--new-filename ./build/${PROJECT_NAME}_${CMAKE_PROJECT_VERSION}_${GP2040_BOARDCONFIG}.bin
COMMENT "Patching binary with board config"
)
endfunction()

0 comments on commit 5357b89

Please sign in to comment.