]> 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 c599e269408adb38d4b38c75808d19ef71dc83a6..ea96534cdb0afb7b10bd42d9c4f4608df09e8803 100644 (file)
@@ -16,6 +16,7 @@
 #include "binarypackage.h"
 #include "builder.h"
 #include "copy.h"
+#include "datatool.h"
 #include "gnuarchiver.h"
 #include "gnuccompiler.h"
 #include "gnucxxcompiler.h"
@@ -51,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;
@@ -203,6 +205,7 @@ Builder::Builder(int argc, char **argv):
        toolchain.add_tool(new PkgConfigGenerator(*this));
        if(current_arch->get_system()=="windows")
                toolchain.add_tool(new MingwDllTool(*this, *current_arch));
+       toolchain.add_tool(new DataTool(*this));
 }
 
 Builder::~Builder()
@@ -227,7 +230,7 @@ int Builder::main()
                }
        }
 
-       load_build_file(main_file);
+       load_build_file(main_file, &cmdline_options, conf_all);
 
        if(help)
        {
@@ -333,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);
 }
 
@@ -550,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)
@@ -590,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);