X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flib%2Fbuilder.h;h=8ab0f941f8c482774d38d1f8aecd4b86b1234d43;hb=f4de41c810319d3ecc8bb5084de06a953037b7b7;hp=0455637c9ca96808de0ebff64e3c4519dd0b5ac9;hpb=d5535ad0823221b326b47f4549bd546118e72599;p=builder.git diff --git a/source/lib/builder.h b/source/lib/builder.h index 0455637..8ab0f94 100644 --- a/source/lib/builder.h +++ b/source/lib/builder.h @@ -10,22 +10,22 @@ #include "buildgraph.h" #include "buildtype.h" #include "config.h" +#include "libbuilder_api.h" #include "logger.h" #include "packagemanager.h" +#include "sourcepackage.h" #include "target.h" #include "toolchain.h" #include "virtualfilesystem.h" -class FileTarget; class Package; class Plugin; -class SourcePackage; /** This class ties everything else together. It also contains code for loading build files and supervising the build process. */ -class Builder +class LIBBUILDER_API Builder { private: class Loader: public Msp::DataFile::ObjectLoader @@ -54,11 +54,13 @@ private: LoadedPlugin() = default; LoadedPlugin(LoadedPlugin &&); + LoadedPlugin &operator=(LoadedPlugin &&); ~LoadedPlugin(); }; std::vector plugins; PackageManager package_manager; + SourcePackage::ComponentRegistry component_registry; Architecture native_arch; Architecture *current_arch = 0; @@ -81,7 +83,16 @@ public: ~Builder(); void load_plugins(); + + template + void load_plugins(); + +private: + void add_plugins(std::vector &); + +public: PackageManager &get_package_manager() { return package_manager; } + SourcePackage::ComponentRegistry &get_component_registry() { return component_registry; } template void call_plugins(F) const; @@ -109,7 +120,10 @@ public: const Logger &get_logger() const { return *logger; } std::vector collect_problems() const; +private: + void collect_broken_packages(const Package &, std::vector &) const; +public: /** Loads a build file. If opts is not null, it is used to configure any packages loaded from this file. If all is true, external packages are also configured. */ @@ -128,6 +142,20 @@ public: int do_create_makefile(); }; +template +void Builder::load_plugins() +{ + Plugin *raw_plugins[] = { new T(*this)... }; + std::vector pending_plugins; + for(Plugin *p: raw_plugins) + { + LoadedPlugin plugin; + plugin.plugin = p; + pending_plugins.emplace_back(std::move(plugin)); + } + add_plugins(pending_plugins); +} + template void Builder::call_plugins(F func) const {