mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 19:54:39 +00:00
CMake: Improve dependencies, how output files are managed/cleaned.
I almost think I understand CMake, now. Almost.
This commit is contained in:
parent
45ca3cf7e6
commit
b6fe392512
@ -18,7 +18,7 @@
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
project(portapack-h1-firmware)
|
||||
project(firmware)
|
||||
|
||||
set(COMMON ${PROJECT_SOURCE_DIR}/common)
|
||||
set(CHIBIOS ${PROJECT_SOURCE_DIR}/chibios)
|
||||
@ -30,31 +30,48 @@ set(STRIP_DFU ${PROJECT_SOURCE_DIR}/tools/strip_dfu.py)
|
||||
set(MAKE_SPI_IMAGE ${PROJECT_SOURCE_DIR}/tools/make_spi_image.py)
|
||||
set(MAKE_IMAGE_CHUNK ${PROJECT_SOURCE_DIR}/tools/make_image_chunk.py)
|
||||
|
||||
set(FIRMWARE_NAME portapack-h1-firmware)
|
||||
set(FIRMWARE_FILENAME ${FIRMWARE_NAME}.bin)
|
||||
|
||||
add_subdirectory(application)
|
||||
add_subdirectory(baseband)
|
||||
add_subdirectory(bootstrap)
|
||||
|
||||
# NOTE: Dependencies break if the .bin files aren't included in DEPENDS. WTF, CMake?
|
||||
add_custom_command(
|
||||
OUTPUT ${FIRMWARE_FILENAME}
|
||||
COMMAND ${MAKE_SPI_IMAGE} ${bootstrap_BINARY_DIR}/bootstrap.bin ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin ${FIRMWARE_FILENAME}
|
||||
DEPENDS bootstrap baseband application ${MAKE_SPI_IMAGE}
|
||||
${bootstrap_BINARY_DIR}/bootstrap.bin ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
${PROJECT_NAME}.bin
|
||||
COMMAND ${MAKE_SPI_IMAGE} ${bootstrap_BINARY_DIR}/bootstrap.bin ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin ${PROJECT_NAME}.bin
|
||||
DEPENDS bootstrap.bin baseband.img application.bin
|
||||
firmware
|
||||
DEPENDS ${FIRMWARE_FILENAME}
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
program
|
||||
COMMAND dfu-util --device 1fc9:000c --download ${HACKRF_FIRMWARE_IMAGE} --reset
|
||||
COMMAND sleep 1s
|
||||
COMMAND hackrf_spiflash -w ${PROJECT_NAME}.bin
|
||||
DEPENDS ${PROJECT_NAME}.bin
|
||||
COMMAND hackrf_spiflash -w ${FIRMWARE_FILENAME}
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FIRMWARE_FILENAME}
|
||||
)
|
||||
|
||||
# TODO: Bad hack to fix location of LICENSE file for tar.
|
||||
add_custom_target(
|
||||
release
|
||||
add_custom_command(
|
||||
OUTPUT ${FIRMWARE_NAME}-${GIT_REVISION}.tar.bz2 ${FIRMWARE_NAME}-${GIT_REVISION}.zip
|
||||
COMMAND cp ${LICENSE_PATH} LICENSE
|
||||
COMMAND cp ${HACKRF_FIRMWARE_IMAGE} ${HACKRF_FIRMWARE_FILENAME}
|
||||
COMMAND tar -c -j -f ${PROJECT_NAME}-${GIT_REVISION}.tar.bz2 ${PROJECT_NAME}.bin ${HACKRF_FIRMWARE_FILENAME} LICENSE
|
||||
COMMAND zip -9 -q ${PROJECT_NAME}-${GIT_REVISION}.zip ${PROJECT_NAME}.bin ${HACKRF_FIRMWARE_FILENAME} LICENSE
|
||||
COMMAND tar -c -j -f ${FIRMWARE_NAME}-${GIT_REVISION}.tar.bz2 ${FIRMWARE_FILENAME} ${HACKRF_FIRMWARE_FILENAME} LICENSE
|
||||
COMMAND zip -9 -q ${FIRMWARE_NAME}-${GIT_REVISION}.zip ${FIRMWARE_FILENAME} ${HACKRF_FIRMWARE_FILENAME} LICENSE
|
||||
COMMAND rm -f LICENSE ${HACKRF_FIRMWARE_FILENAME}
|
||||
DEPENDS ${PROJECT_NAME}.bin
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FIRMWARE_FILENAME} ${LICENSE_PATH} ${HACKRF_FIRMWARE_IMAGE}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
release
|
||||
DEPENDS ${FIRMWARE_NAME}-${GIT_REVISION}.tar.bz2 ${FIRMWARE_NAME}-${GIT_REVISION}.zip
|
||||
)
|
||||
|
@ -305,3 +305,8 @@ add_custom_command(
|
||||
COMMAND ${CMAKE_OBJCOPY} -O binary ${PROJECT_NAME}.elf ${PROJECT_NAME}.bin
|
||||
DEPENDS ${PROJECT_NAME}.elf
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
${PROJECT_NAME}
|
||||
DEPENDS ${PROJECT_NAME}.bin
|
||||
)
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
enable_language(C CXX ASM)
|
||||
|
||||
project(baseband)
|
||||
project(baseband_shared)
|
||||
|
||||
# Compiler options here.
|
||||
set(USE_OPT "-O3 -falign-functions=16 -fno-math-errno --specs=nano.specs")
|
||||
@ -253,22 +253,18 @@ macro(DeclareTargets chunk_tag name)
|
||||
project("baseband_${name}")
|
||||
|
||||
include(${RULESPATH}/rules.cmake)
|
||||
add_executable(${PROJECT_NAME}.elf $<TARGET_OBJECTS:baseband> ${MODE_CPPSRC} ${LDSCRIPT})
|
||||
add_executable(${PROJECT_NAME}.elf $<TARGET_OBJECTS:baseband_shared> ${MODE_CPPSRC} ${LDSCRIPT})
|
||||
add_definitions(${DEFS})
|
||||
include_directories(. ${INCDIR})
|
||||
link_directories(${LLIBDIR})
|
||||
target_link_libraries(${PROJECT_NAME}.elf ${LIBS})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${PROJECT_NAME}.bin
|
||||
OUTPUT ${PROJECT_NAME}.bin ${PROJECT_NAME}.img
|
||||
COMMAND ${CMAKE_OBJCOPY} -O binary ${PROJECT_NAME}.elf ${PROJECT_NAME}.bin
|
||||
DEPENDS ${PROJECT_NAME}.elf
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${PROJECT_NAME}.img
|
||||
COMMAND ${MAKE_IMAGE_CHUNK} ${PROJECT_NAME}.bin ${chunk_tag} ${PROJECT_NAME}.img
|
||||
DEPENDS ${PROJECT_NAME}.bin ${MAKE_IMAGE_CHUNK}
|
||||
DEPENDS ${PROJECT_NAME}.elf ${MAKE_IMAGE_CHUNK}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
set(BASEBAND_IMAGES ${BASEBAND_IMAGES} ${PROJECT_NAME}.img)
|
||||
@ -333,15 +329,11 @@ DeclareTargets(PSPE wideband_spectrum)
|
||||
### HackRF "factory" firmware
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT hackrf.bin
|
||||
OUTPUT hackrf.bin hackrf.img
|
||||
COMMAND ${STRIP_DFU} ${HACKRF_FIRMWARE_IMAGE} hackrf.bin
|
||||
DEPENDS ${HACKRF_FIRMWARE_IMAGE} ${STRIP_DFU}
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT hackrf.img
|
||||
COMMAND ${MAKE_IMAGE_CHUNK} hackrf.bin HRF1 hackrf.img
|
||||
DEPENDS hackrf.bin ${MAKE_IMAGE_CHUNK}
|
||||
DEPENDS ${HACKRF_FIRMWARE_IMAGE} ${STRIP_DFU} ${MAKE_IMAGE_CHUNK}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
set(BASEBAND_IMAGES ${BASEBAND_IMAGES} hackrf.img)
|
||||
@ -352,12 +344,23 @@ add_custom_command(
|
||||
OUTPUT terminator.img
|
||||
COMMAND ${MAKE_IMAGE_CHUNK} terminator.img
|
||||
DEPENDS ${MAKE_IMAGE_CHUNK}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
set(BASEBAND_IMAGES ${BASEBAND_IMAGES} terminator.img)
|
||||
|
||||
#######################################################################
|
||||
|
||||
add_custom_target(
|
||||
baseband.img
|
||||
COMMAND cat ${BASEBAND_IMAGES} terminator.img >baseband.img
|
||||
DEPENDS ${BASEBAND_IMAGES} terminator.img
|
||||
project(baseband)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${PROJECT_NAME}.img
|
||||
COMMAND cat ${BASEBAND_IMAGES} > ${PROJECT_NAME}.img
|
||||
DEPENDS ${BASEBAND_IMAGES}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
${PROJECT_NAME}
|
||||
DEPENDS ${PROJECT_NAME}.img
|
||||
)
|
||||
|
@ -204,3 +204,8 @@ add_custom_command(
|
||||
COMMAND ${CMAKE_OBJCOPY} -O binary ${PROJECT_NAME}.elf ${PROJECT_NAME}.bin
|
||||
DEPENDS ${PROJECT_NAME}.elf
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
bootstrap
|
||||
DEPENDS ${PROJECT_NAME}.bin
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user