From: Mikko Rasa Date: Fri, 12 Nov 2010 20:30:55 +0000 (+0000) Subject: Fix rebuild graph walking over symlinks X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=87ea54db19306434bac3e765c9bd3464fd53f390;p=builder.git Fix rebuild graph walking over symlinks Allow non-numeric optimize levels (for -Os) Don't create symlinks for shlibs without soname --- diff --git a/source/analyzer.cpp b/source/analyzer.cpp index 75c0884..984af61 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -48,7 +48,7 @@ void Analyzer::analyze() row.push_back("Rebuild"); table.push_back(row); - const Target &cmdline = *builder.get_target("cmdline"); + Target &cmdline = *builder.get_target("cmdline"); if(mode==RDEPS) { const TargetList &deps = cmdline.get_depends(); @@ -61,19 +61,20 @@ void Analyzer::analyze() print_table(); } -void Analyzer::build_depend_table(const Target &tgt, unsigned depth) +void Analyzer::build_depend_table(Target &tgt, unsigned depth) { + Target *real = tgt.get_real_target(); if(mode==DEPS) { // Skip trivial targets + if(real!=&tgt) + return build_depend_table(*real, depth); if(const ObjectFile *obj = dynamic_cast(&tgt)) return build_depend_table(obj->get_source(), depth); - else if(const Install *inst = dynamic_cast(&tgt)) - return build_depend_table(inst->get_source(), depth); } - else if(mode==REBUILD && !tgt.get_rebuild()) + else if(mode==REBUILD && !tgt.get_rebuild() && !real->get_rebuild()) /* All targets that depend on to-be-built targets will be rebuilt - themselves, so we cn stop here. */ + themselves, so we can stop here. */ return; TableRow row; diff --git a/source/analyzer.h b/source/analyzer.h index 6d6af9b..cca2590 100644 --- a/source/analyzer.h +++ b/source/analyzer.h @@ -56,7 +56,7 @@ private: /** Adds rows to the table for the given target and its dependencies. */ - void build_depend_table(const Target &, unsigned); + void build_depend_table(Target &, unsigned); /** Prints out the table that resulted from the analysis. diff --git a/source/builder.cpp b/source/builder.cpp index 0b00fec..dac7bb8 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -652,7 +652,6 @@ int Builder::create_targets() // Make the cmdline target depend on all targets mentioned on the command line Target *cmdline = new VirtualTarget(*this, "cmdline"); - bool build_world = false; for(list::iterator i=cmdline_targets.begin(); i!=cmdline_targets.end(); ++i) { Target *tgt = get_target(*i); @@ -663,8 +662,7 @@ int Builder::create_targets() IO::print("I don't know anything about %s\n", *i); return -1; } - if(tgt==world) - build_world = true; + cmdline->add_depend(tgt); } diff --git a/source/component.cpp b/source/component.cpp index 87252d5..c440e4c 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -237,7 +237,8 @@ void Component::create_targets() const if(type==LIBRARY) if(SharedLibrary *shlib = dynamic_cast(*i)) - inst_tgt->add_depend(new Symlink(builder, pkg, *inst, shlib->get_name())); + if(!shlib->get_soname().empty()) + inst_tgt->add_depend(new Symlink(builder, pkg, *inst, shlib->get_name())); } } diff --git a/source/filetarget.cpp b/source/filetarget.cpp index 7ba81b2..061a3ae 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -53,6 +53,12 @@ void FileTarget::check_rebuild() mark_rebuild((*i)->get_name()+" has changed"); else if((*i)->get_rebuild()) mark_rebuild((*i)->get_name()+" needs rebuilding"); + else + { + Target *real = ft->get_real_target(); + if(real->get_rebuild()) + mark_rebuild(real->get_name()+" needs rebuilding"); + } } } diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index df1677f..e946d01 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -164,7 +164,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); diff --git a/source/symlink.cpp b/source/symlink.cpp index d99f6da..2b979e7 100644 --- a/source/symlink.cpp +++ b/source/symlink.cpp @@ -20,6 +20,11 @@ Symlink::Symlink(Builder &b, const Package &p, FileTarget &t, const string &n): add_depend(&target); } +Target *Symlink::get_buildable_target() +{ + return target.get_buildable_target(); +} + Target *Symlink::get_real_target() { return target.get_real_target(); diff --git a/source/symlink.h b/source/symlink.h index b381eba..e3473be 100644 --- a/source/symlink.h +++ b/source/symlink.h @@ -24,6 +24,7 @@ public: virtual const char *get_type() const { return "Symlink";} FileTarget &get_target() const { return target; } + virtual Target *get_buildable_target(); virtual Target *get_real_target(); private: virtual void check_rebuild(); diff --git a/source/target.h b/source/target.h index edfd60c..2881d42 100644 --- a/source/target.h +++ b/source/target.h @@ -56,7 +56,7 @@ public: dependencies are up-to-date, returns this target. If there are no targets ready to be built (maybe because they are being built right now), returns 0. */ - Target *get_buildable_target(); + virtual Target *get_buildable_target(); /** If this target is a proxy for another (such as Install or Symlink), return