Fix #1442: Allow adding alternative .gatt file import paths (#1445)

* fix feature request #1442

* Do not require -I before each addtional path

* Fix pico_btstack_make_gatt_header warning

gatt header files are always made into the "generated" folder so you get
a warning if you have more than one target generating a gatt header with
the same name.

Also, simplify the expansion of ARGN

* Improve pico_btstack_make_gatt_header description

---------

Co-authored-by: Peter Harper <peter.harper@raspberrypi.com>
This commit is contained in:
rppicomidi 2024-01-16 07:43:57 -08:00 committed by GitHub
parent 62bb486f2a
commit f1c6fc8b6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -232,21 +232,22 @@ if (EXISTS ${PICO_BTSTACK_PATH}/${BTSTACK_TEST_PATH})
# Make a GATT header file from a BTstack GATT file
# Pass the target library name library type and path to the GATT input file
# To add additional directories to the gatt #import path, add them to the end of the argument list.
function(pico_btstack_make_gatt_header TARGET_LIB TARGET_TYPE GATT_FILE)
find_package (Python3 REQUIRED COMPONENTS Interpreter)
get_filename_component(GATT_NAME "${GATT_FILE}" NAME_WE)
get_filename_component(GATT_PATH "${GATT_FILE}" PATH)
set(GATT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(GATT_HEADER "${GATT_BINARY_DIR}/${GATT_NAME}.h")
set(TARGET_GATT "${TARGET_LIB}_gatt_header")
set(GATT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated/${TARGET_GATT}")
set(GATT_HEADER "${GATT_BINARY_DIR}/${GATT_NAME}.h")
list(TRANSFORM ARGN PREPEND "-I")
add_custom_target(${TARGET_GATT} DEPENDS ${GATT_HEADER})
add_custom_command(
OUTPUT ${GATT_HEADER}
DEPENDS ${GATT_FILE}
WORKING_DIRECTORY ${GATT_PATH}
COMMAND ${CMAKE_COMMAND} -E make_directory ${GATT_BINARY_DIR} &&
${Python3_EXECUTABLE} ${PICO_SDK_PATH}/lib/btstack/tool/compile_gatt.py ${GATT_FILE} ${GATT_HEADER}
${Python3_EXECUTABLE} ${PICO_SDK_PATH}/lib/btstack/tool/compile_gatt.py ${GATT_FILE} ${GATT_HEADER} ${ARGN}
VERBATIM)
add_dependencies(${TARGET_LIB}
${TARGET_GATT}