+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
#include <msp/strings/lexicalcast.h>
#include <msp/strings/utils.h>
#include "builder.h"
conf_done(false),
use_pkgconfig(true),
need_path(false)
-{ }
+{
+ tar_files.push_back(source/"Build");
+
+ if(builder.get_verbose()>=4)
+ cout<<"Created buildable package "<<n<<" at "<<s<<'\n';
+}
/**
Sets the path where the package files were installed. This is only useful for
Package *pkg=i->resolve();
if(pkg) all_reqs.push_back(pkg);
}
+
for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
{
i->resolve_refs();
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());
+ }
}
/**
config.select_profile(prof->second);
else
config.select_last_profile();
-
+
if(flag && config.update(opts))
{
if(builder.get_verbose()>=2)
config.finish();
+ 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());
+ }
+
for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i)
{
if((*i)->get_need_path())
argv.push_back("--libs");
argv.push_back(name);
vector<string> info=split(run_command(argv));
-
+
bool need_path=false;
bool use_pkgconfig=true;
if(info.empty())
{
use_pkgconfig=false;
-
+
//XXX Put these in an external file
if(name=="opengl")
info.push_back("-lGL");
need_path=true;
else if(name=="devil")
info.push_back("-lIL");
+ else if(name=="Xlib")
+ info.push_back("-lX11");
else
return 0;
}
-
+
Package *pkg=new Package(b, name, info);
pkg->need_path=need_path;
pkg->use_pkgconfig=use_pkgconfig;
else if(!i->compare(0, 2, "-l"))
export_binfo.libs.push_back(i->substr(2));
}
+
+ if(builder.get_verbose()>=4)
+ {
+ cout<<"Created non-buildable package "<<name<<" with";
+ for(vector<string>::const_iterator i=info.begin(); i!=info.end(); ++i)
+ cout<<' '<<*i;
+ cout<<'\n';
+ }
}
/**
if(flags&DATA)
config.add_option("includedir", "$prefix/share", "Data installation directory");*/
- for(PkgRefList::iterator i=requires.begin(); i!=requires.end(); ++i)
- if(i->get_package() && i->get_package()->get_need_path())
- config.add_option(i->get_name()+"_path", "", "Path for "+i->get_name());
+ 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)
+ if((*i)->get_need_path())
+ config.add_option((*i)->get_name()+"_path", "", "Path for "+(*i)->get_name());
}
/**
Package *pkg=i->get_package();
if(!pkg)
continue;
- build_info.add(pkg->get_exported_binfo());
- //XXX We probably really only want to pass cflags and defines through
- export_binfo.add(pkg->get_exported_binfo());
+ const BuildInfo &ebi=pkg->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());
}
-
+
build_info.cflags.push_back("-Wall");
build_info.cflags.push_back("-Wshadow");
build_info.cflags.push_back("-Wextra");
build_info.defines.push_back("DEBUG");
}
+ for(FeatureList::iterator i=features.begin(); i!=features.end(); ++i)
+ if(lexical_cast<bool>(config.get_option("with_"+i->name).value))
+ build_info.cflags.push_back("-DWITH_"+toupper(i->name));
+
build_info.unique();
for(list<Component>::iterator i=components.begin(); i!=components.end(); ++i)
add("version", &Package::version);
add("description", &Package::description);
add("require", &Loader::require);
+ add("feature", &Loader::feature);
+ add("if", &Loader::condition);
add("program", &Loader::program);
add("library", &Loader::library);
add("module", &Loader::module);
add("headers", &Loader::headers);
add("build_info", &Loader::build_info);
+ add("tar_file", &Loader::tar_file);
}
void Package::Loader::require(const string &n)
pkg.requires.push_back(PackageRef(pkg.builder, n));
}
+void Package::Loader::feature(const string &n, const string &d)
+{
+ pkg.features.push_back(Feature(n, d));
+}
+
+void Package::Loader::condition(const string &c)
+{
+ Condition cond(pkg, c);
+ load_sub(cond);
+ pkg.conditions.push_back(cond);
+}
+
void Package::Loader::program(const string &n)
{
Component prog(pkg, Component::PROGRAM, n);
{
load_sub(pkg.build_info);
}
+
+void Package::Loader::tar_file(const string &f)
+{
+ pkg.tar_files.push_back(pkg.source/f);
+}