]> git.tdb.fi Git - builder.git/commitdiff
Make the name of a FileTarget be its basename instead of full path
authorMikko Rasa <tdb@tdb.fi>
Fri, 5 Feb 2010 10:35:21 +0000 (10:35 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 5 Feb 2010 10:35:21 +0000 (10:35 +0000)
source/analyzer.cpp
source/binary.cpp
source/builder.cpp
source/builder.h
source/filetarget.cpp
source/install.cpp
source/sourcefile.cpp
source/target.cpp
source/virtualtarget.cpp
source/virtualtarget.h

index f8af44ff9a6295497102bd80989ef3f64c24c096..563143f11c56d2c0b5a72b7f5e4fc58327d23f72 100644 (file)
@@ -58,12 +58,13 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth)
        
        TableRow row;
 
-       string fn;
-       if(full_paths)
-               fn = tgt.get_name();
+       string name;
+       FileTarget *ft = dynamic_cast<FileTarget *>(&tgt);
+       if(full_paths && ft)
+               name = ft->get_path().str();
        else
-               fn = FS::basename(tgt.get_name());
-       row.push_back(string(depth*2, ' ')+fn);
+               name = tgt.get_name();
+       row.push_back(string(depth*2, ' ')+name);
 
        const Package *pkg = tgt.get_package();
        if(pkg)
index e82b65aaecb77048b126261c5a2cb6a444d3d24d..590471f3a0f75e286f55c6afd4f04f2c62a4b447 100644 (file)
@@ -59,7 +59,7 @@ void Binary::find_depends()
                                        queue.push_back(&stlib->get_component());
                        }
                        else
-                               builder.problem(comp.get_package().get_name(), format("Couldn't find library %s for %s", *i, FS::basename(name)));
+                               builder.problem(comp.get_package().get_name(), format("Couldn't find library %s for %s", *i, name));
                }
        }
 
index 77579ea45e60a894da24fb44182e972e7c9ba2be..208e7d5b389aec8524f75922e5d2df828848bdbc 100644 (file)
@@ -487,7 +487,13 @@ void Builder::problem(const string &p, const string &d)
        problems.push_back(Problem(p, d));
 }
 
-void Builder::add_target(Target *t)
+void Builder::add_target(FileTarget *t)
+{
+       targets.insert(TargetMap::value_type(t->get_path().str(), t));
+       new_tgts.push_back(t);
+}
+
+void Builder::add_target(VirtualTarget *t)
 {
        targets.insert(TargetMap::value_type(t->get_name(), t));
        new_tgts.push_back(t);
index 653a81ad22cf51ca83bbced40c0183c991b89947..9dca6f025fceeb8bf8a010d8480dbfbfd5285895 100644 (file)
@@ -22,8 +22,10 @@ Distributed under the LGPL
 
 class Analyzer;
 class Config;
+class FileTarget;
 class Package;
 class SourcePackage;
+class VirtualTarget;
 
 /**
 The main application class.  Controls and owns everything.  Rules the world.
@@ -146,7 +148,8 @@ public:
 
        /** Adds a target to both the target map and the new target queue.  Called
        from Target constructor. */
-       void add_target(Target *);
+       void add_target(FileTarget *);
+       void add_target(VirtualTarget *);
 
        void problem(const std::string &, const std::string &);
 
index 37cc65ca06ee282db3b8a62d41c9bc14ba1f8463..8f35cfc9ed3b54f776f30159ab7e909fb5ed4843 100644 (file)
@@ -7,17 +7,19 @@ Distributed under the LGPL
 
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
-#include "file.h"
+#include "builder.h"
+#include "filetarget.h"
 
 using namespace std;
 using namespace Msp;
 
 FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a):
-       // XXX Builder depends on target name being its path for locating file targets
-       Target(b, p, /*FS::basename*/(a.str())),
+       Target(b, p, FS::basename(a.str())),
        path(a),
        size(0)
 {
+       builder.add_target(this);
+
        struct stat st;
        if(!FS::stat(path, st))
        {
index 893f021387cbb81e346fb47e8418f8402ee58c49..e59e0d93b090d802e26ed9949eedbb036238826d 100644 (file)
@@ -33,9 +33,9 @@ void Install::check_rebuild()
        if(!mtime)
                mark_rebuild("Does not exist");
        else if(source.get_mtime()>mtime || source.get_size()!=size)
-               mark_rebuild(FS::basename(source.get_name())+" has changed");
+               mark_rebuild(source.get_name()+" has changed");
        else if(source.get_rebuild())
-               mark_rebuild(FS::basename(source.get_name())+" needs rebuilding");
+               mark_rebuild(source.get_name()+" needs rebuilding");
 }
 
 Action *Install::create_action()
index 3a1941af4b76b8ea41266ef6d237bdf846e10962..d95ea5edc5f3678d1f1c0eb1926a50866ab22311 100644 (file)
@@ -36,7 +36,7 @@ void SourceFile::find_depends()
        }
 
        const SourcePackage &spkg = comp->get_package();
-       string relname = FS::relative(name, spkg.get_source()).str();
+       string relname = FS::relative(path, spkg.get_source()).str();
        DependencyCache &deps_cache = spkg.get_deps_cache();
        bool deps_found = false;
        if(mtime<deps_cache.get_mtime())
@@ -54,10 +54,10 @@ void SourceFile::find_depends()
        {
                try
                {
-                       IO::BufferedFile in(name);
+                       IO::BufferedFile in(path.str());
 
                        if(builder.get_verbose()>=4)
-                               IO::print("Reading includes from %s\n", name);
+                               IO::print("Reading includes from %s\n", path.str());
 
                        Regex r_include("^[ \t]*#include[ \t]+([\"<].*)[\">]");
 
@@ -70,7 +70,9 @@ void SourceFile::find_depends()
                }
                catch(const IO::FileNotFound &)
                {
-                       // XXX WTF?
+                       if(builder.get_verbose()>=4)
+                               IO::print("Failed to read includes from %s\n", path.str());
+                       deps_ready = true;
                        return;
                }
        }
index 3ee6bc5efe1528fc5573ed0ea8e8a9fc23107c93..532901167b51f813228a972a52e7b4941806b64f 100644 (file)
@@ -28,9 +28,7 @@ Target::Target(Builder &b, const Package *p, const string &n):
        deps_ready(false),
        preparing(false),
        prepared(false)
-{
-       builder.add_target(this);
-}
+{ }
 
 Target *Target::get_buildable_target()
 {
@@ -128,9 +126,9 @@ void Target::check_rebuild()
                for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
                {
                        if((*i)->get_mtime()>mtime)
-                               mark_rebuild(FS::basename((*i)->get_name())+" has changed");
+                               mark_rebuild((*i)->get_name()+" has changed");
                        else if((*i)->get_rebuild())
-                               mark_rebuild(FS::basename((*i)->get_name())+" needs rebuilding");
+                               mark_rebuild((*i)->get_name()+" needs rebuilding");
                }
        }
 
index 72d369b402ca641fdd021fc3bd1b23849a0b3710..85bdbc0779fd26c0855d8a053338106be48d91a0 100644 (file)
@@ -7,15 +7,22 @@ Distributed under the LGPL
 
 #include <msp/fs/path.h>
 #include <msp/fs/utils.h>
+#include "builder.h"
 #include "virtualtarget.h"
 
 using namespace std;
 using namespace Msp;
 
+VirtualTarget::VirtualTarget(Builder &b, const string &n):
+       Target(b, 0, n)
+{
+       builder.add_target(this);
+}
+
 void VirtualTarget::check_rebuild()
 {
        // Virtual targets are only rebuilt if their dependencies need rebuilding.
        for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
                if((*i)->get_rebuild())
-                       mark_rebuild(FS::basename((*i)->get_name())+" needs rebuilding");
+                       mark_rebuild((*i)->get_name()+" needs rebuilding");
 }
index 252c68f3cb3aa7ebd6f187f349954463a22399f4..d68dba4cf77c326e5cd870119ea7438d4dd3bf69 100644 (file)
@@ -16,7 +16,7 @@ A target that is not associated with any file.
 class VirtualTarget: public Target
 {
 public:
-       VirtualTarget(Builder &b, const std::string &n): Target(b, 0, n) { }
+       VirtualTarget(Builder &, const std::string &);
        virtual const char *get_type() const { return "VirtualTarget"; }
 private:
        virtual void check_rebuild();