diff --git a/CMakeLists.txt b/CMakeLists.txt index c5f1bf449b4d385ab5d541e0a438ff53e23b585b..fc5dec731e4bcc5b1934c45f76b7bb36e7730daa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -335,7 +335,7 @@ px4_join(OUT CMAKE_EXE_LINKER_FLAGS LIST "${CMAKE_EXE_LINKER_FLAGS};${exe_linker px4_join(OUT CMAKE_C_FLAGS LIST "${CMAKE_C_FLAGS};${c_flags};${optimization_flags}" GLUE " ") px4_join(OUT CMAKE_CXX_FLAGS LIST "${CMAKE_CXX_FLAGS};${cxx_flags};${optimization_flags}" GLUE " ") -include_directories(${include_dirs}) +include_directories(${include_dirs} ${CMAKE_CURRENT_BINARY_DIR}/src/modules/systemlib/param) link_directories(${link_dirs}) add_definitions(${definitions}) diff --git a/src/modules/systemlib/param/CMakeLists.txt b/src/modules/systemlib/param/CMakeLists.txt index c29c458c97e8c50b636cd63fb0fbab18185f0ad5..b74b3fc03b0be996809981e5f3f2b2c3bc833b40 100644 --- a/src/modules/systemlib/param/CMakeLists.txt +++ b/src/modules/systemlib/param/CMakeLists.txt @@ -98,8 +98,8 @@ add_custom_command(OUTPUT ${parameters_xml} ) add_custom_target(parameters_xml DEPENDS ${parameters_xml}) -# generate px4_parameters.c and px4_parameters.h -add_custom_command(OUTPUT px4_parameters.c px4_parameters.h +# generate px4_parameters.c and px4_parameters{,_public}.h +add_custom_command(OUTPUT px4_parameters.c px4_parameters.h px4_parameters_public.h COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/px_generate_params.py --xml ${parameters_xml} --dest ${CMAKE_CURRENT_BINARY_DIR} DEPENDS @@ -107,8 +107,12 @@ add_custom_command(OUTPUT px4_parameters.c px4_parameters.h px_generate_params.py templates/px4_parameters.c.jinja templates/px4_parameters.h.jinja + templates/px4_parameters_public.h.jinja ) +add_custom_target(parameter_headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/px4_parameters_public.h) +add_dependencies(prebuild_targets parameter_headers) + px4_add_module( MODULE modules__systemlib__param COMPILE_FLAGS diff --git a/src/modules/systemlib/param/px_generate_params.py b/src/modules/systemlib/param/px_generate_params.py index 103e0c3bced50a800f1f1476e07cf5b1ae6c1c84..af746fb7ed5d79f816892d5873ed1394059b2cbc 100755 --- a/src/modules/systemlib/param/px_generate_params.py +++ b/src/modules/systemlib/param/px_generate_params.py @@ -40,6 +40,7 @@ def generate(xml_file, dest='.'): template_files = [ 'px4_parameters.h.jinja', + 'px4_parameters_public.h.jinja', 'px4_parameters.c.jinja', ] for template_file in template_files: diff --git a/src/modules/systemlib/param/templates/px4_parameters_public.h.jinja b/src/modules/systemlib/param/templates/px4_parameters_public.h.jinja new file mode 100644 index 0000000000000000000000000000000000000000..5685f615aac0da9509975ece90d63f05120a0ecc --- /dev/null +++ b/src/modules/systemlib/param/templates/px4_parameters_public.h.jinja @@ -0,0 +1,37 @@ +{# jinja syntax: http://jinja.pocoo.org/docs/2.9/templates/ #} +#include <stdint.h> +#include <systemlib/param/param.h> + +// DO NOT EDIT +// This file is autogenerated from parameters.xml + + +#ifdef __cplusplus + +namespace px4 { {# wrap the enum in a namespace, otherwise we get shadowing errors for MAV_TYPE #} + +/// Enum with all parameters +enum class params { + {# enums are guaranteed to start with 0 (if the value for the first is not + specified), and then incremented by 1 #} +{%- for param in params %} + {{ param.attrib["name"] }}, +{%- endfor %} + + _COUNT +}; + +// All parameter types +{# (px4_parameters is marked as extern, so we cannot use it as constexpr) #} +static const constexpr int param_types_array[] = { +{%- for param in params %} + PARAM_TYPE_{{ param.attrib["type"] }}, // {{ param.attrib["name"] }} +{%- endfor %} +}; + + +} // namespace px4 + + +#endif /* __cplusplus */ +