Skip to content

Commit

Permalink
CI build fix for Github Ubuntu 22.04 runner (#31)
Browse files Browse the repository at this point in the history
Signed-off-by: Adam BZH <adam@onekey.so>
  • Loading branch information
424778940z authored May 28, 2024
1 parent 53faa94 commit f9c8f9d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ jobs:
sudo apt -y install curl wget cmake ninja-build build-essential libtool
# sudo apt -y install gcc-arm-none-eabi binutils-arm-none-eabi libnewlib-arm-none-eabi
sudo apt -y install python3 python-is-python3 python3-pip python3-poetry
# sudo python -m pip install -U pip
# sudo pip install wheel click
# Note:
# currently poetry is not being used in CI since ubuntu-latest(22.04) poetry is too old
# may consider switch to poetry when ubuntu-latest pointing to 24.04
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
Expand Down
23 changes: 16 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(FILE_OUTPUT_FACTORY_HEX "${DIR_OUTPUT}/factory.hex")
set(FILE_OUTPUT_FACTORY_BIN "${DIR_OUTPUT}/factory.bin")
set(FILE_OUTPUT_ZIP "${DIR_OUTPUT}/ota.zip")
set(FILE_OUTPUT_OTA_BIN "${DIR_OUTPUT}/ota.bin")
set(PYTHON_RUNNER poetry -C ${DIR_UTILS})
set(PYTHON_RUNNER exit -1 && ) # placeholder, will be set later

###############################
# Prerequests and Environments
Expand All @@ -47,11 +47,20 @@ add_custom_target(
COMMAND ${DIR_UTILS}/nrfutil install nrf5sdk-tools
)

# python env
# python env (poetry)
# set(PYTHON_RUNNER poetry -C ${DIR_UTILS} run)
# add_custom_target(
# ${CMAKE_PROJECT_NAME}_PYENV
# COMMAND ${PYTHON_RUNNER} install
# COMMAND ${PYTHON_RUNNER} env info
# )

# python env (pip)
set(PYTHON_RUNNER ${PROJECT_BINARY_DIR}/venv/bin/python)
add_custom_target(
${CMAKE_PROJECT_NAME}_PYENV
COMMAND ${PYTHON_RUNNER} install -q
# COMMAND ${PYTHON_RUNNER} env info
COMMAND python -m venv ${PROJECT_BINARY_DIR}/venv
COMMAND ${PROJECT_BINARY_DIR}/venv/bin/pip install -r ${DIR_UTILS}/requirements.txt
)

###############################
Expand All @@ -72,14 +81,14 @@ ExternalProject_Add(
# dfu payload
add_custom_target(
${CMAKE_PROJECT_NAME}_DFU_UPGRADE_PAYLOAD ALL
COMMAND ${PYTHON_RUNNER} run ${DIR_UTILS}/bin2array.py -l 16 -i ${PROJECT_SOURCE_DIR}/artifacts/OnekeyProBTFW_BL.bin -o ${PROJECT_SOURCE_DIR}/artifacts/dfu_upgrade_payload.h
COMMAND ${PYTHON_RUNNER} ${DIR_UTILS}/bin2array.py -l 16 -i ${PROJECT_SOURCE_DIR}/artifacts/OnekeyProBTFW_BL.bin -o ${PROJECT_SOURCE_DIR}/artifacts/dfu_upgrade_payload.h
DEPENDS dfu ${CMAKE_PROJECT_NAME}_PYENV
)

# mbr and uicr config
add_custom_target(
${CMAKE_PROJECT_NAME}_MBR_UICR ALL
COMMAND ${PYTHON_RUNNER} run ${DIR_UTILS}/uicr_mbr_hex_gen.py --no-use-uicr -i ${PROJECT_SOURCE_DIR}/artifacts/OnekeyProBTFW_BL -o ${FILE_INPUT_MBR_UICR}
COMMAND ${PYTHON_RUNNER} ${DIR_UTILS}/uicr_mbr_hex_gen.py --no-use-uicr -i ${PROJECT_SOURCE_DIR}/artifacts/OnekeyProBTFW_BL -o ${FILE_INPUT_MBR_UICR}
DEPENDS dfu ${CMAKE_PROJECT_NAME}_PYENV
)

Expand Down Expand Up @@ -133,7 +142,7 @@ add_custom_target(
--hw-version 52 --sd-req 0xCB
--application ${FILE_INPUT_APP} --application-version 3 --app-boot-validation VALIDATE_ECDSA_P256_SHA256
--key-file ${FILE_KEY} ${FILE_OUTPUT_ZIP}
COMMAND ${PYTHON_RUNNER} run ${DIR_UTILS}/ota_to_onekey_bin.py ${FILE_OUTPUT_ZIP} ${FILE_OUTPUT_OTA_BIN}
COMMAND ${PYTHON_RUNNER} ${DIR_UTILS}/ota_to_onekey_bin.py ${FILE_OUTPUT_ZIP} ${FILE_OUTPUT_OTA_BIN}
DEPENDS ${CMAKE_PROJECT_NAME}_OUT_DIR ${CMAKE_PROJECT_NAME}_UTIL ${CMAKE_PROJECT_NAME}_KEY dfu app
)

Expand Down
4 changes: 4 additions & 0 deletions utils/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
click==8.1.7 ; python_version >= "3.10" and python_version < "4.0"
intelhex==2.3.0 ; python_version >= "3.10" and python_version < "4.0"
pyelftools==0.31 ; python_version >= "3.10" and python_version < "4.0"
wheel==0.43.0 ; python_version >= "3.10" and python_version < "4.0"

0 comments on commit f9c8f9d

Please sign in to comment.