From: Mikko Rasa Date: Sun, 8 Jul 2012 14:13:42 +0000 (+0300) Subject: Use Path objects to store include and library paths X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=ca18323d45d67243773b03668e79c715aa976441;p=builder.git Use Path objects to store include and library paths --- diff --git a/source/binary.cpp b/source/binary.cpp index 421697d..957d233 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -41,9 +41,9 @@ void Binary::find_depends() const Component *c = queue.front(); queue.erase(queue.begin()); - const StringList &libpath = c->get_build_info().libpath; + const BuildInfo::PathList &libpath = c->get_build_info().libpath; - const list &libs = c->get_build_info().libs; + const BuildInfo::WordList &libs = c->get_build_info().libs; for(StringList::const_iterator i=libs.begin(); i!=libs.end(); ++i) { Target *lib = builder.get_vfs().find_library(*i, libpath, libmode); diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index 8c3571d..cc90c0a 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -20,13 +20,13 @@ void BinaryPackage::set_path(const FS::Path &p) void BinaryPackage::create_build_info() { - for(StringList::iterator i=export_binfo.incpath.begin(); i!=export_binfo.incpath.end(); ++i) - if((*i)[0]=='@') - *i = (path/i->substr(1)).str(); + for(BuildInfo::PathList::iterator i=export_binfo.incpath.begin(); i!=export_binfo.incpath.end(); ++i) + if((*i)[0]=="@") + *i = path/i->subpath(1); - for(StringList::iterator i=export_binfo.libpath.begin(); i!=export_binfo.libpath.end(); ++i) - if((*i)[0]=='@') - *i = (path/i->substr(1)).str(); + for(BuildInfo::PathList::iterator i=export_binfo.libpath.begin(); i!=export_binfo.libpath.end(); ++i) + if((*i)[0]=="@") + *i = path/i->subpath(1); } BinaryPackage *BinaryPackage::from_flags(Builder &builder, const std::string &name, const vector &flags) diff --git a/source/buildinfo.h b/source/buildinfo.h index 297efff..144a16d 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -33,12 +33,14 @@ public: }; typedef std::map DefineMap; + typedef std::list PathList; + typedef std::list WordList; DefineMap defines; - StringList incpath; - StringList libpath; - StringList libs; - StringList warnings; + PathList incpath; + PathList libpath; + WordList libs; + WordList warnings; bool threads; bool debug; int optimize; diff --git a/source/component.cpp b/source/component.cpp index 5c859f7..11d2925 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -61,9 +61,9 @@ void Component::create_build_info() build_info.update_from(pkg.get_build_info()); - for(StringList::iterator i=build_info.incpath.begin(); i!=build_info.incpath.end(); ++i) + for(BuildInfo::PathList::iterator i=build_info.incpath.begin(); i!=build_info.incpath.end(); ++i) *i = (pkg.get_source() / *i).str(); - for(StringList::iterator i=build_info.libpath.begin(); i!=build_info.libpath.end(); ++i) + for(BuildInfo::PathList::iterator i=build_info.libpath.begin(); i!=build_info.libpath.end(); ++i) *i = (pkg.get_source() / *i).str(); if(pkg.get_library_mode()!=DYNAMIC) diff --git a/source/csourcefile.cpp b/source/csourcefile.cpp index d3cb807..0ff4286 100644 --- a/source/csourcefile.cpp +++ b/source/csourcefile.cpp @@ -49,8 +49,8 @@ void CSourceFile::find_depends() deps_cache.set_deps(relname, includes); } - const StringList &incpath = comp->get_build_info().incpath; - StringList local_incpath = incpath; + const BuildInfo::PathList &incpath = comp->get_build_info().incpath; + BuildInfo::PathList local_incpath = incpath; local_incpath.push_front(FS::dirname(path).str()); for(list::iterator i=includes.begin(); i!=includes.end(); ++i) diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 6989e2d..5ecd293 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -44,10 +44,10 @@ Task *GnuCompiler::run(const Target &target) const argv.push_back("-c"); const BuildInfo &binfo = comp.get_build_info(); - for(list::const_iterator i=binfo.warnings.begin(); i!=binfo.warnings.end(); ++i) + for(BuildInfo::WordList::const_iterator i=binfo.warnings.begin(); i!=binfo.warnings.end(); ++i) argv.push_back("-W"+*i); - for(list::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i) - argv.push_back("-I"+*i); + for(BuildInfo::PathList::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i) + argv.push_back("-I"+i->str()); for(BuildInfo::DefineMap::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i) { if(i->second.empty()) diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index ee4f02d..52ae0f3 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -91,8 +91,8 @@ Task *GnuLinker::run(const Target &target) const argv.push_back("-static"); const BuildInfo &binfo = comp.get_build_info(); - for(list::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i) - argv.push_back("-L"+*i); + for(BuildInfo::PathList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i) + argv.push_back("-L"+i->str()); if(binfo.strip) argv.push_back("-s"); if(binfo.threads) diff --git a/source/pkgconfiggenerator.cpp b/source/pkgconfiggenerator.cpp index 827f62d..f29ae4a 100644 --- a/source/pkgconfiggenerator.cpp +++ b/source/pkgconfiggenerator.cpp @@ -52,16 +52,16 @@ void PkgConfigGenerator::Worker::main() const BuildInfo &binfo = spkg.get_exported_binfo(); IO::print(out, "Libs:"); - for(StringList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i) + for(BuildInfo::PathList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i) IO::print(out, " -L%s", FS::relative(*i, builder.get_prefix()).str()); - for(StringList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i) + for(BuildInfo::WordList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i) IO::print(out, " -l%s", *i); if(binfo.threads) out.write("-pthread"); out.put('\n'); IO::print(out, "Cflags:"); - for(StringList::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i) + for(BuildInfo::PathList::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i) IO::print(out, " -I%s", FS::relative(*i, builder.get_prefix()).str()); for(BuildInfo::DefineMap::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i) if(i->second.empty()) diff --git a/source/virtualfilesystem.h b/source/virtualfilesystem.h index f0cb738..362d5db 100644 --- a/source/virtualfilesystem.h +++ b/source/virtualfilesystem.h @@ -17,10 +17,10 @@ possible to build them. class VirtualFileSystem { public: - typedef std::list SearchPath; + typedef std::list SearchPath; private: - typedef std::map TargetMap; + typedef std::map TargetMap; Builder &builder; TargetMap targets;