]> git.tdb.fi Git - builder.git/blobdiff - source/builder.cpp
Pass the option map through load_build_file and to Loader
[builder.git] / source / builder.cpp
index 07007f61bd75c82ae9f80d5e35315e29b7374b23..ea96534cdb0afb7b10bd42d9c4f4608df09e8803 100644 (file)
@@ -52,7 +52,8 @@ Builder::Builder(int argc, char **argv):
        conf_only(false),
        build_all(false),
        create_makefile(false),
-       tempdir("temp")
+       tempdir("temp"),
+       top_loader(0)
 {
        string analyze_mode;
        string work_dir;
@@ -229,7 +230,7 @@ int Builder::main()
                }
        }
 
-       load_build_file(main_file);
+       load_build_file(main_file, &cmdline_options, conf_all);
 
        if(help)
        {
@@ -335,14 +336,14 @@ void Builder::usage(const char *reason, const char *argv0, bool brief)
        }
 }
 
-void Builder::load_build_file(const FS::Path &fn)
+void Builder::load_build_file(const FS::Path &fn, const Config::InputOptions *opts, bool all)
 {
        IO::BufferedFile in(fn.str());
 
        logger.log("files", format("Reading %s", fn));
 
        DataFile::Parser parser(in, fn.str());
-       Loader loader(*this);
+       Loader loader(*this, opts, all);
        loader.load(parser);
 }
 
@@ -552,14 +553,27 @@ string Builder::usagemsg;
 string Builder::helpmsg;
 
 
-Builder::Loader::Loader(Builder &b):
-       DataFile::ObjectLoader<Builder>(b)
+Builder::Loader::Loader(Builder &b, const Config::InputOptions *o, bool a):
+       DataFile::ObjectLoader<Builder>(b),
+       options(o),
+       conf_all(a)
 {
        add("architecture", &Loader::architecture);
        add("binary_package", &Loader::binpkg);
        add("build_type", &Loader::build_type);
        add("profile", &Loader::profile);
        add("package", &Loader::package);
+
+       if(!obj.top_loader)
+               obj.top_loader = this;
+       else if(!options && obj.top_loader!=this && obj.top_loader->conf_all)
+               options = obj.top_loader->options;
+}
+
+Builder::Loader::~Loader()
+{
+       if(obj.top_loader==this)
+               obj.top_loader = 0;
 }
 
 void Builder::Loader::architecture(const string &n)
@@ -592,8 +606,8 @@ void Builder::Loader::package(const string &n)
 {
        SourcePackage *pkg = new SourcePackage(obj, n, get_source());
 
-       if(obj.conf_all || pkg==&obj.package_manager.get_main_package())
-               load_sub(*pkg, obj.cmdline_options);
+       if(options)
+               load_sub(*pkg, *options);
        else
                load_sub(*pkg);