Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify param scoping (fix out of tree builds) and fix qurt fc_addon linking #8325

Merged
merged 3 commits into from Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 5 additions & 16 deletions CMakeLists.txt
Expand Up @@ -397,33 +397,22 @@ execute_process(COMMAND cmake -E make_directory ${ep_base}/Install/include)
#=============================================================================
# external modules
#
set(external_module_paths)
if (NOT EXTERNAL_MODULES_LOCATION STREQUAL "")
message(STATUS "External modules: ${EXTERNAL_MODULES_LOCATION}")
add_subdirectory("${EXTERNAL_MODULES_LOCATION}/src" external_modules_src)
add_subdirectory("${EXTERNAL_MODULES_LOCATION}/src" external_modules)

set(config_module_list_external_expanded)
foreach(external_module ${config_module_list_external})
list(APPEND config_module_list_external_expanded
${EXTERNAL_MODULES_LOCATION}/src/${external_module})
add_subdirectory(${EXTERNAL_MODULES_LOCATION}/src/${external_module} external_modules/${external_module})
list(APPEND external_module_paths ${EXTERNAL_MODULES_LOCATION}/src/${external_module})
endforeach()
set(config_module_list
${config_module_list}
${config_module_list_external_expanded}
)
endif()

#=============================================================================
# subdirectories
#
foreach(module ${config_module_list})
string(REGEX MATCH "^[./]" external_module ${module})
if (external_module)
STRING(REGEX REPLACE "//" "/" EXT_MODULE ${module})
STRING(REGEX REPLACE "/" "__" EXT_MODULE_PREFIX ${EXT_MODULE})
add_subdirectory(${module} ${PX4_BINARY_DIR}/${EXT_MODULE_PREFIX})
else()
add_subdirectory(src/${module})
endif()
add_subdirectory(src/${module})
endforeach()

add_subdirectory(src/firmware/${OS})
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -240,8 +240,8 @@ check_%:
.PHONY: parameters_metadata airframe_metadata module_documentation px4_metadata

parameters_metadata:
@python $(SRC_DIR)/Tools/px_process_params.py -s `find $(SRC_DIR)/src -maxdepth 3 -type d` --inject-xml $(SRC_DIR)/Tools/parameters_injected.xml --markdown
@python $(SRC_DIR)/Tools/px_process_params.py -s `find $(SRC_DIR)/src -maxdepth 3 -type d` --inject-xml $(SRC_DIR)/Tools/parameters_injected.xml --xml
@python $(SRC_DIR)/src/modules/systemlib/param/px_process_params.py -s `find $(SRC_DIR)/src -maxdepth 3 -type d` --inject-xml $(SRC_DIR)/src/modules/systemlib/param/parameters_injected.xml --markdown
@python $(SRC_DIR)/src/modules/systemlib/param/px_process_params.py -s `find $(SRC_DIR)/src -maxdepth 3 -type d` --inject-xml $(SRC_DIR)/src/modules/systemlib/param/parameters_injected.xml --xml

airframe_metadata:
@python $(SRC_DIR)/Tools/px_process_airframes.py -v -a $(SRC_DIR)/ROMFS/px4fmu_common/init.d --markdown
Expand Down
23 changes: 10 additions & 13 deletions cmake/common/px4_base.cmake
Expand Up @@ -205,12 +205,6 @@ function(px4_add_module)
set(STACK_MAIN_DEFAULT 1024)
set(PRIORITY_DEFAULT SCHED_PRIORITY_DEFAULT)

# default stack max to stack main
if(NOT STACK_MAIN AND STACK)
set(STACK_MAIN ${STACK})
message(AUTHOR_WARNING "STACK deprecated, USE STACK_MAIN instead!")
endif()

foreach(property MAIN STACK_MAIN PRIORITY)
if(NOT ${property})
set(${property} ${${property}_DEFAULT})
Expand All @@ -227,15 +221,18 @@ function(px4_add_module)
if(${OS} STREQUAL "qurt" )
set_property(TARGET ${MODULE} PROPERTY POSITION_INDEPENDENT_CODE TRUE)
elseif(${OS} STREQUAL "nuttx" )
list(APPEND COMPILE_FLAGS -Wframe-larger-than=${STACK_MAX})
target_compile_options(${MODULE} PRIVATE -Wframe-larger-than=${STACK_MAX})
endif()

if(MAIN)
set_target_properties(${MODULE} PROPERTIES
COMPILE_DEFINITIONS PX4_MAIN=${MAIN}_app_main)
add_definitions(-DMODULE_NAME="${MAIN}")
target_compile_definitions(${MODULE} PRIVATE PX4_MAIN=${MAIN}_app_main)
target_compile_definitions(${MODULE} PRIVATE MODULE_NAME="${MAIN}")
else()
add_definitions(-DMODULE_NAME="${MODULE}")
target_compile_definitions(${MODULE} PRIVATE MODULE_NAME="${MODULE}")
endif()

if(COMPILE_FLAGS)
target_compile_options(${MODULE} PRIVATE ${COMPILE_FLAGS})
endif()

if(INCLUDES)
Expand All @@ -247,7 +244,7 @@ function(px4_add_module)
endif()

# join list variables to get ready to send to compiler
foreach(prop LINK_FLAGS COMPILE_FLAGS)
foreach(prop LINK_FLAGS)
if(${prop})
px4_join(OUT ${prop} LIST ${${prop}} GLUE " ")
endif()
Expand All @@ -259,7 +256,7 @@ function(px4_add_module)
if(COMPILE_FLAGS AND ${_no_optimization_for_target})
px4_strip_optimization(COMPILE_FLAGS ${COMPILE_FLAGS})
endif()
foreach (prop COMPILE_FLAGS LINK_FLAGS STACK_MAIN MAIN PRIORITY)
foreach (prop LINK_FLAGS STACK_MAIN MAIN PRIORITY)
if (${prop})
set_target_properties(${MODULE} PROPERTIES ${prop} ${${prop}})
endif()
Expand Down
28 changes: 16 additions & 12 deletions src/modules/systemlib/param/CMakeLists.txt
Expand Up @@ -51,7 +51,10 @@ endif()
set(module_list)
if (DISABLE_PARAMS_MODULE_SCOPING)
# search all directories with .c files (potentially containing parameters)
file(GLOB_RECURSE new_list ${PX4_SOURCE_DIR}/src/*.c)
file(GLOB_RECURSE new_list
${PX4_SOURCE_DIR}/src/*.c
${external_module_paths}
)
foreach(file_path ${new_list})
get_filename_component(dir_path ${file_path} PATH)
list(APPEND module_list "${dir_path}")
Expand All @@ -61,17 +64,21 @@ else()
foreach(module ${config_module_list})
list(APPEND module_list ${PX4_SOURCE_DIR}/src/${module})
endforeach()
list(APPEND module_list
${external_module_paths}
)
endif()

set(parameters_xml ${PX4_BINARY_DIR}/parameters.xml)
file(GLOB_RECURSE param_src_files ${PX4_SOURCE_DIR}/src/*params.c)
add_custom_command(OUTPUT ${parameters_xml}
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_params.py
-s ${module_list} ${EXTERNAL_MODULES_LOCATION}
--board CONFIG_ARCH_${BOARD} --xml --inject-xml
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/px_process_params.py
--src-path ${module_list}
--xml ${parameters_xml}
--inject-xml ${CMAKE_CURRENT_SOURCE_DIR}/parameters_injected.xml
--overrides ${PARAM_DEFAULT_OVERRIDES}
DEPENDS ${param_src_files} ${PX4_SOURCE_DIR}/Tools/px_process_params.py
WORKING_DIRECTORY ${PX4_BINARY_DIR}
#--verbose
DEPENDS ${param_src_files} px_process_params.py parameters_injected.xml
COMMENT "Generating parameters.xml"
)
add_custom_target(parameters_xml DEPENDS ${parameters_xml})
Expand All @@ -82,12 +89,10 @@ add_custom_command(OUTPUT px4_parameters.c px4_parameters.h
--xml ${parameters_xml} --dest ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
${PX4_BINARY_DIR}/parameters.xml
${CMAKE_CURRENT_SOURCE_DIR}/px_generate_params.py
${CMAKE_CURRENT_SOURCE_DIR}/templates/px4_parameters.c.jinja
${CMAKE_CURRENT_SOURCE_DIR}/templates/px4_parameters.h.jinja
px_generate_params.py
templates/px4_parameters.c.jinja
templates/px4_parameters.h.jinja
)
set_source_files_properties(px4_parameters.c PROPERTIES GENERATED TRUE)
set_source_files_properties(px4_parameters.h PROPERTIES GENERATED TRUE)

px4_add_module(
MODULE modules__systemlib__param
Expand All @@ -102,4 +107,3 @@ px4_add_module(
DEPENDS
platforms__common
)
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 5 additions & 15 deletions src/platforms/qurt/fc_addon/mpu_spi/CMakeLists.txt
Expand Up @@ -41,29 +41,19 @@ else()
set(FC_ADDON $ENV{FC_ADDON})
endif()

add_library(libmpu9x50 SHARED IMPORTED GLOBAL)
set_target_properties(libmpu9x50 PROPERTIES IMPORTED_LOCATION ${FC_ADDON}/flight_controller/hexagon/libs/libmpu9x50.so)

include_directories(
${FC_ADDON}/flight_controller/hexagon/inc
)
add_library(mpu9x50 SHARED IMPORTED GLOBAL)
set_target_properties(mpu9x50 PROPERTIES IMPORTED_LOCATION ${FC_ADDON}/flight_controller/hexagon/libs/libmpu9x50.so)

px4_add_module(
MODULE platforms__qurt__fc_addon__mpu_spi
MAIN mpu9x50
STACK_MAIN 1200
COMPILE_FLAGS
INCLUDES
${FC_ADDON}/flight_controller/hexagon/inc
SRCS
mpu9x50_main.cpp
mpu9x50_params.c
DEPENDS
platforms__common
)

set(module_external_libraries
${module_external_libraries}
libmpu9x50
CACHE INTERNAL "module_external_libraries"
)

# vim: set noet ft=cmake fenc=utf-8 ff=unix :
target_link_libraries(platforms__qurt__fc_addon__mpu_spi PRIVATE mpu9x50)
25 changes: 7 additions & 18 deletions src/platforms/qurt/fc_addon/rc_receiver/CMakeLists.txt
Expand Up @@ -41,30 +41,19 @@ else()
set(FC_ADDON $ENV{FC_ADDON})
endif()

include_directories(
${FC_ADDON}/flight_controller/hexagon/inc
)

add_library(librc_receiver SHARED IMPORTED GLOBAL)
set_target_properties(librc_receiver PROPERTIES IMPORTED_LOCATION ${FC_ADDON}/flight_controller/hexagon/libs/librc_receiver.so)
add_library(rc_receiver SHARED IMPORTED GLOBAL)
set_target_properties(rc_receiver PROPERTIES IMPORTED_LOCATION ${FC_ADDON}/flight_controller/hexagon/libs/librc_receiver.so)

px4_add_module(
MODULE platforms__qurt__fc_addon__rc_receiver
MAIN rc_receiver
MODULE platforms__qurt__fc_addon__rc_receiver
MAIN rc_receiver
STACK_MAIN 1200
COMPILE_FLAGS
INCLUDES
${FC_ADDON}/flight_controller/hexagon/inc
SRCS
rc_receiver_main.cpp
rc_receiver_params.c

DEPENDS
platforms__common
)

set(module_external_libraries
${module_external_libraries}
librc_receiver
CACHE INTERNAL "module_external_libraries"
)

# vim: set noet ft=cmake fenc=utf-8 ff=unix :
target_link_libraries(platforms__qurt__fc_addon__rc_receiver PRIVATE rc_receiver)
33 changes: 11 additions & 22 deletions src/platforms/qurt/fc_addon/uart_esc/CMakeLists.txt
Expand Up @@ -41,30 +41,19 @@ else()
set(FC_ADDON $ENV{FC_ADDON})
endif()

include_directories(
${FC_ADDON}/flight_controller/hexagon/inc
)

add_library(libuart_esc SHARED IMPORTED GLOBAL)
set_target_properties(libuart_esc PROPERTIES IMPORTED_LOCATION ${FC_ADDON}/flight_controller/hexagon/libs/libuart_esc.so)
add_library(uart_esc SHARED IMPORTED GLOBAL)
set_target_properties(uart_esc PROPERTIES IMPORTED_LOCATION ${FC_ADDON}/flight_controller/hexagon/libs/libuart_esc.so)

px4_add_module(
MODULE platforms__qurt__fc_addon__uart_esc
MAIN uart_esc
MODULE platforms__qurt__fc_addon__uart_esc
MAIN uart_esc
STACK_MAIN 1200
COMPILE_FLAGS
SRCS
uart_esc_main.cpp
INCLUDES
${FC_ADDON}/flight_controller/hexagon/inc
SRCS
uart_esc_main.cpp
uart_esc_params.c

DEPENDS
platforms__common
)

set(module_external_libraries
${module_external_libraries}
libuart_esc
CACHE INTERNAL "module_external_libraries"
DEPENDS
platforms__common
)

# vim: set noet ft=cmake fenc=utf-8 ff=unix :
target_link_libraries(platforms__qurt__fc_addon__uart_esc PRIVATE uart_esc)