cmake: fixes for apps.h generation for posix and qurt

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois 2015-09-08 19:17:53 -07:00
parent dbc60d99c5
commit b561215017
6 changed files with 29 additions and 22 deletions

View File

@ -22,9 +22,10 @@ static int list_topics_main(int argc, char *argv[]);
static int sleep_main(int argc, char *argv[]);
}
void init_app_map(map<string,px4_main_t> &apps)
static map<string,px4_main_t> app_map(void)
{
static map<string,px4_main_t> apps;
${builtin_apps_string}
apps["shutdown"] = shutdown_main;
apps["list_tasks"] = list_tasks_main;
@ -32,13 +33,17 @@ ${builtin_apps_string}
apps["list_devices"] = list_devices_main;
apps["list_topics"] = list_topics_main;
apps["sleep"] = sleep_main;
return apps;
}
void list_builtins(map<string,px4_main_t> &apps)
map<string,px4_main_t> apps = app_map();
static void list_builtins(void)
{
printf("Builtin Commands:\\n");
cout << "Builtin Commands:" << endl;
for (map<string,px4_main_t>::iterator it=apps.begin(); it!=apps.end(); ++it)
printf("\\t%s\\n", (it->first).c_str());
cout << '\t' << it->first << endl;
}
static int shutdown_main(int argc, char *argv[])
@ -64,21 +69,20 @@ static int list_topics_main(int argc, char *argv[])
px4_show_topics();
return 0;
}
static int list_files_main(int argc, char *argv[])
{
px4_show_files();
return 0;
}
static int sleep_main(int argc, char *argv[])
{
if (argc != 2) {
PX4_WARN( "Usage: sleep <seconds>" );
return 1;
}
unsigned long usecs = ( (unsigned long) atol( argv[1] ) ) * 1000 * 1000;
PX4_WARN("Sleeping for %s, %ld",argv[1],usecs);
usleep( usecs );
return 0;
if (argc != 2) {
cout << "Usage: sleep <seconds>" << endl;
return 1;
}
sleep(atoi(argv[1]));
return 0;
}

View File

@ -102,7 +102,7 @@ function(px4_posix_generate_builtin_commands)
math(EXPR command_count "${command_count}+1")
endif()
endforeach()
configure_file(${CMAKE_SOURCE_DIR}/cmake/posix/builtin_commands.cpp_in
configure_file(${CMAKE_SOURCE_DIR}/cmake/posix/apps.h_in
${OUT})
endfunction()

View File

@ -104,7 +104,7 @@ function(px4_qurt_generate_builtin_commands)
math(EXPR command_count "${command_count}+1")
endif()
endforeach()
configure_file(${CMAKE_SOURCE_DIR}/cmake/qurt/builtin_commands.cpp_in
configure_file(${CMAKE_SOURCE_DIR}/cmake/qurt/apps.h_in
${OUT})
endfunction()

View File

@ -7,8 +7,8 @@ message(STATUS "module list: ${module_dir_list}")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(OUTPUT apps.h
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/posix_apps.py > apps.h)
#add_custom_command(OUTPUT apps.h
# COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/posix_apps.py > apps.h)
foreach(directory ${module_dir_list})
message(STATUS "directory: ${directory}")
@ -17,13 +17,13 @@ foreach(directory ${module_dir_list})
${mangled_name})
endforeach()
px4_posix_generate_builtin_commands(
OUT builtin_commands.cpp
OUT apps.h
MODULE_LIST ${module_list})
add_executable(mainapp
${CMAKE_SOURCE_DIR}/src/platforms/posix/main.cpp
apps.h
builtin_commands.cpp)
)
set(main_link_flags
"-T${CMAKE_SOURCE_DIR}/cmake/posix/ld.script"

View File

@ -16,7 +16,7 @@ foreach(directory ${module_dir_list})
${mangled_name})
endforeach()
px4_qurt_generate_builtin_commands(
OUT builtin_commands.cpp
OUT apps.h
MODULE_LIST ${module_list})
# FIXME @jgoppert - how to work around issues like this?
@ -25,7 +25,10 @@ px4_qurt_generate_builtin_commands(
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
add_library(mainapp builtin_commands.cpp)
add_library(mainapp
${CMAKE_SOURCE_DIR}/src/platforms/qurt/px4_layer/main.cpp
apps.h)
target_link_libraries(mainapp
-Wl,--whole-archive
${module_list}