mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 19:07:45 +08:00
Merge pull request #46 from mcharleb/cmake-mc
param: Build param without linker script
This commit is contained in:
+1
-1
@@ -226,7 +226,7 @@ link_directories(${link_dirs})
|
|||||||
add_definitions(${definitions})
|
add_definitions(${definitions})
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# source code generation}
|
# source code generation
|
||||||
#
|
#
|
||||||
file(GLOB_RECURSE msg_files msg/*.msg)
|
file(GLOB_RECURSE msg_files msg/*.msg)
|
||||||
px4_generate_messages(TARGET msg_gen
|
px4_generate_messages(TARGET msg_gen
|
||||||
|
|||||||
Executable
+53
@@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
import os
|
||||||
|
|
||||||
|
if len(os.sys.argv) != 3:
|
||||||
|
print "Error in %s" % os.sys.argv[0]
|
||||||
|
print "Usage: %s <parameters.xml> <parameters.c>"
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
|
fp = open(os.sys.argv[2], "w")
|
||||||
|
|
||||||
|
tree = ET.parse(os.sys.argv[1])
|
||||||
|
root = tree.getroot()
|
||||||
|
body = """
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <systemlib/param/param.h>
|
||||||
|
|
||||||
|
// DO NOT EDIT
|
||||||
|
// This file is autogenerated from paramaters.xml
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
start_name = ""
|
||||||
|
end_name = ""
|
||||||
|
|
||||||
|
for group in root:
|
||||||
|
if group.tag == "group":
|
||||||
|
body += "// %s\n" % group.attrib["name"]
|
||||||
|
for param in group:
|
||||||
|
if not start_name:
|
||||||
|
start_name = param.attrib["name"]
|
||||||
|
end_name = param.attrib["name"]
|
||||||
|
body += """
|
||||||
|
static const
|
||||||
|
__attribute__((used, section("__param")))
|
||||||
|
struct param_info_s __param__%s = {
|
||||||
|
"%s",
|
||||||
|
PARAM_TYPE_%s,
|
||||||
|
.val.f = %s
|
||||||
|
};
|
||||||
|
""" % (param.attrib["name"], param.attrib["name"], param.attrib["type"], param.attrib["default"])
|
||||||
|
body += """
|
||||||
|
extern const
|
||||||
|
__attribute__((alias("__param__%s")))
|
||||||
|
struct param_info_s __param_start;
|
||||||
|
|
||||||
|
extern const
|
||||||
|
__attribute__((alias("__param__%s")))
|
||||||
|
struct param_info_s __param_end;
|
||||||
|
""" % (start_name, end_name)
|
||||||
|
|
||||||
|
fp.write(body)
|
||||||
|
|
||||||
@@ -672,4 +672,18 @@ function(px4_create_git_hash_header)
|
|||||||
configure_file(${CMAKE_SOURCE_DIR}/cmake/templates/build_git_version.h.in ${HEADER} @ONLY)
|
configure_file(${CMAKE_SOURCE_DIR}/cmake/templates/build_git_version.h.in ${HEADER} @ONLY)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# parameter file generation
|
||||||
|
#
|
||||||
|
function(px4_generate_parameters)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/px_process_params.py -s ${CMAKE_SOURCE_DIR}/src --board ${BOARD} --xml
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/px_generate_params.py ${CMAKE_BINARY_DIR}/parameters.xml ${CMAKE_BINARY_DIR}/parameters.c
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
# vim: set noet fenc=utf-8 ff=unix nowrap:
|
# vim: set noet fenc=utf-8 ff=unix nowrap:
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
|
||||||
px4_posix_generate_builtin_commands(
|
px4_posix_generate_builtin_commands(
|
||||||
OUT apps.h
|
OUT apps.h
|
||||||
MODULE_LIST ${module_libraries})
|
MODULE_LIST ${module_libraries})
|
||||||
|
|
||||||
|
px4_generate_parameters()
|
||||||
|
|
||||||
add_executable(mainapp
|
add_executable(mainapp
|
||||||
${CMAKE_SOURCE_DIR}/src/platforms/posix/main.cpp
|
${CMAKE_SOURCE_DIR}/src/platforms/posix/main.cpp
|
||||||
|
${CMAKE_BINARY_DIR}/parameters.c
|
||||||
apps.h
|
apps.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(main_link_flags
|
|
||||||
"-T${CMAKE_SOURCE_DIR}/cmake/posix/ld.script"
|
|
||||||
)
|
|
||||||
px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ")
|
|
||||||
set_target_properties(mainapp PROPERTIES LINK_FLAGS ${main_link_flags})
|
|
||||||
|
|
||||||
target_link_libraries(mainapp
|
target_link_libraries(mainapp
|
||||||
-Wl,--start-group
|
-Wl,--start-group
|
||||||
${module_libraries}
|
${module_libraries}
|
||||||
|
|||||||
@@ -86,9 +86,11 @@ extern struct param_info_s param_array[];
|
|||||||
extern struct param_info_s *param_info_base;
|
extern struct param_info_s *param_info_base;
|
||||||
extern struct param_info_s *param_info_limit;
|
extern struct param_info_s *param_info_limit;
|
||||||
#else
|
#else
|
||||||
extern char __param_start, __param_end;
|
extern const struct param_info_s __param_start, __param_end;
|
||||||
static const struct param_info_s *param_info_base = (struct param_info_s *) &__param_start;
|
|
||||||
static const struct param_info_s *param_info_limit = (struct param_info_s *) &__param_end;
|
// FIXME - start and end are reversed
|
||||||
|
static const struct param_info_s *param_info_base = &__param_end;
|
||||||
|
static const struct param_info_s *param_info_limit = &__param_start;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define param_info_count ((unsigned)(param_info_limit - param_info_base))
|
#define param_info_count ((unsigned)(param_info_limit - param_info_base))
|
||||||
|
|||||||
@@ -346,34 +346,13 @@ __EXPORT int param_load_default(void);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** define an int32 parameter */
|
/** define an int32 parameter */
|
||||||
#define PARAM_DEFINE_INT32(_name, _default) \
|
#define PARAM_DEFINE_INT32(_name, _default)
|
||||||
static const \
|
|
||||||
__attribute__((used, section("__param"))) \
|
|
||||||
struct param_info_s __param__##_name = { \
|
|
||||||
#_name, \
|
|
||||||
PARAM_TYPE_INT32, \
|
|
||||||
.val.i = _default \
|
|
||||||
}
|
|
||||||
|
|
||||||
/** define a float parameter */
|
/** define a float parameter */
|
||||||
#define PARAM_DEFINE_FLOAT(_name, _default) \
|
#define PARAM_DEFINE_FLOAT(_name, _default)
|
||||||
static const \
|
|
||||||
__attribute__((used, section("__param"))) \
|
|
||||||
struct param_info_s __param__##_name = { \
|
|
||||||
#_name, \
|
|
||||||
PARAM_TYPE_FLOAT, \
|
|
||||||
.val.f = _default \
|
|
||||||
}
|
|
||||||
|
|
||||||
/** define a parameter that points to a structure */
|
/** define a parameter that points to a structure */
|
||||||
#define PARAM_DEFINE_STRUCT(_name, _default) \
|
#define PARAM_DEFINE_STRUCT(_name, _default)
|
||||||
static const \
|
|
||||||
__attribute__((used, section("__param"))) \
|
|
||||||
struct param_info_s __param__##_name = { \
|
|
||||||
#_name, \
|
|
||||||
PARAM_TYPE_STRUCT + sizeof(_default), \
|
|
||||||
.val.p = &_default \
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameter value union.
|
* Parameter value union.
|
||||||
|
|||||||
Reference in New Issue
Block a user