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.build_type = &i->second;
}
-void Builder::Loader::profile(const string &)
-{
- IO::print("Profiles are deprecated\n");
-}
-
void Builder::Loader::package(const string &n)
{
SourcePackage *pkg = new SourcePackage(obj, n, get_source());
void architecture(const std::string &);
void binpkg(const std::string &);
void build_type(const std::string &);
- void profile(const std::string &);
void package(const std::string &);
};
+++ /dev/null
-#include <msp/strings/utils.h>
-#include "builder.h"
-#include "condition.h"
-#include "sourcepackage.h"
-
-using namespace std;
-using namespace Msp;
-
-Condition::Condition(SourcePackage &p, const string &expr):
- pkg(p)
-{
- vector<string> parts = split(expr);
-
- for(vector<string>::iterator i=parts.begin(); i!=parts.end(); ++i)
- {
- if(*i=="and")
- continue;
-
- string::size_type token = i->find_first_of("=!");
- if(token==string::npos)
- expression.insert(Expression::value_type(*i, "="));
- else if(token==0 && (*i)[0]=='!')
- expression.insert(Expression::value_type(i->substr(1), "!"));
- else
- expression.insert(Expression::value_type(i->substr(0, token), i->substr(token)));
- }
-}
-
-bool Condition::eval()
-{
- const Config &conf = pkg.get_config();
-
- bool result = true;
- for(Expression::iterator i=expression.begin(); i!=expression.end(); ++i)
- {
- bool neg = (i->second[0]=='!');
- unsigned start = 1;
- if(i->second[1]=='=')
- ++start;
- string value = i->second.substr(start);
-
- bool match = false;
- if(conf.is_option(i->first))
- {
- if(value.empty())
- match = lexical_cast<bool>(conf.get_option(i->first).value);
- else
- match = (conf.get_option(i->first).value==value);
- }
- else if(i->first=="arch")
- match = pkg.get_builder().get_current_arch().match_name(value);
-
- if(match==neg)
- result = false;
- }
-
- return result;
-}
-
-
-Condition::Loader::Loader(Condition &c):
- DataFile::ObjectLoader<Condition>(c)
-{
- add("require", &Loader::require);
- add("build_info", &Loader::build_info);
-}
-
-void Condition::Loader::require(const string &pkg)
-{
- obj.requires.push_back(pkg);
-}
-
-void Condition::Loader::build_info()
-{
- load_sub(obj.build_info);
-}
+++ /dev/null
-#ifndef CONDITION_H_
-#define CONDITION_H_
-
-#include <msp/datafile/loader.h>
-#include "buildinfo.h"
-
-class Config;
-class SourcePackage;
-
-class Condition
-{
-public:
- class Loader: public Msp::DataFile::ObjectLoader<Condition>
- {
- public:
- Loader(Condition &);
- private:
- void require(const std::string &);
- void build_info();
- };
-
- typedef std::list<std::string> RequireList;
-
-private:
- typedef std::map<std::string, std::string> Expression;
-
- SourcePackage &pkg;
- Expression expression;
- RequireList requires;
- BuildInfo build_info;
-
-public:
- Condition(SourcePackage &, const std::string &);
- const RequireList &get_requires() const { return requires; }
- const BuildInfo &get_build_info() const { return build_info; }
- bool eval();
-};
-
-#endif
add("description", &SourcePackage::description);
add("build_info", &Loader::build_info);
add("feature", &Loader::feature);
- add("if", &Loader::condition);
add("if_feature", &Loader::if_feature);
add("program", &Loader::component<Component::PROGRAM>);
add("library", &Loader::component<Component::LIBRARY>);
add("module", &Loader::component<Component::MODULE>);
- add("headers", &Loader::headers);
add("install", &Loader::component<Component::INSTALL>);
add("interface_version", &Loader::interface_version);
add("datapack", &Loader::component<Component::DATAPACK>);
add("source_tarball", &Loader::source_tarball);
add("tarball", &Loader::tarball);
- add("tar_file", &Loader::tar_file);
add("version", &Loader::version);
}
void SourcePackage::Loader::finish()
{
obj.components.sort(component_sort);
-
- for(map<string, string>::const_iterator i=install_map.begin(); i!=install_map.end(); ++i)
- {
- for(ComponentList::iterator j=obj.components.begin(); j!=obj.components.end(); ++j)
- {
- const Component::SourceList &sources = j->get_sources();
- for(Component::SourceList::const_iterator k=sources.begin(); k!=sources.end(); ++k)
- {
- string k_str = k->str();
- if(!i->first.compare(0, k_str.size(), k_str))
- {
- const_cast<InstallMap &>(j->get_install_map()).add_mapping(obj.source_dir/i->first, i->second);
- }
- }
- }
- }
}
void SourcePackage::Loader::feature(const string &n, const string &d)
}
}
-void SourcePackage::Loader::condition(const string &c)
-{
- IO::print("%s: Note: Old-style conditions are deprecated\n", get_source());
- Condition cond(obj, c);
- if(cond.eval())
- load_sub_with(*this);
-}
-
template<Component::Type t>
void SourcePackage::Loader::component(const string &n)
{
load_sub(obj.build_info);
}
-void SourcePackage::Loader::headers(const string &n)
-{
- IO::print("%s: Note: headers components are deprecated\n", get_source());
- Component comp(obj, Component::LIBRARY, n);
- load_sub(comp);
- const Component::SourceList &sources = comp.get_sources();
- for(Component::SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
- install_map[i->str()] = "include/"+comp.get_name();
-}
-
void SourcePackage::Loader::if_feature(const string &cond)
{
bool match = obj.match_feature(cond);
void SourcePackage::Loader::tarball(const string &n)
{
- if(n=="@src")
- {
- IO::print("%s: Note: Use source_tarball instead of tarball \"@src\"\n", get_source());
- load_sub(*obj.source_tarball);
- }
- else
- {
- Component trbl(obj, Component::TARBALL, n);
- load_sub(trbl);
- }
-}
-
-void SourcePackage::Loader::tar_file(const string &f)
-{
- IO::print("%s: Note: tar_file is deprecated\n", get_source());
- for(ComponentList::iterator i=obj.components.begin(); i!=obj.components.end(); ++i)
- if(i->get_type()==Component::TARBALL && i->get_name()=="@src")
- const_cast<Component::SourceList &>(i->get_sources()).push_back((obj.source_dir/f).str());
+ Component trbl(obj, Component::TARBALL, n);
+ load_sub(trbl);
}
void SourcePackage::Loader::version(const string &v)
#include "buildinfo.h"
#include "cache.h"
#include "component.h"
-#include "condition.h"
#include "config.h"
#include "feature.h"
#include "package.h"
{
private:
const Config::InputOptions *options;
- std::map<std::string, std::string> install_map;
public:
Loader(SourcePackage &);
void feature(const std::string &, const std::string &);
template<Component::Type>
void component(const std::string &);
- void condition(const std::string &);
void build_info();
- void headers(const std::string &);
void if_feature(const std::string &);
void interface_version(const std::string &);
void source_tarball();
void tarball(const std::string &);
- void tar_file(const std::string &);
void version(const std::string &);
};