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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.