diff options
author | Josh Blum | 2013-07-17 22:15:23 -0700 |
---|---|---|
committer | Josh Blum | 2013-07-17 22:15:23 -0700 |
commit | 356a1d290297bf72a574876de0404512266ec845 (patch) | |
tree | 1409002a1f26217ded47ef0883ed4c031008425c | |
parent | 6d07c50dafbe38049dbede7241e9e66eea0a699e (diff) | |
download | sandhi-356a1d290297bf72a574876de0404512266ec845.tar.gz sandhi-356a1d290297bf72a574876de0404512266ec845.tar.bz2 sandhi-356a1d290297bf72a574876de0404512266ec845.zip |
gras: module loading is recursive and takes files
m--------- | grextras | 0 | ||||
-rw-r--r-- | lib/module_loader.cpp | 18 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 12 |
3 files changed, 16 insertions, 14 deletions
diff --git a/grextras b/grextras -Subproject a552699da3dd8e3a274eb114373231349b7ca23 +Subproject 12cdd194513ec0fb05292950bfc133587b16685 diff --git a/lib/module_loader.cpp b/lib/module_loader.cpp index ce59502..00c34ab 100644 --- a/lib/module_loader.cpp +++ b/lib/module_loader.cpp @@ -28,19 +28,21 @@ namespace fs = boost::filesystem; static void load_all_modules_in_path(const fs::path &path) { - if (not fs::exists(fs::path(path))) return; - if (not fs::is_directory(fs::path(path))) return; - for( - fs::directory_iterator dir_itr(path); - dir_itr != fs::directory_iterator(); - ++dir_itr - ){ - const std::string mod_path = dir_itr->path().string(); + if (not fs::exists(path)) return; + if (fs::is_regular_file(path)) + { + const std::string mod_path = path.string(); if (not load_module_in_path(mod_path.c_str())) { std::cerr << "GRAS Module loader fail: " << mod_path << std::endl; } + return; } + if (fs::is_directory(path)) for( + fs::directory_iterator dir_itr(path); + dir_itr != fs::directory_iterator(); + ++dir_itr + ) load_all_modules_in_path(dir_itr->path()); } GRAS_STATIC_BLOCK(gras_module_loader) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f72dfab..5c76dbe 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -58,10 +58,10 @@ GR_ADD_TEST(time_tags_test ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/time add_library(example_module MODULE example_module.cpp) target_link_libraries(example_module ${GRAS_LIBRARIES}) -set(CURRENT_LIBRARY_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) -if(WIN32) -set(CURRENT_LIBRARY_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}) -endif() -file(TO_NATIVE_PATH "${CURRENT_LIBRARY_BUILD_DIR}" CURRENT_LIBRARY_BUILD_DIR) -list(APPEND GR_TEST_ENVIRONS "GRAS_MODULE_PATH=${CURRENT_LIBRARY_BUILD_DIR}") +get_target_property(example_module_location example_module LOCATION) +string(REPLACE "$(Configuration)" ${CMAKE_BUILD_TYPE} example_module_location ${example_module_location}) +file(TO_NATIVE_PATH "${example_module_location}" example_module_location) +message(STATUS "example_module_location: ${example_module_location}") + +list(APPEND GR_TEST_ENVIRONS "GRAS_MODULE_PATH=${example_module_location}") GR_ADD_TEST(module_loader_test ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/module_loader_test.py) |