Package *pkg=BinaryPackage::from_pkgconfig(*this, n);
packages.insert(PackageMap::value_type(n, pkg));
- if(pkg)
- new_pkgs.push_back(pkg);
return pkg;
}
return 1;
}
- while(!new_pkgs.empty())
- {
- Package *pkg=new_pkgs.front();
- new_pkgs.erase(new_pkgs.begin());
- pkg->resolve_refs();
- }
-
default_pkg->configure(cmdline_options, conf_all?2:1);
if(help)
const Config::OptionMap &options=config.get_options();
cout<<"Required packages:\n ";
- const PkgRefList &requires=default_pkg->get_requires();
- for(PkgRefList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
+ const PackageList &requires=default_pkg->get_requires();
+ for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
{
if(i!=requires.begin())
cout<<", ";
- cout<<i->get_name();
+ cout<<(*i)->get_name();
}
cout<<"\n\n";
cout<<"Package configuration:\n";
BinaryPackage *pkg=new BinaryPackage(bld, n);
load_sub(*pkg);
bld.packages.insert(PackageMap::value_type(n, pkg));
- bld.new_pkgs.push_back(pkg);
}
void Builder::Loader::profile(const string &n)
void Builder::Loader::package(const string &n)
{
SourcePackage *pkg=new SourcePackage(bld, n, src);
- load_sub(*pkg);
- bld.packages.insert(PackageMap::value_type(n, pkg));
- bld.new_pkgs.push_back(pkg);
if(!bld.default_pkg)
bld.default_pkg=pkg;
+
+ load_sub(*pkg);
+ bld.packages.insert(PackageMap::value_type(n, pkg));
}
Msp::Path::Path cwd;
PackageMap packages;
- PackageList new_pkgs;
SourcePackage *default_pkg;
TargetMap targets;
deflt(true)
{ }
-/**
-Tries to resolve all references to packages.
-*/
-void Component::resolve_refs()
-{
- for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
- i->resolve();
-}
-
/**
Prepares the build information for building.
*/
{
build_info.add(pkg.get_build_info());
- for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
- {
- if(!i->get_package())
- continue;
- //i->get_package()->create_build_info();
- build_info.add(i->get_package()->get_exported_binfo());
- }
+ for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i)
+ build_info.add((*i)->get_exported_binfo());
if(type==PROGRAM)
{
void Component::Loader::require(const string &n)
{
- comp.requires.push_back(PackageRef(comp.pkg.get_builder(), n));
+ Package *req=comp.pkg.get_builder().get_package(n);
+ if(req)
+ comp.requires.push_back(req);
}
void Component::Loader::modular()
#include <msp/path/path.h>
#include "buildinfo.h"
#include "misc.h"
-#include "packageref.h"
+#include "package.h"
class SourcePackage;
};
Component(SourcePackage &, Type, const std::string &);
- const SourcePackage &get_package() const { return pkg; }
+ const SourcePackage &get_package() const { return pkg; }
Type get_type() const { return type; }
const std::string &get_name() const { return name; }
const PathList &get_sources() const { return sources; }
bool get_install() const { return install; }
const std::string &get_install_headers() const { return install_headers; }
bool get_modular() const { return modular; }
- const PkgRefList &get_requires() const { return requires; }
+ const PackageList &get_requires() const { return requires; }
bool get_default() const { return deflt; }
- void resolve_refs();
void create_build_info();
void create_targets() const;
protected:
const Component *module_host;
bool modular;
BuildInfo build_info;
- PkgRefList requires;
+ PackageList requires;
bool deflt;
PathList collect_source_files() const;
}
}
-void Condition::resolve_refs()
-{
- for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
- i->resolve();
-}
-
bool Condition::eval()
{
const Config &conf=pkg.get_config();
void Condition::Loader::require(const string &pkg)
{
- cond.requires.push_back(PackageRef(cond.pkg.get_builder(), pkg));
+ cond.requires.push_back(pkg);
}
void Condition::Loader::build_info()
#include <msp/datafile/loader.h>
#include "buildinfo.h"
#include "misc.h"
-#include "packageref.h"
class Config;
class SourcePackage;
};
Condition(SourcePackage &, const std::string &);
- const PkgRefList &get_requires() const { return requires; }
+ const StringList &get_requires() const { return requires; }
const BuildInfo &get_build_info() const { return build_info; }
- void resolve_refs();
bool eval();
private:
SourcePackage &pkg;
StringMap expression;
- PkgRefList requires;
+ StringList requires;
BuildInfo build_info;
};
typedef std::list<Condition> ConditionList;
use_pkgconfig(true)
{ }
-/**
-Tries to resolve all references to dependency packages.
-*/
-void Package::resolve_refs()
-{
- for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
- i->resolve();
-}
-
/**
Processes configuration options that were most likely obtained from the command
line.
do_configure(opts, flag);
- for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
- i->get_package()->configure(opts, flag&2);
+ requires.sort();
+ requires.unique();
+
+ for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i)
+ (*i)->configure(opts, flag&2);
create_build_info();
void Package::Loader::require(const string &n)
{
- pkg.requires.push_back(PackageRef(pkg.builder, n));
+ Package *req=pkg.builder.get_package(n);
+ if(req)
+ pkg.requires.push_back(req);
}
#include <string>
#include <msp/datafile/loader.h>
#include "buildinfo.h"
-#include "packageref.h"
class Builder;
class Package;
typedef std::list<Package *> PackageList;
/**
-A package is a distributable piece of software. They consist of one or more
-Components and may depend on other packages. Packages also have configuration
-to determine where files are installed and which features to include.
+A package is a distributable piece of software. Package information may be
+obtained in several ways: Build files of source packages, pkg-config for binary
+packages and the builderrc file for binary packages with no pkg-config support.
*/
class Package
{
const std::string &get_name() const { return name; }
Builder &get_builder() const { return builder; }
- const PkgRefList &get_requires() const { return requires; }
+ const PackageList &get_requires() const { return requires; }
const BuildInfo &get_exported_binfo() const { return export_binfo; }
/// Indicates whether or not this package supports pkg-config
bool get_use_pkgconfig() const { return use_pkgconfig; }
- virtual void resolve_refs();
void configure(const StringMap &, unsigned);
virtual ~Package() { }
protected:
std::string name;
- PkgRefList requires;
+ PackageList requires;
BuildInfo export_binfo;
bool conf_done;
+++ /dev/null
-/* $Id$
-
-This file is part of builder
-Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include "builder.h"
-#include "package.h"
-#include "packageref.h"
-
-using namespace std;
-
-PackageRef::PackageRef(Builder &b, const string &n):
- builder(b),
- name(n),
- package(0)
-{ }
-
-/**
-Tries to get the package from Builder if we don't have it already.
-
-@return The package pointer (0 if the package was not found)
-*/
-Package *PackageRef::resolve()
-{
- if(!package)
- package=builder.get_package(name);
- return package;
-}
+++ /dev/null
-/* $Id$
-
-This file is part of builder
-Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#ifndef PACKAGEREF_H_
-#define PACKAGEREF_H_
-
-#include <list>
-#include <string>
-
-class Builder;
-class Package;
-
-/**
-A proxy class that stores a package name and possibly a pointer to the package.
-*/
-class PackageRef
-{
-public:
- PackageRef(Builder &, const std::string &);
- const std::string &get_name() const { return name; }
- Package *get_package() const { return package; }
- Package *resolve();
-private:
- Builder &builder;
- std::string name;
- Package *package;
-};
-typedef std::list<PackageRef> PkgRefList;
-
-#endif
out<<"Version: "<<spkg.get_version()<<'\n';
out<<"Requires:";
- const PkgRefList &reqs=spkg.get_requires();
- for(PkgRefList::const_iterator i=reqs.begin(); i!=reqs.end(); ++i)
- if(i->get_package()->get_use_pkgconfig())
- out<<' '<<i->get_name();
+ const PackageList &reqs=spkg.get_requires();
+ for(PackageList::const_iterator i=reqs.begin(); i!=reqs.end(); ++i)
+ if((*i)->get_use_pkgconfig())
+ out<<' '<<(*i)->get_name();
out<<'\n';
const BuildInfo &binfo=spkg.get_exported_binfo();
throw Exception("Unknown library mode");
}
-/**
-Tries to resolve all references to dependency packages.
-*/
-void SourcePackage::resolve_refs()
-{
- Package::resolve_refs();
-
- for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
- if(i->get_package())
- all_reqs.push_back(i->get_package());
-
- for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
- {
- i->resolve_refs();
- const PkgRefList &creqs=i->get_requires();
- for(PkgRefList::const_iterator j=creqs.begin(); j!=creqs.end(); ++j)
- if(j->get_package())
- all_reqs.push_back(j->get_package());
- }
-
- for(ConditionList::iterator i=conditions.begin(); i!=conditions.end(); ++i)
- {
- i->resolve_refs();
- const PkgRefList &creqs=i->get_requires();
- for(PkgRefList::const_iterator j=creqs.begin(); j!=creqs.end(); ++j)
- if(j->get_package())
- all_reqs.push_back(j->get_package());
- }
-}
-
/*** private ***/
/**
for(ConditionList::iterator i=conditions.begin(); i!=conditions.end(); ++i)
if(i->eval())
{
- const PkgRefList &reqs=i->get_requires();
- requires.insert(requires.end(), reqs.begin(), reqs.end());
- build_info.add(i->get_build_info());
+ const StringList &reqs=i->get_requires();
+ for(StringList::const_iterator j=reqs.begin(); j!=reqs.end(); ++j)
+ requires.push_back(builder.get_package(*j));
}
- for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+ 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);
if(bpkg && bpkg->get_need_path())
deps_cache.load();
- for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
- (*i)->configure(opts, flag&2);
+ /*for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+ (*i)->configure(opts, flag&2);*/
}
/**
for(FeatureList::iterator i=features.begin(); i!=features.end(); ++i)
config.add_option("with_"+i->name, "0", i->descr);
- for(PackageList::const_iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
+ for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
{
BinaryPackage *bpkg=dynamic_cast<BinaryPackage *>(*i);
if(bpkg && bpkg->get_need_path())
*/
void SourcePackage::create_build_info()
{
- for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
+ for(PackageList::iterator i=base_reqs.begin(); i!=base_reqs.end(); ++i)
{
- Package *pkg=i->get_package();
- if(!pkg)
- continue;
- const BuildInfo &ebi=pkg->get_exported_binfo();
+ 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());
#include "dependencycache.h"
#include "feature.h"
#include "package.h"
-#include "packageref.h"
class Builder;
LibMode get_library_mode() const;
const PathList &get_tar_files() const { return tar_files; }
DependencyCache &get_deps_cache() const { return deps_cache; }
- virtual void resolve_refs();
private:
std::string version;
std::string description;
Msp::Path::Path source;
- PackageList all_reqs;
+ PackageList base_reqs;
FeatureList features;
BuildInfo build_info;
ConditionList conditions;