From 9e61f8080937612f1fa67dbc6fc4b0a50f1742a3 Mon Sep 17 00:00:00 2001 From: "E.T" Date: Thu, 4 Jan 2024 22:59:25 +0100 Subject: [PATCH] Create cmake target ppfw (#1716) * Create cmake target ppfw and oci It will build an OCI ppfw package to be flashed or shared on test-drive Additionally some minor cmake cleanup And updated gitignore to allow multiple build folders * Make ppfw / oci build default --- .gitignore | 2 +- CMakeLists.txt | 21 +++++++++++++++++++-- firmware/CMakeLists.txt | 30 +++++++++++++++++++++++++++++- hackrf-portapack/CMakeLists.txt | 2 +- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index fff979e9..86c38d46 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,7 @@ *.map *.lst .dep/ -build/ +/build* CMakeFiles/ # Debugging diff --git a/CMakeLists.txt b/CMakeLists.txt index 2804f285..8ec0f8b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ # Boston, MA 02110-1301, USA. # -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) cmake_policy(SET CMP0005 NEW) set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/firmware/toolchain-arm-cortex-m.cmake) @@ -28,7 +28,7 @@ project(portapack-h1) set(EXPECTED_GCC_VERSION "9.2.1") set(VERSION "$ENV{VERSION_STRING}") -if ("$ENV{VERSION_STRING}" STREQUAL "") +if ("${VERSION}" STREQUAL "") execute_process( COMMAND git log -n 1 --format=%h WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} @@ -42,6 +42,11 @@ if ("$ENV{VERSION_STRING}" STREQUAL "") else (GIT_VERSION_FOUND) set(VERSION "${GIT_VERSION}") endif (GIT_VERSION_FOUND) + + set(VERSION_NOHASH "dev") +else() + set(VERSION_NOHASH "${VERSION}") + set(PPFW_FILENAME "portapack-mayhem.ppfw.tar") endif() execute_process( @@ -50,6 +55,18 @@ execute_process( ) set(VERSION_MD5 "0x${VERSION_MD5}") +if (NOT DEFINED PPFW_FILENAME) + # Funny business here: trying to generate unique names to prevent renaming of shared test-drive builds by the browser on download to .ppfw-42.tar as it wont be recognized by the flasher + execute_process( + COMMAND date "+%y%m%d-%H%M" + OUTPUT_VARIABLE PPFW_FILENAME + ) + string(STRIP ${PPFW_FILENAME} PPFW_FILENAME) + set(PPFW_FILENAME "portapack-mayhem_${PPFW_FILENAME}_OCI.ppfw.tar") +endif() + +message("Building version: ${VERSION} MD5: ${VERSION_MD5}") + set(LICENSE_PATH ${CMAKE_CURRENT_LIST_DIR}/LICENSE) set(HARDWARE_PATH ${CMAKE_CURRENT_LIST_DIR}/hardware) diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt index 74e6e7d5..aa74225b 100644 --- a/firmware/CMakeLists.txt +++ b/firmware/CMakeLists.txt @@ -18,6 +18,8 @@ # Boston, MA 02110-1301, USA. # +cmake_minimum_required(VERSION 3.5) + project(firmware) set(BASEBAND ${PROJECT_SOURCE_DIR}/baseband) @@ -59,7 +61,7 @@ add_custom_command( ) add_custom_target( - firmware ALL + firmware DEPENDS ${FIRMWARE_FILENAME} ${HACKRF_FIRMWARE_DFU_FILENAME} ) @@ -88,6 +90,21 @@ add_custom_target( DEPENDS program ) +add_custom_command( + OUTPUT ${PPFW_FILENAME} + + COMMAND rm -rf firmware_tar + COMMAND mkdir -p firmware_tar/FIRMWARE + # Using VERSION_NOHASH to avoid dev builds piling up in the FIRMWARE folder of the sd card of testers in #test-drive + COMMAND cp ${FIRMWARE_FILENAME} firmware_tar/FIRMWARE/portapack-mayhem_${VERSION_NOHASH}.bin + COMMAND mkdir -p firmware_tar/APPS + COMMAND cp application/*.ppma firmware_tar/APPS + COMMAND cd firmware_tar && tar -cvaf ../${PPFW_FILENAME} * + DEPENDS firmware + # Dont use VERBATIM here as it prevents usage of globbing (*) + # There shouldnt be any funny business in the filenames above :) +) + # TODO: Bad hack to fix location of LICENSE file for tar. add_custom_command( OUTPUT ${FIRMWARE_NAME}-${VERSION}.tar.bz2 ${FIRMWARE_NAME}-${VERSION}.zip @@ -107,7 +124,18 @@ add_custom_command( DEPENDS ${FIRMWARE_NAME}-${VERSION}.tar.bz2 ${FIRMWARE_NAME}-${VERSION}.zip ) +add_custom_target( + ppfw ALL + DEPENDS ${PPFW_FILENAME} +) + +add_custom_target( + oci + DEPENDS ${PPFW_FILENAME} +) + add_custom_target( release DEPENDS MD5SUMS SHA256SUMS ) + diff --git a/hackrf-portapack/CMakeLists.txt b/hackrf-portapack/CMakeLists.txt index ffa7c398..07e9e3fa 100644 --- a/hackrf-portapack/CMakeLists.txt +++ b/hackrf-portapack/CMakeLists.txt @@ -18,7 +18,7 @@ # Boston, MA 02110-1301, USA. # -cmake_minimum_required(VERSION 3.1.3) +cmake_minimum_required(VERSION 3.5) set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake) project(hackrf_usb C)