Skip to content

Commit

Permalink
HAL_ESP32: allow for building of examples and tool firmware on ESP32
Browse files Browse the repository at this point in the history
use waf build target to find the right library name
  • Loading branch information
tridge committed Dec 30, 2023
1 parent 564041f commit 687c588
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
26 changes: 16 additions & 10 deletions libraries/AP_HAL_ESP32/targets/esp32/esp-idf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,31 @@ if(NOT DEFINED ARDUPILOT_CMD)
set(ARDUPILOT_CMD "none")
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")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarduplane.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduPlane_libs.a")
ENDIF()

IF(${ARDUPILOT_CMD} STREQUAL "copter")
ELSEIF(${ARDUPILOT_CMD} STREQUAL "copter")
message("Building for copter")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarducopter.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduCopter_libs.a")
ENDIF()

IF(${ARDUPILOT_CMD} STREQUAL "rover")
ELSEIF(${ARDUPILOT_CMD} STREQUAL "rover")
message("Building for rover")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardurover.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libRover_libs.a")
ENDIF()

IF(${ARDUPILOT_CMD} STREQUAL "sub")
ELSEIF(${ARDUPILOT_CMD} STREQUAL "sub")
message("Building for submarine")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardusub.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduSub_libs.a")
Expand Down
30 changes: 15 additions & 15 deletions libraries/AP_HAL_ESP32/targets/esp32s3/esp-idf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,35 @@ if(NOT DEFINED ARDUPILOT_CMD)
set(ARDUPILOT_CMD "none")
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")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarduplane.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduPlane_libs.a")
ENDIF()

IF(${ARDUPILOT_CMD} STREQUAL "copter")
ELSEIF(${ARDUPILOT_CMD} STREQUAL "copter")
message("Building for copter")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libarducopter.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduCopter_libs.a")
ENDIF()

IF(${ARDUPILOT_CMD} STREQUAL "rover")
ELSEIF(${ARDUPILOT_CMD} STREQUAL "rover")
message("Building for rover")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardurover.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libRover_libs.a")
ENDIF()

IF(${ARDUPILOT_CMD} STREQUAL "sub")
ELSEIF(${ARDUPILOT_CMD} STREQUAL "sub")
message("Building for submarine")
target_link_libraries(${elf_file} "${ARDUPILOT_BIN}/libardusub.a")
target_link_libraries(${elf_file} "${ARDUPILOT_LIB}/libArduSub_libs.a")
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
COMMAND echo -e
"$<TARGET_PROPERTY:${elf_file},INCLUDE_DIRECTORIES>"
Expand Down

0 comments on commit 687c588

Please sign in to comment.