]> git.tdb.fi Git - builder.git/commitdiff
Fix rebuild graph walking over symlinks
authorMikko Rasa <tdb@tdb.fi>
Fri, 12 Nov 2010 20:30:55 +0000 (20:30 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 12 Nov 2010 20:30:55 +0000 (20:30 +0000)
Allow non-numeric optimize levels (for -Os)
Don't create symlinks for shlibs without soname

source/analyzer.cpp
source/analyzer.h
source/builder.cpp
source/component.cpp
source/filetarget.cpp
source/sourcepackage.cpp
source/symlink.cpp
source/symlink.h
source/target.h

index 75c08849b39c61fdb222bbdcae8ab981bedfb770..984af61be7167b9ad06e47abdd4838e3e4bbb521 100644 (file)
@@ -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<const ObjectFile *>(&tgt))
                        return build_depend_table(obj->get_source(), depth);
-               else if(const Install *inst = dynamic_cast<const Install *>(&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;
index 6d6af9b5ab5706a076617bd6e9a500cf84052ee3..cca259052d8c075a5b5970e7bf4401212e8f96df 100644 (file)
@@ -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.
index 0b00fecf5c8dec0036c34a4ab69333394e2b7029..dac7bb84a43c6f68c577331b2294955309982f08 100644 (file)
@@ -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<string>::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);
        }
 
index 87252d574f98c67548861757cacbdc931a6bdf1e..c440e4c90df9c07c30db084f75d5fc8678963d73 100644 (file)
@@ -237,7 +237,8 @@ void Component::create_targets() const
 
                if(type==LIBRARY)
                        if(SharedLibrary *shlib = dynamic_cast<SharedLibrary *>(*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()));
        }
 }
 
index 7ba81b28cf5a626340c3a9de707b23846c9688d1..061a3ae20968750a70a589d21618059cb150c913 100644 (file)
@@ -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");
+                       }
                }
        }
 
index df1677fcce8edc638f8a8eb66cfafe2b6dee7b25..e946d018a51953a44149a6888179500a2923fd32 100644 (file)
@@ -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<unsigned>(optimize))
+       if(!optimize.empty() && optimize!="0")
        {
                build_info.cflags.push_back("-O"+optimize);
                build_info.ldflags.push_back("-O"+optimize);
index d99f6dabf99d991e9828ad9772f6d945965cad2a..2b979e778624507a24f95199fec2dd4983b9a07c 100644 (file)
@@ -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();
index b381eba78a3292c3d10638d3ea8b80b7deac1ff4..e3473be501f5b602f3bdddea5f1428e3e6dfdf88 100644 (file)
@@ -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();
index edfd60cebe7f8f655a5c8011512d05b80b481d9b..2881d42fcda00dc2409d57518eddaa48a357181b 100644 (file)
@@ -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