diff --git a/doc/changelog.dox b/doc/changelog.dox index a250f97db..7d4e94984 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -73,6 +73,14 @@ See also: @ref Primitives::grid3DSolid() and @ref Primitives::grid3DWireframe() primitives +@subsection changelog-latest-buildsystem Build system + +- All plugin interfaces now implement + @ref Corrade::PluginManager::AbstractPlugin::pluginSearchPaths() "pluginSearchPaths()" + for plugin directory autodetection --- you no longer need to specify the + plugin directory explicitly when loading plugins. See @ref plugins-loading + for more information. + @subsection changelog-latest-bugfixes Bug fixes - Engine startup info was not properly printed to Android log since diff --git a/src/Magnum/Audio/AbstractImporter.cpp b/src/Magnum/Audio/AbstractImporter.cpp index cfdf73106..3f8254759 100644 --- a/src/Magnum/Audio/AbstractImporter.cpp +++ b/src/Magnum/Audio/AbstractImporter.cpp @@ -29,12 +29,26 @@ #include #include +#include "Magnum/Audio/configure.h" + namespace Magnum { namespace Audio { std::string AbstractImporter::pluginInterface() { return "cz.mosra.magnum.Audio.AbstractImporter/0.1"; } +std::vector AbstractImporter::pluginSearchPaths() { + return { + #ifdef CORRADE_IS_DEBUG_BUILD + "magnum-d/audioimporters", + Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "audioimporters") + #else + "magnum/audioimporters", + Utility::Directory::join(MAGNUM_PLUGINS_DIR, "audioimporters") + #endif + }; +} + AbstractImporter::AbstractImporter() = default; AbstractImporter::AbstractImporter(PluginManager::Manager& manager): PluginManager::AbstractManagingPlugin{manager} {} diff --git a/src/Magnum/Audio/AbstractImporter.h b/src/Magnum/Audio/AbstractImporter.h index 06ad870a9..2ec9d71c9 100644 --- a/src/Magnum/Audio/AbstractImporter.h +++ b/src/Magnum/Audio/AbstractImporter.h @@ -93,6 +93,19 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi */ static std::string pluginInterface(); + /** + * @brief Plugin search paths + * + * First looks in `magnum/audioimporters/` or `magnum-d/audioimporters/` + * next to the executable and as a fallback in `magnum/audioimporters/` + * or `magnum-d/audioimporters/` in the runtime install location + * (`lib[64]/` on Unix-like systems, `bin/` on Windows). The + * system-wide plugin search directory is configurable using the + * `MAGNUM_PLUGINS_DIR` CMake variables, see @ref building for more + * information. + */ + static std::vector pluginSearchPaths(); + /** @brief Default constructor */ explicit AbstractImporter(); diff --git a/src/Magnum/Audio/CMakeLists.txt b/src/Magnum/Audio/CMakeLists.txt index 027f6bdcb..046141159 100644 --- a/src/Magnum/Audio/CMakeLists.txt +++ b/src/Magnum/Audio/CMakeLists.txt @@ -44,6 +44,9 @@ set(MagnumAudio_HEADERS visibility.h) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + if(WITH_SCENEGRAPH) list(APPEND MagnumAudio_HEADERS Listener.h diff --git a/src/Magnum/Audio/configure.h.cmake b/src/Magnum/Audio/configure.h.cmake new file mode 100644 index 000000000..5c5383224 --- /dev/null +++ b/src/Magnum/Audio/configure.h.cmake @@ -0,0 +1,28 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#define MAGNUM_PLUGINS_DIR "${MAGNUM_PLUGINS_DIR}" +#define MAGNUM_PLUGINS_DEBUG_DIR "${MAGNUM_PLUGINS_DEBUG_DIR}" + diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index 077e3d71b..2026bb514 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -32,12 +32,26 @@ #include "Magnum/Math/Functions.h" #include "Magnum/Text/GlyphCache.h" +#include "Magnum/Text/configure.h" + namespace Magnum { namespace Text { std::string AbstractFont::pluginInterface() { return "cz.mosra.magnum.Text.AbstractFont/0.2.4"; } +std::vector AbstractFont::pluginSearchPaths() { + return { + #ifdef CORRADE_IS_DEBUG_BUILD + "magnum-d/fonts", + Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "fonts") + #else + "magnum/fonts", + Utility::Directory::join(MAGNUM_PLUGINS_DIR, "fonts") + #endif + }; +} + AbstractFont::AbstractFont(): _size(0.0f) {} AbstractFont::AbstractFont(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractPlugin{manager, plugin}, _size{0.0f}, _lineHeight{0.0f} {} diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index d11b9ed28..0911a1fcf 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -109,6 +109,18 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { */ static std::string pluginInterface(); + /** + * @brief Plugin search paths + * + * First looks in `magnum/fonts/` or `magnum-d/fonts/` next to the + * executable and as a fallback in `magnum/fonts/` or `magnum-d/fonts/` + * in the runtime install location (`lib[64]/` on Unix-like systems, + * `bin/` on Windows). The system-wide plugin search directory is + * configurable using the `MAGNUM_PLUGINS_DIR` CMake variables, see + * @ref building for more information. + */ + static std::vector pluginSearchPaths(); + /** @brief Default constructor */ explicit AbstractFont(); diff --git a/src/Magnum/Text/AbstractFontConverter.cpp b/src/Magnum/Text/AbstractFontConverter.cpp index 21bc93a4b..1c5245490 100644 --- a/src/Magnum/Text/AbstractFontConverter.cpp +++ b/src/Magnum/Text/AbstractFontConverter.cpp @@ -33,6 +33,8 @@ #include "Magnum/Text/GlyphCache.h" +#include "Magnum/Text/configure.h" + namespace Magnum { namespace Text { namespace { @@ -55,6 +57,18 @@ std::string AbstractFontConverter::pluginInterface() { return "cz.mosra.magnum.Text.AbstractFontConverter/0.1.2"; } +std::vector AbstractFontConverter::pluginSearchPaths() { + return { + #ifdef CORRADE_IS_DEBUG_BUILD + "magnum-d/fontconverters", + Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "fontconverters") + #else + "magnum/fontconverters", + Utility::Directory::join(MAGNUM_PLUGINS_DIR, "fontconverters") + #endif + }; +} + AbstractFontConverter::AbstractFontConverter() = default; AbstractFontConverter::AbstractFontConverter(PluginManager::AbstractManager& manager, const std::string& plugin): PluginManager::AbstractPlugin{manager, plugin} {} diff --git a/src/Magnum/Text/AbstractFontConverter.h b/src/Magnum/Text/AbstractFontConverter.h index b439d9983..974e9dedd 100644 --- a/src/Magnum/Text/AbstractFontConverter.h +++ b/src/Magnum/Text/AbstractFontConverter.h @@ -135,6 +135,19 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl */ static std::string pluginInterface(); + /** + * @brief Plugin search paths + * + * First looks in `magnum/fontconverters/` or `magnum-d/fontconverters/` + * next to the executable and as a fallback in `magnum/fontconverters/` + * or `magnum-d/fontconverters/` in the runtime install location + * (`lib[64]/` on Unix-like systems, `bin/` on Windows). The + * system-wide plugin search directory is configurable using the + * `MAGNUM_PLUGINS_DIR` CMake variables, see @ref building for more + * information. + */ + static std::vector pluginSearchPaths(); + /** @brief Default constructor */ explicit AbstractFontConverter(); diff --git a/src/Magnum/Text/CMakeLists.txt b/src/Magnum/Text/CMakeLists.txt index 95d1fdd6d..0153086de 100644 --- a/src/Magnum/Text/CMakeLists.txt +++ b/src/Magnum/Text/CMakeLists.txt @@ -40,6 +40,9 @@ set(MagnumText_HEADERS visibility.h) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + # Text library add_library(MagnumText ${SHARED_OR_STATIC} ${MagnumText_SRCS} diff --git a/src/Magnum/Text/configure.h.cmake b/src/Magnum/Text/configure.h.cmake new file mode 100644 index 000000000..d3c9194bc --- /dev/null +++ b/src/Magnum/Text/configure.h.cmake @@ -0,0 +1,27 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#define MAGNUM_PLUGINS_DEBUG_DIR "${MAGNUM_PLUGINS_DEBUG_DIR}" +#define MAGNUM_PLUGINS_DIR "${MAGNUM_PLUGINS_DIR}" diff --git a/src/Magnum/Trade/AbstractImageConverter.cpp b/src/Magnum/Trade/AbstractImageConverter.cpp index cf781e130..8d23f9248 100644 --- a/src/Magnum/Trade/AbstractImageConverter.cpp +++ b/src/Magnum/Trade/AbstractImageConverter.cpp @@ -31,6 +31,7 @@ #include "Magnum/Image.h" #include "Magnum/Trade/ImageData.h" +#include "Magnum/Trade/configure.h" namespace Magnum { namespace Trade { @@ -38,6 +39,18 @@ std::string AbstractImageConverter::pluginInterface() { return "cz.mosra.magnum.Trade.AbstractImporter/0.3"; } +std::vector AbstractImageConverter::pluginSearchPaths() { + return { + #ifdef CORRADE_IS_DEBUG_BUILD + "magnum-d/imageconverters", + Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "imageconverters") + #else + "magnum/imageconverters", + Utility::Directory::join(MAGNUM_PLUGINS_DIR, "imageconverters") + #endif + }; +} + AbstractImageConverter::AbstractImageConverter() = default; AbstractImageConverter::AbstractImageConverter(PluginManager::Manager& manager): PluginManager::AbstractManagingPlugin{manager} {} diff --git a/src/Magnum/Trade/AbstractImageConverter.h b/src/Magnum/Trade/AbstractImageConverter.h index 3dfe440f4..06c735602 100644 --- a/src/Magnum/Trade/AbstractImageConverter.h +++ b/src/Magnum/Trade/AbstractImageConverter.h @@ -123,6 +123,19 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractManagi */ static std::string pluginInterface(); + /** + * @brief Plugin search paths + * + * First looks in `magnum/imageconverters/` or `magnum-d/imageconverters/` + * next to the executable and as a fallback in `magnum/imageconverters/` + * or `magnum-d/imageconverters/` in the runtime install location + * (`lib[64]/` on Unix-like systems, `bin/` on Windows). The + * system-wide plugin search directory is configurable using the + * `MAGNUM_PLUGINS_DIR` CMake variables, see @ref building for more + * information. + */ + static std::vector pluginSearchPaths(); + /** @brief Default constructor */ explicit AbstractImageConverter(); diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index 19db18ac7..0eb13ba41 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -40,6 +40,7 @@ #include "Magnum/Trade/ObjectData3D.h" #include "Magnum/Trade/SceneData.h" #include "Magnum/Trade/TextureData.h" +#include "Magnum/Trade/configure.h" namespace Magnum { namespace Trade { @@ -47,6 +48,18 @@ std::string AbstractImporter::pluginInterface() { return "cz.mosra.magnum.Trade.AbstractImporter/0.3"; } +std::vector AbstractImporter::pluginSearchPaths() { + return { + #ifdef CORRADE_IS_DEBUG_BUILD + "magnum-d/importers", + Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "importers") + #else + "magnum/importers", + Utility::Directory::join(MAGNUM_PLUGINS_DIR, "importers") + #endif + }; +} + AbstractImporter::AbstractImporter() = default; AbstractImporter::AbstractImporter(PluginManager::Manager& manager): PluginManager::AbstractManagingPlugin{manager} {} diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index ba9fc44c3..0fc875dab 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -113,6 +113,18 @@ class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlug */ static std::string pluginInterface(); + /** + * @brief Plugin search paths + * + * First looks in `magnum/importers/` or `magnum-d/importers/` next to + * the executable and as a fallback in `magnum/importers/` or + * `magnum-d/importers/` in the runtime install location (`lib[64]/` on + * Unix-like systems, `bin/` on Windows). The system-wide plugin search + * directory is configurable using the `MAGNUM_PLUGINS_DIR` CMake + * variables, see @ref building for more information. + */ + static std::vector pluginSearchPaths(); + /** @brief Default constructor */ explicit AbstractImporter(); diff --git a/src/Magnum/Trade/CMakeLists.txt b/src/Magnum/Trade/CMakeLists.txt index c4abf1f32..34e9a8432 100644 --- a/src/Magnum/Trade/CMakeLists.txt +++ b/src/Magnum/Trade/CMakeLists.txt @@ -41,6 +41,9 @@ set(MagnumTrade_HEADERS TextureData.h Trade.h) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + # Force IDEs to display all header files in project view add_custom_target(MagnumTrade SOURCES ${MagnumTrade_HEADERS}) set_target_properties(MagnumTrade PROPERTIES FOLDER "Magnum/Trade") diff --git a/src/Magnum/Trade/configure.h.cmake b/src/Magnum/Trade/configure.h.cmake new file mode 100644 index 000000000..b409476ed --- /dev/null +++ b/src/Magnum/Trade/configure.h.cmake @@ -0,0 +1,27 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#define MAGNUM_PLUGINS_DIR "${MAGNUM_PLUGINS_DIR}" +#define MAGNUM_PLUGINS_DEBUG_DIR "${MAGNUM_PLUGINS_DEBUG_DIR}"