conf_only(false),
build_all(false),
create_makefile(false),
- tempdir("temp")
+ tempdir("temp"),
+ top_loader(0)
{
string analyze_mode;
string work_dir;
}
}
- load_build_file(main_file);
+ load_build_file(main_file, &cmdline_options, conf_all);
if(help)
{
}
}
-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);
}
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)
{
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);
private:
class Loader: public Msp::DataFile::ObjectLoader<Builder>
{
+ private:
+ const Config::InputOptions *options;
+ bool conf_all;
+
public:
- Loader(Builder &);
+ Loader(Builder &, const Config::InputOptions * = 0, bool = false);
+ ~Loader();
+
private:
void architecture(const std::string &);
void binpkg(const std::string &);
Msp::FS::Path prefix;
Msp::FS::Path tempdir;
+ Loader *top_loader;
+
static std::string usagemsg;
static std::string helpmsg;
static void usage(const char *, const char *, bool);
- /** Loads a build file. Returns 0 on success or -1 if the file could not be
- opened. */
- void load_build_file(const Msp::FS::Path &);
+ /** 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. */
+ void load_build_file(const Msp::FS::Path &, const Config::InputOptions *opts = 0, bool all = false);
private:
/** Prepares packages and targets for building. Returns true if everything