X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsourcepackage.cpp;h=f59b353d74d0c3edd5dc6e52409e61c9083fab64;hb=3e8bf5032e744b5fc3e7680af48f2abacc67addc;hp=3b107372c78935616ef98da15e2de2085c8ea765;hpb=72e0fe372278c31c980b6f79e6ead0068ee1eee7;p=builder.git diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 3b10737..f59b353 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -1,10 +1,4 @@ -/* $Id$ - -This file is part of builder -Copyright © 2007-2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include #include #include #include @@ -75,7 +69,51 @@ LibMode SourcePackage::get_library_mode() const else if(mode=="none") return DYNAMIC; else - throw Exception("Unknown library mode"); + throw runtime_error("unknown library mode"); +} + +string SourcePackage::expand_string(const string &str) const +{ + string result = str; + string::size_type dollar = 0; + unsigned n = 0; + while((dollar = result.find('$'))!=string::npos) + { + if(n>1000) + throw bad_expansion("nested too deep"); + + string::size_type end; + string var; + if(dollar+1get_requires(); - requires.insert(requires.end(), reqs.begin(), reqs.end()); - } - for(PackageList::iterator i=requires.begin(); i!=requires.end(); ++i) { BinaryPackage *bpkg = dynamic_cast(*i); @@ -123,6 +153,9 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag) } deps_cache.load(); + + for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i) + i->configure(opts, flag); } void SourcePackage::init_config() @@ -148,17 +181,7 @@ void SourcePackage::init_config() void SourcePackage::create_build_info() { - 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()); - } + build_info.update_from(builder.get_current_arch().get_build_info()); // XXX Currently, a package-specific settings will override cmdline. This might or might not be desirable. const StringList &warnings = builder.get_warnings(); @@ -175,7 +198,7 @@ void SourcePackage::create_build_info() export_binfo.libpath.push_back((builder.get_prefix()/"lib").str()); string optimize = config.get_option("optimize").value; - if(lexical_cast(optimize)) + if(!optimize.empty() && optimize!="0") { build_info.cflags.push_back("-O"+optimize); build_info.ldflags.push_back("-O"+optimize); @@ -193,7 +216,7 @@ void SourcePackage::create_build_info() for(ConditionList::iterator i=conditions.begin(); i!=conditions.end(); ++i) if(i->eval()) - build_info.add(i->get_build_info()); + build_info.update_from(i->get_build_info()); build_info.unique(); @@ -285,5 +308,5 @@ void SourcePackage::Loader::tar_file(const string &f) SourcePackage &spkg = static_cast(pkg); for(ComponentList::iterator i=spkg.components.begin(); i!=spkg.components.end(); ++i) if(i->get_type()==Component::TARBALL && i->get_name()=="@src") - const_cast(i->get_sources()).push_back(spkg.source/f); + const_cast(i->get_sources()).push_back((spkg.source/f).str()); }