chore(cmake): CMake cleanup and simplifications (#2620)
* CMake cleanup and simplifications * Position Independent Code is need for radiolib_native * Some more cleanup & repair * Fix SIMU_SRC scope issue * fix: avoid warnings due to assembler statements from StdPeriph on arm64 native
This commit is contained in:
@@ -174,8 +174,6 @@ set(RADIO_DEPENDENCIES
|
||||
${BITMAPS_TARGET}
|
||||
)
|
||||
|
||||
set(FIRMWARE_DEPENDENCIES datacopy)
|
||||
|
||||
add_definitions(-DPCBHORUS -DSTM32F429_439xx -DSTM32F429xx -DSDRAM -DCCMRAM -DCOLORLCD -DHARDWARE_KEYS)
|
||||
add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK)
|
||||
add_definitions(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE})
|
||||
@@ -319,20 +317,10 @@ endif()
|
||||
# Make malloc() thread-safe
|
||||
add_definitions(-DTHREADSAFE_MALLOC)
|
||||
|
||||
if(PYTHONINTERP_FOUND)
|
||||
add_custom_command(
|
||||
OUTPUT ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp
|
||||
WORKING_DIRECTORY ${RADIO_DIRECTORY}/src
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs_private.h
|
||||
-DPCBHORUS -DPCB${PCB} -DCPUARM -DSTM32F4 -DSTM32F429_439xx -DCOLORLCD -DBACKUP -DSIMU
|
||||
-I. -Igui/colorlcd -Itargets/horus -Itargets/common/arm/stm32
|
||||
-I${THIRDPARTY_DIR} -I${THIRDPARTY_DIR}/libopenui/src
|
||||
-I${THIRDPARTY_DIR}/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/STM32F4xx_StdPeriph_Driver/inc
|
||||
-I${THIRDPARTY_DIR}/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include
|
||||
-I${THIRDPARTY_DIR}/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/CMSIS/Include
|
||||
-Wno-asm-operand-widths -Wno-pragma-once-outside-header ${SYSROOT_ARG}
|
||||
> ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp
|
||||
DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py
|
||||
)
|
||||
add_custom_target(datacopy DEPENDS ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp)
|
||||
endif()
|
||||
set(STM32LIB_SRC
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c
|
||||
)
|
||||
|
||||
@@ -60,7 +60,6 @@ set(TOUCH_DRIVER touch_driver.cpp)
|
||||
set(HARDWARE_TOUCH YES)
|
||||
|
||||
set(RADIO_DEPENDENCIES ${RADIO_DEPENDENCIES} ${BITMAPS_TARGET})
|
||||
set(FIRMWARE_DEPENDENCIES datacopy)
|
||||
|
||||
set(HARDWARE_TOUCH ON)
|
||||
|
||||
@@ -164,21 +163,13 @@ set(FIRMWARE_SRC
|
||||
# Make malloc() thread-safe
|
||||
add_definitions(-DTHREADSAFE_MALLOC)
|
||||
|
||||
if(PYTHONINTERP_FOUND)
|
||||
add_custom_command(
|
||||
OUTPUT ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp
|
||||
WORKING_DIRECTORY ${RADIO_DIRECTORY}/src
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs_private.h
|
||||
-DPCBFLYSKY -DPCBNV14 -DCPUARM -DSTM32F4 -DSTM32F429_439xx -DCOLORLCD -DBACKUP -DSIMU
|
||||
-I. -Igui/colorlcd -Itargets/nv14 -Itargets/common/arm/stm32
|
||||
-I${THIRDPARTY_DIR} -I${THIRDPARTY_DIR}/libopenui/src
|
||||
-I${THIRDPARTY_DIR}/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/STM32F4xx_StdPeriph_Driver/inc
|
||||
-I${THIRDPARTY_DIR}/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include
|
||||
-I${THIRDPARTY_DIR}/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/CMSIS/Include
|
||||
-Wno-asm-operand-widths -Wno-pragma-once-outside-header ${SYSROOT_ARG}
|
||||
> ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp
|
||||
DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py
|
||||
)
|
||||
add_custom_target(datacopy DEPENDS ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp)
|
||||
endif()
|
||||
set(STM32LIB_SRC
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c
|
||||
STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c
|
||||
)
|
||||
|
||||
|
||||
@@ -5,12 +5,7 @@ if(NOT SIMU_TARGET)
|
||||
return()
|
||||
endif()
|
||||
|
||||
foreach(FILE ${SRC})
|
||||
set(SIMU_SRC ${SIMU_SRC} ../../${FILE})
|
||||
endforeach()
|
||||
|
||||
set(SIMU_SRC
|
||||
${SIMU_SRC}
|
||||
set(SIMU_DRIVERS
|
||||
simpgmspace.cpp
|
||||
simueeprom.cpp
|
||||
simufatfs.cpp
|
||||
@@ -23,11 +18,6 @@ set(SIMU_SRC
|
||||
bt_driver.cpp
|
||||
)
|
||||
|
||||
if(SIMU_DISKIO)
|
||||
set(SIMU_SRC ${SIMU_SRC} ../../${FATFS_DIR}/ff.c ../../${FATFS_DIR}/option/ccsbcs.c)
|
||||
endif()
|
||||
|
||||
remove_definitions(-DCLI)
|
||||
|
||||
if(SDL_FOUND)
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
@@ -40,7 +30,7 @@ endif()
|
||||
|
||||
if(SIMU_BOOTLOADER)
|
||||
add_definitions(-DSIMU_BOOTLOADER)
|
||||
set(SIMU_SRC ${SIMU_SRC}
|
||||
set(SIMU_DRIVERS ${SIMU_DRIVERS}
|
||||
../../targets/common/arm/stm32/bootloader/bin_files.cpp
|
||||
../../targets/common/arm/stm32/bootloader/boot.cpp
|
||||
../../targets/${TARGET_DIR}/bootloader/boot_menu.cpp
|
||||
@@ -48,16 +38,44 @@ if(SIMU_BOOTLOADER)
|
||||
)
|
||||
endif()
|
||||
|
||||
# Pack all simu driver sources into an object lib
|
||||
add_library(simu_drivers OBJECT EXCLUDE_FROM_ALL
|
||||
${SIMU_DRIVERS})
|
||||
|
||||
get_property(SIMU_SRC_OPTIONS
|
||||
TARGET radiolib_native
|
||||
PROPERTY INTERFACE_COMPILE_OPTIONS)
|
||||
|
||||
target_compile_options(simu_drivers PRIVATE ${SIMU_SRC_OPTIONS})
|
||||
|
||||
set_property(TARGET simu_drivers PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# Replace SIMU_SRC with the objects from radiolib_native & simu_drivers
|
||||
set(SIMU_SRC
|
||||
$<TARGET_OBJECTS:radiolib_native>
|
||||
$<TARGET_OBJECTS:simu_drivers>
|
||||
)
|
||||
set(SIMU_SRC ${SIMU_SRC} PARENT_SCOPE)
|
||||
|
||||
# Set the options as well in parent scope to be used by unit tests
|
||||
set(SIMU_SRC_OPTIONS ${SIMU_SRC_OPTIONS} PARENT_SCOPE)
|
||||
|
||||
if(Qt5Widgets_FOUND)
|
||||
set(SIMULATOR_FLAVOUR edgetx-${FLAVOUR})
|
||||
set(SIMULATOR_TARGET ${SIMULATOR_FLAVOUR}-simulator)
|
||||
|
||||
add_definitions(-DSIMULATOR_FLAVOUR="${SIMULATOR_FLAVOUR}")
|
||||
include_directories(${COMPANION_SRC_DIRECTORY} ${COMPANION_SRC_DIRECTORY}/simulation)
|
||||
qt5_wrap_cpp(SIMULATOR_SRC ${COMPANION_SRC_DIRECTORY}/simulation/simulatorinterface.h opentxsimulator.h)
|
||||
|
||||
qt5_wrap_cpp(SIMULATOR_SRC
|
||||
${COMPANION_SRC_DIRECTORY}/simulation/simulatorinterface.h
|
||||
opentxsimulator.h
|
||||
)
|
||||
list(APPEND SIMULATOR_SRC ${SIMU_SRC} opentxsimulator.cpp)
|
||||
add_library(${SIMULATOR_TARGET} SHARED ${SIMULATOR_SRC})
|
||||
add_dependencies(${SIMULATOR_TARGET} ${RADIO_DEPENDENCIES})
|
||||
target_compile_definitions(${SIMULATOR_TARGET} PUBLIC ${APP_COMMON_DEFINES}) # set in top-level CMakeLists
|
||||
|
||||
target_compile_options(${SIMULATOR_TARGET} PRIVATE ${SIMU_SRC_OPTIONS})
|
||||
target_compile_definitions(${SIMULATOR_TARGET} PUBLIC ${APP_COMMON_DEFINES})
|
||||
target_link_libraries(${SIMULATOR_TARGET} ${SDL_LIBRARY} Qt5::Core)
|
||||
|
||||
# Remove debug symbols on release builds
|
||||
@@ -138,22 +156,14 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
|
||||
use_cxx11() # ensure gnu++11 in CXX_FLAGS with CMake < 3.1
|
||||
|
||||
if(FOX_FOUND)
|
||||
if(SIMU_DISKIO)
|
||||
set(SIMU_SRC ${SIMU_SRC} ${FATFS_DIR}/FatFs/ff.c ${FATFS_DIR}/option/ccsbcs.c)
|
||||
endif()
|
||||
|
||||
add_executable(simu WIN32
|
||||
EXCLUDE_FROM_ALL
|
||||
${SIMU_SRC} ${RADIO_SRC_DIR}/simu.cpp)
|
||||
|
||||
add_dependencies(simu ${RADIO_DEPENDENCIES})
|
||||
${SIMU_SRC}
|
||||
${RADIO_SRC_DIR}/simu.cpp)
|
||||
|
||||
target_include_directories(simu PUBLIC ${FOX_INCLUDE_DIR} )
|
||||
target_link_libraries(simu ${FOX_LIBRARY} pthread ${SDL_LIBRARY})
|
||||
target_compile_definitions(simu PUBLIC -DSIMU)
|
||||
if(SIMU_DISKIO)
|
||||
target_compile_definitions(simu PUBLIC -DSIMU_DISKIO)
|
||||
endif()
|
||||
target_compile_options(simu PRIVATE -DSIMU)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
FILE * diskImage = 0;
|
||||
FATFS g_FATFS_Obj = {0};
|
||||
|
||||
bool _g_FATFS_init = false;
|
||||
|
||||
RTOS_MUTEX_HANDLE ioMutex;
|
||||
|
||||
@@ -242,9 +243,39 @@ void sdDone()
|
||||
}
|
||||
}
|
||||
|
||||
void sdMount()
|
||||
{
|
||||
TRACE("sdMount");
|
||||
|
||||
diskCache.clear();
|
||||
|
||||
if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) {
|
||||
// call sdGetFreeSectors() now because f_getfree() takes a long time first time it's called
|
||||
_g_FATFS_init = true;
|
||||
sdGetFreeSectors();
|
||||
|
||||
#if defined(LOG_TELEMETRY)
|
||||
f_open(&g_telemetryFile, LOGS_PATH "/telemetry.log", FA_OPEN_ALWAYS | FA_WRITE);
|
||||
if (f_size(&g_telemetryFile) > 0) {
|
||||
f_lseek(&g_telemetryFile, f_size(&g_telemetryFile)); // append
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LOG_BLUETOOTH)
|
||||
f_open(&g_bluetoothFile, LOGS_PATH "/bluetooth.log", FA_OPEN_ALWAYS | FA_WRITE);
|
||||
if (f_size(&g_bluetoothFile) > 0) {
|
||||
f_lseek(&g_bluetoothFile, f_size(&g_bluetoothFile)); // append
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
TRACE("f_mount() failed");
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t sdMounted()
|
||||
{
|
||||
return g_FATFS_Obj.fs_type != 0;
|
||||
return _g_FATFS_init && (g_FATFS_Obj.fs_type != 0);
|
||||
}
|
||||
|
||||
uint32_t sdIsHC()
|
||||
|
||||
@@ -125,16 +125,15 @@ void eepromStartWrite(uint8_t * buffer, size_t address, size_t size)
|
||||
eepromTransmitData(address, buffer, size, false);
|
||||
}
|
||||
|
||||
bool _eeprom_write_simu_delay = true;
|
||||
|
||||
void eepromWriteBlock(uint8_t * buffer, size_t address, size_t size)
|
||||
{
|
||||
eepromStartWrite(buffer, address, size);
|
||||
|
||||
while (!eepromIsTransferComplete()) {
|
||||
#if defined(GTESTS)
|
||||
sleep(0/*ms*/);
|
||||
#else
|
||||
sleep(1/*ms*/);
|
||||
#endif
|
||||
if (_eeprom_write_simu_delay)
|
||||
sleep(1/*ms*/);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user