Skip to content

Commit

Permalink
Create cmake target ppfw (#1716)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
u-foka committed Jan 4, 2024
1 parent ff591c6 commit 9e61f80
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*.map
*.lst
.dep/
build/
/build*
CMakeFiles/

# Debugging
Expand Down
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}
Expand All @@ -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(
Expand All @@ -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)

Expand Down
30 changes: 29 additions & 1 deletion firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Boston, MA 02110-1301, USA.
#

cmake_minimum_required(VERSION 3.5)

project(firmware)

set(BASEBAND ${PROJECT_SOURCE_DIR}/baseband)
Expand Down Expand Up @@ -59,7 +61,7 @@ add_custom_command(
)

add_custom_target(
firmware ALL
firmware
DEPENDS ${FIRMWARE_FILENAME} ${HACKRF_FIRMWARE_DFU_FILENAME}
)

Expand Down Expand Up @@ -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
Expand All @@ -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
)

2 changes: 1 addition & 1 deletion hackrf-portapack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9e61f80

Please sign in to comment.