X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsourcepackage.cpp;h=ef4fd5760a26fd1a90f7fb077d3256612c4b9fca;hb=762be94b71b647a18ef7d6e328280023de732aa8;hp=5d1d6837ed5e903a07dc6423d28154ad442a7cc4;hpb=654de39b62a9a58fd8e1b5a557361d628345788b;p=builder.git diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 5d1d683..ef4fd57 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -19,7 +19,7 @@ using namespace Msp; /** Creates a buildable package. */ -SourcePackage::SourcePackage(Builder &b, const string &n, const Path::Path &s): +SourcePackage::SourcePackage(Builder &b, const string &n, const Path &s): Package(b, n), source(s), config(*this), @@ -28,12 +28,12 @@ SourcePackage::SourcePackage(Builder &b, const string &n, const Path::Path &s): tar_files.push_back(source/"Build"); } -Msp::Path::Path SourcePackage::get_temp_dir() const +Msp::Path SourcePackage::get_temp_dir() const { return source/config.get_option("tempdir").value/config.get_option("profile").value; } -Msp::Path::Path SourcePackage::get_out_dir() const +Msp::Path SourcePackage::get_out_dir() const { return source/config.get_option("outdir").value; } @@ -75,36 +75,6 @@ LibMode SourcePackage::get_library_mode() const 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 ***/ /** @@ -134,12 +104,21 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag) 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) + if(Package *pkg=builder.get_package(*j)) + requires.push_back(pkg); } - 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(*i); if(bpkg && bpkg->get_need_path()) @@ -148,8 +127,8 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag) 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);*/ } /** @@ -182,11 +161,11 @@ void SourcePackage::init_config() 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(*i); if(bpkg && bpkg->get_need_path()) - config.add_option(bpkg->get_name()+"_path", "", "Path for "+bpkg->get_name()); + config.add_option(bpkg->get_name()+"_path", "/usr", "Path for "+bpkg->get_name()); } } @@ -196,12 +175,9 @@ configured when this is called. */ 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()); @@ -219,9 +195,9 @@ void SourcePackage::create_build_info() unsigned flags=get_install_flags(); if(flags&INCLUDE) - export_binfo.incpath.push_back((Path::Path(config.get_option("prefix").value)/"include").str()); + export_binfo.incpath.push_back((Path(config.get_option("prefix").value)/"include").str()); if(flags&LIB) - export_binfo.libpath.push_back((Path::Path(config.get_option("prefix").value)/"lib").str()); + export_binfo.libpath.push_back((Path(config.get_option("prefix").value)/"lib").str()); string optimize=config.get_option("optimize").value; if(lexical_cast(optimize)) @@ -243,6 +219,10 @@ void SourcePackage::create_build_info() if(lexical_cast(config.get_option("with_"+i->name).value)) build_info.cflags.push_back("-DWITH_"+toupper(i->name)); + for(ConditionList::iterator i=conditions.begin(); i!=conditions.end(); ++i) + if(i->eval()) + build_info.add(i->get_build_info()); + build_info.unique(); for(list::iterator i=components.begin(); i!=components.end(); ++i)