mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 04:53:34 +08:00
Clean up of app.h
app.h, generated from app.h_in, has unnecessary code duplication and isn't a header file (it defines globals, static functions and doesn't have a header guard, moreover, it has a 'using namespace std;'). Because of this, a real headerfile that declares the stuff defined in apps.h was missing leading to even more code duplication: scattered forward declarations in .cpp files and an often repeated type of std::map<std::string, px4_main_t>. This patch moves cmake/qurt/apps.h_in to src/platforms/apps.cpp.in (with some changes) and removes cmake/posix/apps.h_in. Then src/platforms/apps.cpp.in is split into src/platforms/apps.cpp.in and src/platforms/apps.h.in, splitting declarations from definitions. A typedef is defined for the map (apps_map_type). The main difference between cmake/posix/apps.h_in and cmake/qurt/apps.h_in was that the first defined a global 'apps', while qurt stores the apps in QShell. I opted to get rid of the global variable (which are in general evil for various reasons) and used the API of cmake/qurt/apps.h_in where a provided 'apps' map is initialized with a call to init_app_map. Thus removing the existing code duplication.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
px4_posix_generate_builtin_commands(
|
||||
OUT apps.h
|
||||
OUT apps
|
||||
MODULE_LIST ${module_libraries})
|
||||
|
||||
if ("${BOARD}" STREQUAL "eagle" OR ("${BOARD}" STREQUAL "excelsior"))
|
||||
@@ -19,7 +19,7 @@ if ("${BOARD}" STREQUAL "eagle" OR ("${BOARD}" STREQUAL "excelsior"))
|
||||
SOURCES
|
||||
px4muorb_stub.c
|
||||
${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp
|
||||
apps.h
|
||||
apps.cpp
|
||||
LINK_LIBS
|
||||
-Wl,--start-group
|
||||
${module_libraries}
|
||||
@@ -41,7 +41,7 @@ elseif ("${BOARD}" STREQUAL "rpi")
|
||||
|
||||
px4_add_executable(px4
|
||||
${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp
|
||||
apps.h
|
||||
apps.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(px4
|
||||
@@ -68,7 +68,7 @@ elseif ("${BOARD}" STREQUAL "bebop")
|
||||
|
||||
px4_add_executable(px4
|
||||
${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp
|
||||
apps.h
|
||||
apps.cpp
|
||||
)
|
||||
|
||||
if (NOT APPLE)
|
||||
@@ -98,7 +98,7 @@ else()
|
||||
|
||||
px4_add_executable(px4
|
||||
${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp
|
||||
apps.h
|
||||
apps.cpp
|
||||
)
|
||||
|
||||
if (NOT APPLE)
|
||||
|
||||
@@ -9,7 +9,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes")
|
||||
|
||||
px4_qurt_generate_builtin_commands(
|
||||
OUT ${PX4_BINARY_DIR}/apps.h
|
||||
OUT ${PX4_BINARY_DIR}/apps
|
||||
MODULE_LIST ${module_libraries})
|
||||
|
||||
FASTRPC_STUB_GEN(px4muorb.idl)
|
||||
@@ -23,7 +23,7 @@ if ("${QURT_ENABLE_STUBS}" STREQUAL "1")
|
||||
)
|
||||
add_executable(px4
|
||||
${PX4_BINARY_DIR}/src/firmware/qurt/px4muorb_skel.c
|
||||
${PX4_BINARY_DIR}/apps.h)
|
||||
${PX4_BINARY_DIR}/apps.cpp)
|
||||
|
||||
target_link_libraries(px4
|
||||
-Wl,--start-group
|
||||
@@ -42,7 +42,7 @@ else()
|
||||
QURT_LIB(LIB_NAME px4
|
||||
IDL_NAME px4muorb
|
||||
SOURCES
|
||||
${PX4_BINARY_DIR}/apps.h
|
||||
${PX4_BINARY_DIR}/apps.cpp
|
||||
LINK_LIBS
|
||||
${module_libraries}
|
||||
${target_libraries}
|
||||
|
||||
Reference in New Issue
Block a user