Skip to content
Snippets Groups Projects
Commit 0e4034d0 authored by Beat Küng's avatar Beat Küng
Browse files

param: add a px4_parameters_public.h.jinja template

Generates an enum with all params & additional type information for static
type checking

The generated public param header is required to build the modules using
the new BlockParam classes.
parent 0a5af014
No related branches found
No related tags found
No related merge requests found
......@@ -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})
......
......@@ -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
......
......@@ -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:
......
{# 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 */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment