return 0;
}
- if(!conf_only && create_targets())
- return 1;
-
- PackageList all_reqs = main_pkg->collect_requires();
-
if(conf_only)
return 0;
+ if(create_targets())
+ return 1;
+
if(verbose>=2)
{
IO::print("Building on %s, for %s%s\n", native_arch.get_name(),
current_arch->get_name(), (current_arch->is_native() ? " (native)" : ""));
IO::print("Prefix is %s\n", prefix);
}
+
if(verbose>=1)
- IO::print("%d active packages, %d targets\n", all_reqs.size(), targets.size());
+ {
+ unsigned n_packages = 0;
+ for(PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
+ if(i->second->is_configured())
+ ++n_packages;
+ IO::print("%d active packages, %d targets\n", n_packages, targets.size());
+ }
+
if(verbose>=2)
{
- for(PackageList::const_iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+ for(PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
{
- IO::print(" %s", (*i)->get_name());
- if(dynamic_cast<SourcePackage *>(*i))
+ if(!i->second->is_configured())
+ continue;
+
+ IO::print(" %s", i->second->get_name());
+ if(dynamic_cast<SourcePackage *>(i->second))
IO::print("*");
unsigned count = 0;
unsigned to_be_built = 0;
for(TargetMap::iterator j=targets.begin(); j!=targets.end(); ++j)
- if(j->second->get_package()==*i)
+ if(j->second->get_package()==i->second)
{
++count;
if(j->second->get_rebuild())
Target *tarballs = new VirtualTarget(*this, "tarballs");
world->add_depend(tarballs);
- PackageList all_reqs = main_pkg->collect_requires();
- for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+ for(PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
{
- SourcePackage *spkg = dynamic_cast<SourcePackage *>(*i);
+ if(!i->second->is_configured())
+ continue;
+
+ SourcePackage *spkg = dynamic_cast<SourcePackage *>(i->second);
if(!spkg)
continue;
Distributed under the LGPL
*/
+#include <algorithm>
#include <msp/core/except.h>
#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
void Component::create_build_info()
{
- build_info.add(pkg.get_build_info());
+ const PackageList &pkg_reqs = pkg.get_requires();
+ PackageList direct_reqs = requires;
+ direct_reqs.insert(direct_reqs.end(), pkg_reqs.begin(), pkg_reqs.end());
+
+ PackageList all_reqs = direct_reqs;
+ for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+ {
+ if(find(direct_reqs.begin(), direct_reqs.end(), *i)!=direct_reqs.end())
+ build_info.add((*i)->get_exported_binfo());
+ else
+ {
+ const BuildInfo &ebi = (*i)->get_exported_binfo();
+ build_info.cflags.insert(build_info.cflags.end(), ebi.cflags.begin(), ebi.cflags.end());
+ build_info.incpath.insert(build_info.incpath.end(), ebi.incpath.begin(), ebi.incpath.end());
+ build_info.defines.insert(build_info.defines.end(), ebi.defines.begin(), ebi.defines.end());
+ }
- for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i)
- build_info.add((*i)->get_exported_binfo());
+ const PackageList &reqs = (*i)->get_requires();
+ for(PackageList::const_iterator j=reqs.begin(); j!=reqs.end(); ++j)
+ if(find(all_reqs.begin(), all_reqs.end(), *j)==all_reqs.end())
+ all_reqs.push_back(*j);
+ }
+
+ build_info.add(pkg.get_build_info());
for(StringList::iterator i=build_info.incpath.begin(); i!=build_info.incpath.end(); ++i)
*i = (pkg.get_source() / *i).str();
if(pkg.get_library_mode()!=DYNAMIC)
{
- // XXX This may pull in some unnecessary libpaths too. More thought required.
- PackageList reqs = pkg.collect_requires();
- for(PackageList::iterator i=reqs.begin(); i!=reqs.end(); ++i)
+ for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
{
const BuildInfo &ebi = (*i)->get_exported_binfo();
build_info.libpath.insert(build_info.libpath.end(), ebi.libpath.begin(), ebi.libpath.end());
use_pkgconfig(true)
{ }
-PackageList Package::collect_requires()
-{
- PackageList result;
- result.push_back(this);
- for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
- {
- PackageList r = (*i)->collect_requires();
- result.splice(result.end(), r);
- }
-
- result.sort();
- result.unique();
-
- return result;
-}
-
void Package::configure(const StringMap &opts, unsigned flag)
{
if(conf_done)
Builder &get_builder() const { return builder; }
const PackageList &get_requires() const { return requires; }
- /** Returns a list of all directly and indirectly required packages,
- including the package itself. */
- PackageList collect_requires();
-
const BuildInfo &get_exported_binfo() const { return export_binfo; }
/// Indicates whether or not this package supports pkg-config
/** Processes configuration options that were most likely obtained from the
command line. */
void configure(const StringMap &, unsigned);
+
+ bool is_configured() const { return conf_done; }
protected:
virtual void do_configure(const StringMap &, unsigned) { }
virtual void create_build_info() { }
requires.push_back(pkg);
}
- base_reqs = requires;
-
- for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
- {
- const PackageList &reqs = i->get_requires();
- requires.insert(requires.end(), reqs.begin(), reqs.end());
- }
-
for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i)
{
BinaryPackage *bpkg = dynamic_cast<BinaryPackage *>(*i);
}
deps_cache.load();
+
+ for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
+ {
+ const PackageList &reqs = i->get_requires();
+ for(PackageList::const_iterator j=reqs.begin(); j!=reqs.end(); ++j)
+ (*j)->configure(opts, flag&2);
+ }
}
void SourcePackage::init_config()
{
build_info.add(builder.get_current_arch().get_build_info());
- for(PackageList::iterator i=base_reqs.begin(); i!=base_reqs.end(); ++i)
- {
- const BuildInfo &ebi = (*i)->get_exported_binfo();
- build_info.add(ebi);
-
- export_binfo.cflags.insert(export_binfo.cflags.end(), ebi.cflags.begin(), ebi.cflags.end());
- export_binfo.incpath.insert(export_binfo.incpath.end(), ebi.incpath.begin(), ebi.incpath.end());
- export_binfo.defines.insert(export_binfo.defines.end(), ebi.defines.begin(), ebi.defines.end());
- }
-
// XXX Currently, a package-specific settings will override cmdline. This might or might not be desirable.
const StringList &warnings = builder.get_warnings();
build_info.warnings.insert(build_info.warnings.begin(), warnings.begin(), warnings.end());
std::string description;
Msp::FS::Path source;
- PackageList base_reqs;
FeatureList features;
BuildInfo build_info;
ConditionList conditions;
ComponentList components;
Config config;
- bool conf_done;
mutable DependencyCache deps_cache;
public: