HAL_ESP32: allow for building of examples and tool firmware on ESP32

use waf build target to find the right library name
This commit is contained in:
Andrew Tridgell 2023-12-29 15:51:20 +11:00
parent 564041f592
commit 687c5887af
2 changed files with 31 additions and 25 deletions

View File

@ -34,25 +34,31 @@ if(NOT DEFINED ARDUPILOT_CMD)
set(ARDUPILOT_CMD "none") set(ARDUPILOT_CMD "none")
endif() endif()
IF(${ARDUPILOT_CMD} STREQUAL "plane") message("ARDUPILOT_CMD=${ARDUPILOT_CMD}")
message("WAF_BUILD_TARGET=${WAF_BUILD_TARGET}")
string(REGEX MATCH "^(examples|tool)/" IS_EXAMPLE "${WAF_BUILD_TARGET}")
if (IS_EXAMPLE)
string(REPLACE "/" ";" A ${WAF_BUILD_TARGET})
list(GET A 0 EXAMPLE_BASE)
list(GET A 1 EXAMPLE_NAME)
message("Building ${EXAMPLE_BASE} ${EXAMPLE_NAME}")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/${EXAMPLE_BASE}/lib${EXAMPLE_NAME}.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libap.a")
ELSEIF(${ARDUPILOT_CMD} STREQUAL "plane")
message("Building for plane") message("Building for plane")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarduplane.a") target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarduplane.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduPlane_libs.a") target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduPlane_libs.a")
ENDIF() ELSEIF(${ARDUPILOT_CMD} STREQUAL "copter")
IF(${ARDUPILOT_CMD} STREQUAL "copter")
message("Building for copter") message("Building for copter")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarducopter.a") target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarducopter.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduCopter_libs.a") target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduCopter_libs.a")
ENDIF() ELSEIF(${ARDUPILOT_CMD} STREQUAL "rover")
IF(${ARDUPILOT_CMD} STREQUAL "rover")
message("Building for rover") message("Building for rover")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardurover.a") target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardurover.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libRover_libs.a") target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libRover_libs.a")
ENDIF() ELSEIF(${ARDUPILOT_CMD} STREQUAL "sub")
IF(${ARDUPILOT_CMD} STREQUAL "sub")
message("Building for submarine") message("Building for submarine")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardusub.a") target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardusub.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduSub_libs.a") target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduSub_libs.a")

View File

@ -34,35 +34,35 @@ if(NOT DEFINED ARDUPILOT_CMD)
set(ARDUPILOT_CMD "none") set(ARDUPILOT_CMD "none")
endif() endif()
IF(${ARDUPILOT_CMD} STREQUAL "plane") message("WAF_BUILD_TARGET=${WAF_BUILD_TARGET}")
string(REGEX MATCH "^(examples|tool)/" IS_EXAMPLE "${WAF_BUILD_TARGET}")
if (IS_EXAMPLE)
string(REPLACE "/" ";" A ${WAF_BUILD_TARGET})
list(GET A 0 EXAMPLE_BASE)
list(GET A 1 EXAMPLE_NAME)
message("Building ${EXAMPLE_BASE} ${EXAMPLE_NAME}")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/${EXAMPLE_BASE}/lib${EXAMPLE_NAME}.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libap.a")
ELSEIF(${ARDUPILOT_CMD} STREQUAL "plane")
message("Building for plane") message("Building for plane")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarduplane.a") target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarduplane.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduPlane_libs.a") target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduPlane_libs.a")
ENDIF() ELSEIF(${ARDUPILOT_CMD} STREQUAL "copter")
IF(${ARDUPILOT_CMD} STREQUAL "copter")
message("Building for copter") message("Building for copter")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarducopter.a") target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarducopter.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduCopter_libs.a") target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduCopter_libs.a")
ENDIF() ELSEIF(${ARDUPILOT_CMD} STREQUAL "rover")
IF(${ARDUPILOT_CMD} STREQUAL "rover")
message("Building for rover") message("Building for rover")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardurover.a") target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardurover.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libRover_libs.a") target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libRover_libs.a")
ENDIF() ELSEIF(${ARDUPILOT_CMD} STREQUAL "sub")
IF(${ARDUPILOT_CMD} STREQUAL "sub")
message("Building for submarine") message("Building for submarine")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardusub.a") target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardusub.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduSub_libs.a") target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduSub_libs.a")
ENDIF() ENDIF()
IF(${ARDUPILOT_CMD} STREQUAL "antennatracker")
message("Building AntennaTracker")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libantennatracker.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libAntennaTracker_libs.a")
ENDIF()
add_custom_target(showinc ALL add_custom_target(showinc ALL
COMMAND echo -e COMMAND echo -e
"$<TARGET_PROPERTY:${elf_file},INCLUDE_DIRECTORIES>" "$<TARGET_PROPERTY:${elf_file},INCLUDE_DIRECTORIES>"