X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Flib%2Fsourcepackage.h;h=c311c210e86431f06fffd6a2932ffa49604deaea;hb=b4781796aa997368f46b87b73a907bcab955ca3d;hp=d37ecf4a8a7e356d3d1b45f4566df605c8b77093;hpb=36078a036ecf771ce0f020338f7e812c08a37479;p=builder.git diff --git a/source/lib/sourcepackage.h b/source/lib/sourcepackage.h index d37ecf4..c311c21 100644 --- a/source/lib/sourcepackage.h +++ b/source/lib/sourcepackage.h @@ -1,18 +1,20 @@ #ifndef SOURCEPACKAGE_H_ #define SOURCEPACKAGE_H_ +#include #include #include +#include #include "buildinfo.h" #include "cache.h" #include "component.h" #include "conditionalloader.h" #include "config.h" #include "feature.h" +#include "libbuilder_api.h" #include "package.h" #include "toolchain.h" -class Builder; class BuildType; class FileTarget; class SourceArchiveComponent; @@ -20,12 +22,20 @@ class SourceArchiveComponent; /** A package that can be built by Builder. */ -class SourcePackage: public Package +class LIBBUILDER_API SourcePackage: public Package { public: class Loader: public Msp::DataFile::DerivedObjectLoader, public FeatureConditional { + friend class SourcePackage; + private: + template + struct AddComponent + { + void operator()(const std::string &n, Loader &l) const { l.add(n, &Loader::component); } + }; + const Config::InputOptions *options; public: @@ -33,6 +43,7 @@ public: private: void finish() override; + void exported(); void feature(const std::string &, const std::string &); template void component(Args..., const std::string &); @@ -44,7 +55,18 @@ public: void version(const std::string &); }; + using ComponentRegistry = Msp::TypeRegistry; + private: + class ExportLoader: public Msp::DataFile::ObjectLoader + { + public: + ExportLoader(SourcePackage &); + + private: + void build_info(); + }; + std::string version; std::string interface_version; std::string description; @@ -72,6 +94,7 @@ public: const Msp::FS::Path &get_source_directory() const { return source_dir; } Msp::FS::Path get_temp_directory() const; Msp::FS::Path get_output_directory() const; + Msp::FS::Path get_staging_directory() const; const Toolchain &get_toolchain() const { return local_tools; } const Component &get_component(const std::string &) const; @@ -88,4 +111,15 @@ private: void save_caches() override; }; + +template +void SourcePackage::Loader::component(Args... args, const std::string &n) +{ + if(std::any_of(obj.components.begin(), obj.components.end(), [&n](const Component *c){ return c->get_name()==n; })) + throw Msp::key_error(n); + C *comp = new C(obj, n, args...); + load_sub(*comp); + obj.components.push_back(comp); +} + #endif