Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 23, 2015, 11:57:53 AM (9 years ago)
Author:
landauf
Message:

added support for plugins in the buildsystem. plugins are like modules, but can be loaded/unloaded at runtime

Location:
code/branches/core7/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/CMakeLists.txt

    r10268 r10547  
    3939ADD_SUBDIRECTORY(orxonox)
    4040SET(ORXONOX_MODULES CACHE INTERNAL "")
     41SET(ORXONOX_PLUGINS CACHE INTERNAL "")
    4142ADD_SUBDIRECTORY(modules)
    4243
     
    7273  OUTPUT_NAME orxonox
    7374)
    74 # Main executable should depend on all modules
     75# Main executable should depend on all modules (but not on plugins)
    7576ADD_DEPENDENCIES(orxonox-main ${ORXONOX_MODULES})
    7677
  • code/branches/core7/src/SpecialConfig.h.in

    r8351 r10547  
    6060    const char defaultArchivePath[] = "@DEFAULT_ARCHIVE_PATH@";
    6161    const char defaultModulePath[]  = "@DEFAULT_MODULE_PATH@";
     62    const char defaultPluginPath[]  = "@DEFAULT_PLUGIN_PATH@";
    6263    const char defaultDocPath[]     = "@DEFAULT_DOC_PATH@";
    6364    const char defaultDataPath[]    = "@DEFAULT_DATA_PATH@";
     
    6970    const char dataInstallDirectory[]       = "@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIRECTORY@";
    7071    const char moduleInstallDirectory[]     = "@CMAKE_INSTALL_PREFIX@/@MODULE_INSTALL_DIRECTORY@";
     72    const char pluginInstallDirectory[]     = "@CMAKE_INSTALL_PREFIX@/@PLUGIN_INSTALL_DIRECTORY@";
    7173#endif
    7274
     
    7678#ifdef CMAKE_CONFIGURATION_TYPES
    7779    const char moduleDevDirectory[]         = "@CMAKE_MODULE_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
     80    const char pluginDevDirectory[]         = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
    7881    const char configDevDirectory[]         = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
    7982    const char logDevDirectory[]            = "@CMAKE_LOG_OUTPUT_DIRECTORY@/"    CMAKE_INTDIR;
    8083#else
    8184    const char moduleDevDirectory[]         = "@CMAKE_MODULE_OUTPUT_DIRECTORY@";
     85    const char pluginDevDirectory[]         = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@";
    8286    const char configDevDirectory[]         = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@";
    8387    const char logDevDirectory[]            = "@CMAKE_LOG_OUTPUT_DIRECTORY@";
     
    8892#endif
    8993
    90     // Module extension
     94    // Module and plugin extension
    9195    const char moduleExtension[] = "@ORXONOX_MODULE_EXTENSION@";
     96    const char pluginExtension[] = "@ORXONOX_PLUGIN_EXTENSION@";
    9297
    9398    // OGRE PLUGINS
  • code/branches/core7/src/libraries/core/ApplicationPaths.cc

    r10509 r10547  
    7474        , executablePath_(*(new bf::path()))
    7575        , modulePath_(*(new bf::path()))
     76        , pluginPath_(*(new bf::path()))
    7677        , bBuildDirectoryRun_(false)
    7778    {
     
    121122        executablePath_ = bf::path(buffer).branch_path();
    122123
    123         /////////////////////
    124         // SET MODULE PATH //
    125         /////////////////////
     124        /////////////////////////////////
     125        // SET MODULE AND PLUGIN PATHS //
     126        /////////////////////////////////
    126127
    127128        if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me"))
     
    130131            ApplicationPaths::bBuildDirectoryRun_ = true;
    131132            modulePath_ = specialConfig::moduleDevDirectory;
     133            pluginPath_ = specialConfig::pluginDevDirectory;
    132134        }
    133135        else
     
    144146                ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
    145147
    146             // Module path is fixed as well
     148            // Module and plugin paths are fixed as well
    147149            modulePath_ = rootPath_ / specialConfig::defaultModulePath;
     150            pluginPath_ = rootPath_ / specialConfig::defaultPluginPath;
    148151
    149152#else
    150153
    151154            // There is no root path, so don't set it at all
    152             // Module path is fixed as well
     155            // Module and plugin paths are fixed as well
    153156            modulePath_ = specialConfig::moduleInstallDirectory;
     157            pluginPath_ = specialConfig::pluginInstallDirectory;
    154158
    155159#endif
     
    162166        delete &executablePath_;
    163167        delete &modulePath_;
     168        delete &pluginPath_;
    164169    }
    165170
    166171    std::vector<std::string> ApplicationPaths::getModulePaths()
    167172    {
    168         std::vector<std::string> modulePaths;
     173        return this->getModuleOrPluginPaths(modulePath_, specialConfig::moduleExtension);
     174    }
     175
     176    std::vector<std::string> ApplicationPaths::getPluginPaths()
     177    {
     178        return this->getModuleOrPluginPaths(pluginPath_, specialConfig::pluginExtension);
     179    }
     180
     181    std::vector<std::string> ApplicationPaths::getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension)
     182    {
     183        std::vector<std::string> paths;
    169184
    170185        // We search for helper files with the following extension
    171         const std::string& moduleextension = specialConfig::moduleExtension;
    172         size_t moduleextensionlength = moduleextension.size();
    173 
    174         // Make sure the path exists, otherwise don't load modules
    175         if (!boost::filesystem::exists(modulePath_))
    176             return modulePaths;
    177 
    178         boost::filesystem::directory_iterator file(modulePath_);
     186        size_t extensionlength = extension.size();
     187
     188        // Make sure the path exists, otherwise don't load modules/plugins
     189        if (!boost::filesystem::exists(directory))
     190            return paths;
     191
     192        boost::filesystem::directory_iterator file(directory);
    179193        boost::filesystem::directory_iterator end;
    180194
     
    185199
    186200            // Check if the file ends with the extension in question
    187             if (filename.size() > moduleextensionlength)
     201            if (filename.size() > extensionlength)
    188202            {
    189                 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)
     203                if (filename.substr(filename.size() - extensionlength) == extension)
    190204                {
    191205                    // We've found a helper file
    192                     const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);
    193                     modulePaths.push_back(getModulePathString() + library);
     206                    const std::string& library = filename.substr(0, filename.size() - extensionlength);
     207                    paths.push_back(directory.BF_GENERIC_STRING() + '/' + library);
    194208                }
    195209            }
     
    197211        }
    198212
    199         return modulePaths;
     213        return paths;
    200214    }
    201215
     
    214228        return getInstance().modulePath_.BF_GENERIC_STRING() + '/';
    215229    }
     230
     231    /*static*/ std::string ApplicationPaths::getPluginPathString()
     232    {
     233        return getInstance().pluginPath_.BF_GENERIC_STRING() + '/';
     234    }
    216235}
  • code/branches/core7/src/libraries/core/ApplicationPaths.h

    r10509 r10547  
    4949        The ApplicationPaths class is a singleton which provides static paths of the application.
    5050    @details
    51         The class provides information about the executable, root and module path.
     51        The class provides information about the executable, root and module/plugin path.
    5252        It determines those by the use of platform specific functions.
    5353    @remarks
     
    6363            /**
    6464            @brief
    65                 Retrieves the executable path and sets all hard coded fixed paths (currently only the module path)
     65                Retrieves the executable path and sets all hard coded fixed paths (currently only the module and the plugin paths)
    6666                Also checks for "orxonox_dev_build.keep_me" in the executable directory.
    6767                If found it means that this is not an installed run, hence we
     
    8282            static const boost::filesystem::path& getModulePath()
    8383                { return getInstance().modulePath_; }
     84            //! Returns the path to the plugins as boost::filesystem::path
     85            static const boost::filesystem::path& getPluginPath()
     86                { return getInstance().pluginPath_; }
    8487
    8588            //! Returns the path to the root folder as std::string
     
    8992            //! Returns the path to the modules as std::string
    9093            static std::string getModulePathString();
     94            //! Returns the path to the plugins as std::string
     95            static std::string getPluginPathString();
    9196
    9297            //! Return true for runs in the build directory (not installed)
     
    95100            //! Returns a list with all modules declared by a *.module file in the module folder.
    96101            std::vector<std::string> getModulePaths();
     102            //! Returns a list with all plugins declared by a *.plugin file in the plugin folder.
     103            std::vector<std::string> getPluginPaths();
    97104
    98105        private:
    99106            ApplicationPaths(const ApplicationPaths&); //!< Don't use (undefined symbol)
     107
     108            std::vector<std::string> getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension);
    100109
    101110            //! Path to the parent directory of the ones above if program was installed with relative paths
     
    103112            boost::filesystem::path& executablePath_;        //!< Path to the executable
    104113            boost::filesystem::path& modulePath_;            //!< Path to the modules
     114            boost::filesystem::path& pluginPath_;            //!< Path to the plugins
    105115
    106116            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
  • code/branches/core7/src/libraries/core/Core.cc

    r10544 r10547  
    142142        orxout(internal_info) << "Executable path: " << ApplicationPaths::getExecutablePathString() << endl;
    143143        orxout(internal_info) << "Modules path:    " << ApplicationPaths::getModulePathString() << endl;
     144        orxout(internal_info) << "Plugins path:    " << ApplicationPaths::getPluginPathString() << endl;
    144145
    145146        orxout(internal_info) << "Data path:       " << ConfigurablePaths::getDataPathString() << endl;
Note: See TracChangeset for help on using the changeset viewer.