}
}
- main_pkg->configure(cmdline_options, conf_all?2:1);
-
if(help)
{
usage(0, "builder", false);
list<string> package_details;
for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
{
- if(!i->second || !i->second->is_configured())
+ if(!i->second || !i->second->is_prepared())
continue;
string line = i->second->get_name();
Target *tarballs = new VirtualTarget(*this, "tarballs");
world->add_depend(*tarballs);
- const PackageManager::PackageMap &packages = package_manager.get_packages();
- for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
- if(i->second && i->second->is_configured())
- i->second->create_targets();
+ main_pkg->prepare();
// Make the cmdline target depend on all targets mentioned on the command line
Target *cmdline = new VirtualTarget(*this, "cmdline");
if(!dry_run)
{
+ const PackageManager::PackageMap &packages = package_manager.get_packages();
for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
i->second->save_caches();
}
deflt(true)
{ }
-void Component::configure(const StringMap &opts, unsigned flag)
+void Component::prepare()
{
for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
- (*i)->configure(opts, flag&2);
+ (*i)->prepare();
}
void Component::create_build_info()
bool is_default() const { return deflt; }
const InstallMap &get_install_map() const { return install_map; }
- void configure(const StringMap &, unsigned);
+ void prepare();
/** Prepares the build information for building. Pulls build info from the
parent and dependency packages, and adds any component-specific flags. */
return options.count(name);
}
-bool Config::update(const StringMap &opts)
-{
- bool changed_now = false;
- for(StringMap::const_iterator i=opts.begin(); i!=opts.end(); ++i)
- {
- if(set_option(i->first, i->second) && i->first!="profile")
- changed_now = true;
- }
-
- if(changed_now)
- {
- mtime = Time::now();
- changed = true;
- }
-
- return changed_now;
-}
-
void Config::save() const
{
if(!changed)
/** Checks whether an option exists. */
bool is_option(const std::string &) const;
- /** Processes options from the given raw option map. Nonexistent options
- are ignored. If any options were changed, the mtime of the configuration is
- updated to the current time. Return value indicates whether any options
- were changed. */
- bool update(const StringMap &);
-
void save() const;
bool set_option(const std::string &, const std::string &);
void load();
Package::Package(Builder &b, const string &n):
builder(b),
name(n),
- conf_done(false),
+ prepared(false),
use_pkgconfig(true)
{
builder.get_package_manager().add_package(this);
}
-void Package::configure(const StringMap &opts, unsigned flag)
+void Package::prepare()
{
- if(conf_done)
+ if(prepared)
return;
- builder.get_logger().log("configure", format("Configuring %s", name));
-
- do_configure(opts, flag);
-
- requires.sort();
- requires.unique();
-
- for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i)
- (*i)->configure(opts, flag&2);
+ for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
+ (*i)->prepare();
create_build_info();
-
- conf_done = true;
+ create_targets();
+ prepared = true;
}
#include <string>
#include <msp/datafile/objectloader.h>
#include "buildinfo.h"
+#include "config.h"
class Builder;
class Package;
PackageList requires;
BuildInfo export_binfo;
- bool conf_done;
+ bool prepared;
bool use_pkgconfig;
/// Indicates whether or not this package supports pkg-config
bool get_use_pkgconfig() const { return use_pkgconfig; }
- /** Processes configuration options that were most likely obtained from the
- command line. */
- void configure(const StringMap &, unsigned);
+ /** Prepares the package for building. Recursively prepares all required
+ packages, populates build info and creates targets. */
+ void prepare();
- bool is_configured() const { return conf_done; }
+ bool is_prepared() const { return prepared; }
protected:
- virtual void do_configure(const StringMap &, unsigned) { }
virtual void create_build_info() { }
-public:
virtual void create_targets() { }
+public:
virtual void save_caches() { }
};
return source/arch.get_name()/detail;
}
-void SourcePackage::do_configure(const StringMap &opts, unsigned flag)
-{
- init_config();
-
- config.load();
-
- if(flag && config.update(opts))
- builder.get_logger().log("configure", format("Configuration of %s changed", name));
-
- deps_cache.load();
-
- for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
- i->configure(opts, flag);
-}
-
-void SourcePackage::init_config()
-{
-}
-
void SourcePackage::create_build_info()
{
if(build_type)
for(list<Component>::iterator i=components.begin(); i!=components.end(); ++i)
{
+ i->prepare();
i->create_build_info();
if(i->get_type()==Component::LIBRARY)
export_binfo.libs.push_back(i->get_name());
void SourcePackage::create_targets()
{
+ deps_cache.load();
+
bool pc_needed = false;
for(ComponentList::const_iterator i=components.begin(); i!=components.end(); ++i)
{
DependencyCache &get_deps_cache() const { return deps_cache; }
private:
- virtual void do_configure(const StringMap &, unsigned);
-
- /** Initializes configuration options. */
- void init_config();
-
/** Fills in build info based on configuration. All required packages must be
configured when this is called. */
virtual void create_build_info();