Changeset 5626
- Timestamp:
- Aug 11, 2009, 10:22:55 PM (15 years ago)
- Location:
- code/branches/libraries
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/libraries/cmake/BuildConfig.cmake
r5625 r5626 172 172 # when building, don't use the install RPATH already 173 173 # (but later on when installing) 174 SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 174 SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 175 175 176 176 # the RPATH to be used when installing -
code/branches/libraries/cmake/TargetUtilities.cmake
r5615 r5626 35 35 # NO_SOURCE_GROUPS: Don't create msvc source groups 36 36 # STATIC/SHARED: Inherited from ADD_LIBRARY 37 # PLUGIN: For dynamic plugin libraries 37 38 # WIN32: Inherited from ADD_EXECUTABLE 38 39 # PCH_NO_DEFAULT: Do not make precompiled header files default if … … 80 81 SET(_switches FIND_HEADER_FILES EXCLUDE_FROM_ALL ORXONOX_EXTERNAL 81 82 NO_DLL_INTERFACE NO_SOURCE_GROUPS ${_additional_switches} 82 PCH_NO_DEFAULT NO_INSTALL)83 PCH_NO_DEFAULT NO_INSTALL PLUGIN) 83 84 SET(_list_names LINK_LIBRARIES VERSION SOURCE_FILES DEFINE_SYMBOL 84 85 TOLUA_FILES PCH_FILE PCH_EXCLUDE OUTPUT_NAME) … … 147 148 ENDIF() 148 149 150 # PLUGIN A 151 IF(_arg_PLUGIN) 152 SET(_arg_PLUGIN MODULE) 153 SET(_arg_SHARED) 154 SET(_arg_STATIC) 155 ENDIF() 156 149 157 # Add the library/executable 150 158 IF("${_target_type}" STREQUAL "LIBRARY") 151 ADD_LIBRARY(${_target_name} ${_arg_STATIC} ${_arg_SHARED} 159 ADD_LIBRARY(${_target_name} ${_arg_STATIC} ${_arg_SHARED} ${_arg_PLUGIN} 152 160 ${_arg_EXCLUDE_FROM_ALL} ${_${_target_name}_files}) 153 161 ELSE() 154 162 ADD_EXECUTABLE(${_target_name} ${_arg_WIN32} ${_arg_EXCLUDE_FROM_ALL} 155 163 ${_${_target_name}_files}) 164 ENDIF() 165 166 # PLUGIN B 167 IF (_arg_PLUGIN) 168 SET_TARGET_PROPERTIES(${_target_name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_PLUGIN_OUTPUT_DIRECTORY}) 169 SET_TARGET_PROPERTIES(${_target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_PLUGIN_OUTPUT_DIRECTORY}) 170 ADD_PLUGIN(${_target_name}) 156 171 ENDIF() 157 172 … … 174 189 175 190 # OUTPUT_NAME 176 IF(_arg_OUTPUT_NAME 191 IF(_arg_OUTPUT_NAME) 177 192 SET_TARGET_PROPERTIES(${_target_name} PROPERTIES OUTPUT_NAME ${_arg_OUTPUT_NAME}) 178 193 ENDIF() … … 184 199 185 200 IF(NOT _arg_STATIC AND NOT _arg_NO_INSTALL) 201 SET(_library_destination ${ORXONOX_LIBRARY_INSTALL_PATH}) 202 IF (_arg_PLUGIN) 203 SET(_library_destination ${ORXONOX_PLUGIN_INSTALL_PATH}) 204 ENDIF() 205 186 206 INSTALL(TARGETS ${_target_name} 187 207 RUNTIME DESTINATION ${ORXONOX_RUNTIME_INSTALL_PATH} 188 LIBRARY DESTINATION ${ ORXONOX_LIBRARY_INSTALL_PATH}208 LIBRARY DESTINATION ${_library_destination} 189 209 #ARCHIVE DESTINATION ${ORXONOX_ARCHIVE_INSTALL_PATH} 190 210 ) … … 192 212 193 213 ENDFUNCTION(TU_ADD_TARGET) 214 215 216 # Creates a helper file with name <name_of_the_library>.plugin 217 # This helps finding dynamically loadable plugins at runtime 218 219 FUNCTION(ADD_PLUGIN _name) 220 # We use the properties to get the name because the librarys name may differ from 221 # the targets name (for example orxonox <-> liborxonox) 222 223 GET_TARGET_PROPERTY(_target_loc ${_name} LOCATION) 224 GET_FILENAME_COMPONENT(_target_name ${_target_loc} NAME_WE) 225 226 SET(_plugin_filename "${CMAKE_PLUGIN_OUTPUT_DIRECTORY}/${_target_name}.plugin") 227 228 FILE(WRITE ${_plugin_filename}) 229 230 INSTALL( 231 FILES ${_plugin_filename} 232 DESTINATION ${ORXONOX_PLUGIN_INSTALL_PATH} 233 ) 234 ENDFUNCTION(ADD_PLUGIN) -
code/branches/libraries/src/SpecialConfig.h.in
r5625 r5626 87 87 const char ORXONOX_LOG_DEV_PATH[] = "@CMAKE_LOG_OUTPUT_DIRECTORY@/" BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE); 88 88 #else 89 const char ORXONOX_PLUGIN_DEV_PATH[] = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@"; 89 90 const char ORXONOX_CONFIG_DEV_PATH[] = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@"; 90 91 const char ORXONOX_LOG_DEV_PATH[] = "@CMAKE_LOG_OUTPUT_DIRECTORY@"; -
code/branches/libraries/src/core/CMakeLists.txt
r3370 r5626 23 23 ConfigValueContainer.cc 24 24 Core.cc 25 DynLib.cc 26 DynLibManager.cc 25 27 Event.cc 26 28 Game.cc -
code/branches/libraries/src/core/Core.cc
r5625 r5626 40 40 #include <cstdlib> 41 41 #include <cstdio> 42 #include <boost/version.hpp> 42 43 #include <boost/filesystem.hpp> 43 44 #include <OgreRenderWindow.h> … … 68 69 #include "ConfigValueIncludes.h" 69 70 #include "CoreIncludes.h" 71 #include "DynLibManager.h" 70 72 #include "Factory.h" 71 73 #include "GameMode.h" … … 80 82 #include "input/InputManager.h" 81 83 84 // Boost 1.36 has some issues with deprecated functions that have been omitted 85 #if (BOOST_VERSION == 103600) 86 # define BOOST_LEAF_FUNCTION filename 87 #else 88 # define BOOST_LEAF_FUNCTION leaf 89 #endif 90 82 91 namespace orxonox 83 92 { … … 260 269 this->setFixedPaths(); 261 270 262 // TODO: Load plugins 271 // Create a new dynamic library manager 272 this->dynLibManager_.reset(new DynLibManager()); 273 274 // Load plugins 275 try 276 { 277 // We search for helper files with the following extension 278 std::string pluginextension = ".plugin"; 279 size_t pluginextensionlength = pluginextension.size(); 280 281 // Search in the directory of our executable 282 boost::filesystem::path searchpath = this->getRootPath() / ORXONOX_PLUGIN_INSTALL_PATH; 283 284 boost::filesystem::directory_iterator file(searchpath); 285 boost::filesystem::directory_iterator end; 286 287 // Iterate through all files 288 while (file != end) 289 { 290 std::string filename = file->BOOST_LEAF_FUNCTION(); 291 292 // Check if the file ends with the exension in question 293 if (filename.size() > pluginextensionlength) 294 { 295 if (filename.substr(filename.size() - pluginextensionlength) == pluginextension) 296 { 297 // We've found a helper file - now load the library with the same name 298 std::string library = filename.substr(0, filename.size() - pluginextensionlength); 299 boost::filesystem::path librarypath = searchpath / library; 300 301 this->dynLibManager_->load(librarypath.string()); 302 } 303 } 304 305 ++file; 306 } 307 } 308 catch (const std::exception& e) 309 { 310 COUT(1) << "An error occurred while loading plugins: " << e.what() << std::endl; 311 } 312 catch (...) 313 { 314 COUT(1) << "An error occurred while loading plugins." << std::endl; 315 } 263 316 264 317 // Parse command line arguments AFTER the plugins have been loaded (static code!) -
code/branches/libraries/src/core/Core.h
r5625 r5626 119 119 120 120 // Mind the order for the destruction! 121 scoped_ptr<DynLibManager> dynLibManager_; 121 122 scoped_ptr<SignalHandler> signalHandler_; 122 123 SimpleScopeGuard identifierDestroyer_; -
code/branches/libraries/src/core/CorePrereqs.h
r3370 r5626 112 112 class ConsoleCommand; 113 113 class Core; 114 class DynLib; 115 class DynLibManager; 114 116 struct Event; 115 117 class EventContainer;
Note: See TracChangeset
for help on using the changeset viewer.