[Orxonox-commit 902] r5625 - in code/branches/libraries: cmake src src/core

rgrieder at orxonox.net rgrieder at orxonox.net
Tue Aug 11 17:57:18 CEST 2009


Author: rgrieder
Date: 2009-08-11 17:57:18 +0200 (Tue, 11 Aug 2009)
New Revision: 5625

Modified:
   code/branches/libraries/cmake/BuildConfig.cmake
   code/branches/libraries/src/SpecialConfig.h.in
   code/branches/libraries/src/core/Core.cc
   code/branches/libraries/src/core/Core.h
Log:
Added plugin path that gets configured in BuildConfig.cmake and correctly set in Core.

Modified: code/branches/libraries/cmake/BuildConfig.cmake
===================================================================
--- code/branches/libraries/cmake/BuildConfig.cmake	2009-08-11 13:05:02 UTC (rev 5624)
+++ code/branches/libraries/cmake/BuildConfig.cmake	2009-08-11 15:57:18 UTC (rev 5625)
@@ -30,6 +30,7 @@
 SET(DEFAULT_RUNTIME_PATH bin)
 SET(DEFAULT_LIBRARY_PATH lib)
 SET(DEFAULT_ARCHIVE_PATH lib/static)
+SET(DEFAULT_PLUGIN_PATH  lib/plugins)
 SET(DEFAULT_DOC_PATH     doc)
 SET(DEFAULT_MEDIA_PATH   media)
 SET(DEFAULT_CONFIG_PATH  config)
@@ -39,6 +40,7 @@
 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_RUNTIME_PATH})
 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH})
 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH})
+SET(CMAKE_PLUGIN_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/${DEFAULT_PLUGIN_PATH})
 # Do not set doc and media, rather check in the two subdirectories
 # whether they concur with the DEFAULT_..._PATH
 SET(CMAKE_CONFIG_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH})
@@ -131,6 +133,7 @@
   SET(ORXONOX_RUNTIME_INSTALL_PATH ${DEFAULT_RUNTIME_PATH})
   SET(ORXONOX_LIBRARY_INSTALL_PATH ${DEFAULT_LIBRARY_PATH})
   SET(ORXONOX_ARCHIVE_INSTALL_PATH ${DEFAULT_ARCHIVE_PATH})
+  SET(ORXONOX_PLUGIN_INSTALL_PATH  ${DEFAULT_PLUGIN_PATH})
   SET(ORXONOX_DOC_INSTALL_PATH     ${DEFAULT_DOC_PATH})
   SET(ORXONOX_MEDIA_INSTALL_PATH   ${DEFAULT_MEDIA_PATH})
   SET(ORXONOX_CONFIG_INSTALL_PATH  ${DEFAULT_CONFIG_PATH})
@@ -141,6 +144,7 @@
   SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/bin)
   SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox)
   SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/orxonox/static)
+  SET(ORXONOX_PLUGIN_INSTALL_PATH  ${CMAKE_INSTALL_PREFIX}/lib/orxonox/plugins)
   SET(ORXONOX_DOC_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox)
   SET(ORXONOX_MEDIA_INSTALL_PATH   ${CMAKE_INSTALL_PREFIX}/share/orxonox)
   # These two paths are user and therefore runtime dependent --> only set relatively
@@ -151,6 +155,7 @@
   SET(ORXONOX_RUNTIME_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_RUNTIME_PATH})
   SET(ORXONOX_LIBRARY_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIBRARY_PATH})
   SET(ORXONOX_ARCHIVE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/${DEFAULT_ARCHIVE_PATH})
+  SET(ORXONOX_PLUGIN_INSTALL_PATH  ${CMAKE_INSTALL_PREFIX}/${DEFAULT_PLUGIN_PATH})
   SET(ORXONOX_DOC_INSTALL_PATH     ${CMAKE_INSTALL_PREFIX}/${DEFAULT_DOC_PATH})
   SET(ORXONOX_MEDIA_INSTALL_PATH   ${CMAKE_INSTALL_PREFIX}/${DEFAULT_MEDIA_PATH})
   # Leave empty because it is user and therefore runtime dependent

Modified: code/branches/libraries/src/SpecialConfig.h.in
===================================================================
--- code/branches/libraries/src/SpecialConfig.h.in	2009-08-11 13:05:02 UTC (rev 5624)
+++ code/branches/libraries/src/SpecialConfig.h.in	2009-08-11 15:57:18 UTC (rev 5625)
@@ -73,6 +73,7 @@
 {
     // INSTALLATION PATHS
     const char ORXONOX_RUNTIME_INSTALL_PATH[] = "@ORXONOX_RUNTIME_INSTALL_PATH@";
+    const char ORXONOX_PLUGIN_INSTALL_PATH[]  = "@ORXONOX_PLUGIN_INSTALL_PATH@";
     const char ORXONOX_MEDIA_INSTALL_PATH[]   = "@ORXONOX_MEDIA_INSTALL_PATH@";
     /* Config and Log path might be relative because they could be user and therefore runtime dependent */
     const char ORXONOX_CONFIG_INSTALL_PATH[]  = "@ORXONOX_CONFIG_INSTALL_PATH@";
@@ -81,6 +82,7 @@
     // DEVELOPMENT RUN PATHS
     const char ORXONOX_MEDIA_DEV_PATH[]       = "@CMAKE_MEDIA_OUTPUT_DIRECTORY@";
 #ifdef CMAKE_CONFIGURATION_TYPES
+    const char ORXONOX_PLUGIN_DEV_PATH[]      = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@/" BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE);
     const char ORXONOX_CONFIG_DEV_PATH[]      = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE);
     const char ORXONOX_LOG_DEV_PATH[]         = "@CMAKE_LOG_OUTPUT_DIRECTORY@/"    BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE);
 #else

Modified: code/branches/libraries/src/core/Core.cc
===================================================================
--- code/branches/libraries/src/core/Core.cc	2009-08-11 13:05:02 UTC (rev 5624)
+++ code/branches/libraries/src/core/Core.cc	2009-08-11 15:57:18 UTC (rev 5625)
@@ -240,6 +240,7 @@
         //! Path to the parent directory of the ones above if program was installed with relativ pahts
         boost::filesystem::path rootPath_;
         boost::filesystem::path executablePath_;        //!< Path to the executable
+        boost::filesystem::path pluginPath_;            //!< Path to the plugins
         boost::filesystem::path mediaPath_;             //!< Path to the media file folder
         boost::filesystem::path configPath_;            //!< Path to the config file folder
         boost::filesystem::path logPath_;               //!< Path to the log file folder
@@ -255,18 +256,16 @@
         , bDevRun_(false)
         , bGraphicsLoaded_(false)
     {
-        // Parse command line arguments first
-        CommandLine::parseCommandLine(cmdLine);
+        // Set the hard coded fixed paths
+        this->setFixedPaths();
 
-        // Determine and set the location of the executable
-        setExecutablePath();
+        // TODO: Load plugins
 
-        // Determine whether we have an installed or a binary dir run
-        // The latter occurs when simply running from the build directory
-        checkDevBuild();
+        // Parse command line arguments AFTER the plugins have been loaded (static code!)
+        CommandLine::parseCommandLine(cmdLine);
 
-        // Make sure the directories we write in exist or else make them
-        createDirectories();
+        // Set configurable paths like log, config and media
+        this->setConfigurablePaths();
 
         // create a signal handler (only active for linux)
         // This call is placed as soon as possible, but after the directories are set
@@ -506,10 +505,19 @@
 
     /**
     @brief
-        Compares the executable path with the working directory
+        Retrievs the executable path and sets all hard coded fixed path (currently only plugin path)
+        Also checks for "orxonox_dev_build.keep_me" in the executable diretory.
+        If found it means that this is not an installed run, hence we
+        don't write the logs and config files to ~/.orxonox
+    @throw
+        GeneralException
     */
-    void Core::setExecutablePath()
+    void Core::setFixedPaths()
     {
+        //////////////////////////
+        // FIND EXECUTABLE PATH //
+        //////////////////////////
+
 #ifdef ORXONOX_PLATFORM_WINDOWS
         // get executable module
         TCHAR buffer[1024];
@@ -552,29 +560,22 @@
 #ifndef ORXONOX_PLATFORM_APPLE
         configuration_->executablePath_ = configuration_->executablePath_.branch_path(); // remove executable name
 #endif
-    }
 
-    /**
-    @brief
-        Checks for "orxonox_dev_build.keep_me" in the executable diretory.
-        If found it means that this is not an installed run, hence we
-        don't write the logs and config files to ~/.orxonox
-    @throws
-        GeneralException
-    */
-    void Core::checkDevBuild()
-    {
+        /////////////////////
+        // SET PLUGIN PATH //
+        /////////////////////
+
         if (boost::filesystem::exists(configuration_->executablePath_ / "orxonox_dev_build.keep_me"))
         {
             COUT(1) << "Running from the build tree." << std::endl;
             Core::bDevRun_ = true;
-            configuration_->mediaPath_  = ORXONOX_MEDIA_DEV_PATH;
-            configuration_->configPath_ = ORXONOX_CONFIG_DEV_PATH;
-            configuration_->logPath_    = ORXONOX_LOG_DEV_PATH;
+            configuration_->pluginPath_ = ORXONOX_PLUGIN_DEV_PATH;
         }
         else
         {
+
 #ifdef INSTALL_COPYABLE // --> relative paths
+
             // Also set the root path
             boost::filesystem::path relativeExecutablePath(ORXONOX_RUNTIME_INSTALL_PATH);
             configuration_->rootPath_ = configuration_->executablePath_;
@@ -584,12 +585,44 @@
             if (configuration_->rootPath_.empty())
                 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
 
+            // Plugin path is fixed as well
+            configuration_->pluginPath_ = configuration_->rootPath_ / ORXONOX_PLUGIN_INSTALL_PATH;
+
+#else
+
+            // There is no root path, so don't set it at all
+            // Plugin path is fixed as well
+            configuration_->pluginPath_ = ORXONOX_PLUGIN_INSTALL_PATH;
+
+#endif
+        }
+    }
+
+    /**
+    @brief
+        Sets config, log and media path and creates folders if necessary.
+    @throws
+        GeneralException
+    */
+    void Core::setConfigurablePaths()
+    {
+        if (Core::isDevelopmentRun())
+        {
+            configuration_->mediaPath_  = ORXONOX_MEDIA_DEV_PATH;
+            configuration_->configPath_ = ORXONOX_CONFIG_DEV_PATH;
+            configuration_->logPath_    = ORXONOX_LOG_DEV_PATH;
+        }
+        else
+        {
+
+#ifdef INSTALL_COPYABLE // --> relative paths
+
             // Using paths relative to the install prefix, complete them
             configuration_->mediaPath_  = configuration_->rootPath_ / ORXONOX_MEDIA_INSTALL_PATH;
             configuration_->configPath_ = configuration_->rootPath_ / ORXONOX_CONFIG_INSTALL_PATH;
             configuration_->logPath_    = configuration_->rootPath_ / ORXONOX_LOG_INSTALL_PATH;
+
 #else
-            // There is no root path, so don't set it at all
 
             configuration_->mediaPath_  = ORXONOX_MEDIA_INSTALL_PATH;
 
@@ -606,7 +639,9 @@
 
             configuration_->configPath_ = userDataPath / ORXONOX_CONFIG_INSTALL_PATH;
             configuration_->logPath_    = userDataPath / ORXONOX_LOG_INSTALL_PATH;
+
 #endif
+
         }
 
         // Option to put all the config and log files in a separate folder
@@ -616,17 +651,8 @@
             configuration_->configPath_ = configuration_->configPath_ / directory;
             configuration_->logPath_    = configuration_->logPath_    / directory;
         }
-    }
 
-    /*
-    @brief
-        Checks for the log and the config directory and creates them
-        if necessary. Otherwise me might have problems opening those files.
-    @throws
-        orxonox::GeneralException if the directory to be created is a file.
-    */
-    void Core::createDirectories()
-    {
+        // Create directories to avoid problems when opening files in non existent folders.
         std::vector<std::pair<boost::filesystem::path, std::string> > directories;
         directories.push_back(std::make_pair(boost::filesystem::path(configuration_->configPath_), "config"));
         directories.push_back(std::make_pair(boost::filesystem::path(configuration_->logPath_), "log"));

Modified: code/branches/libraries/src/core/Core.h
===================================================================
--- code/branches/libraries/src/core/Core.h	2009-08-11 13:05:02 UTC (rev 5624)
+++ code/branches/libraries/src/core/Core.h	2009-08-11 15:57:18 UTC (rev 5625)
@@ -113,9 +113,8 @@
         private:
             Core(const Core&); //!< Don't use (undefined symbol)
 
-            void checkDevBuild();
-            void setExecutablePath();
-            void createDirectories();
+            void setFixedPaths();
+            void setConfigurablePaths();
             void setThreadAffinity(int limitToCPU);
 
             // Mind the order for the destruction!




More information about the Orxonox-commit mailing list