]> git.tdb.fi Git - builder.git/commitdiff
Rework the Target class hierarchy
authorMikko Rasa <tdb@tdb.fi>
Sat, 21 Feb 2009 00:45:50 +0000 (00:45 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sat, 21 Feb 2009 00:45:50 +0000 (00:45 +0000)
- Introduce FileTarget and move the stat call there
- More senseful relationships between executable and library targets
- Some related minor cleanups

39 files changed:
source/analyzer.cpp
source/archive.cpp
source/binary.cpp [new file with mode: 0644]
source/binary.h [new file with mode: 0644]
source/builder.cpp
source/builder.h
source/compile.cpp
source/component.cpp
source/executable.cpp
source/executable.h
source/file.cpp
source/file.h
source/filetarget.cpp [new file with mode: 0644]
source/filetarget.h [new file with mode: 0644]
source/install.cpp
source/install.h
source/library.cpp [new file with mode: 0644]
source/library.h [new file with mode: 0644]
source/link.cpp
source/link.h
source/objectfile.cpp
source/objectfile.h
source/pkgconfig.cpp
source/pkgconfig.h
source/pkgconfigaction.cpp
source/sharedlibrary.cpp
source/sharedlibrary.h
source/sourcefile.cpp
source/sourcefile.h
source/staticlibrary.cpp
source/staticlibrary.h
source/systemlibrary.cpp
source/systemlibrary.h
source/tar.cpp
source/tarball.cpp
source/tarball.h
source/target.cpp
source/unlink.cpp
source/unlink.h

index 3481ec823309523fce9f78e171c3ff9df7374382..6664477598d653aa3d4a05950a08c62a808e6a42 100644 (file)
@@ -14,6 +14,7 @@ Distributed under the LGPL
 #include "install.h"
 #include "objectfile.h"
 #include "package.h"
+#include "sourcefile.h"
 #include "target.h"
 
 using namespace std;
@@ -45,10 +46,10 @@ void Analyzer::build_depend_table(Target &tgt, unsigned depth)
        if(mode!=REBUILD && mode!=ALLDEPS)
        {
                // Skip trivial targets
-               if(dynamic_cast<ObjectFile *>(&tgt))
-                       return build_depend_table(*tgt.get_depends().front(), depth);
-               else if(dynamic_cast<Install *>(&tgt))
-                       return build_depend_table(*tgt.get_depends().front(), depth);
+               if(ObjectFile *obj=dynamic_cast<ObjectFile *>(&tgt))
+                       return build_depend_table(obj->get_source(), depth);
+               else if(Install *inst=dynamic_cast<Install *>(&tgt))
+                       return build_depend_table(inst->get_source(), depth);
        }
        else if(mode==REBUILD && !tgt.get_rebuild())
                /* All targets that depend on to-be-built targets will be rebuilt
index 204b202c4863c112593edc50cf6e1d8fe0d53bcf..8b36391aece95ba911537fbd5f6dfba93dfaea2d 100644 (file)
@@ -28,13 +28,13 @@ Archive::Archive(Builder &b, const StaticLibrary &lib):
        argv.push_back(builder.get_current_arch().get_tool(tool));
        argv.push_back("rc");
 
-       argv.push_back(relative(lib.get_name(), work_dir).str());
+       argv.push_back(relative(lib.get_path(), work_dir).str());
        const TargetList &deps=lib.get_depends();
        for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
-               if(dynamic_cast<ObjectFile *>(*i))
-                       argv.push_back(relative((*i)->get_name(), work_dir).str());
+               if(ObjectFile *obj=dynamic_cast<ObjectFile *>(*i))
+                       argv.push_back(relative(obj->get_path(), work_dir).str());
 
-       FS::Path lpath=lib.get_name();
+       FS::Path lpath=lib.get_path();
        if(!builder.get_dry_run())
                FS::mkpath(FS::dirname(lpath), 0755);
 
diff --git a/source/binary.cpp b/source/binary.cpp
new file mode 100644 (file)
index 0000000..591e934
--- /dev/null
@@ -0,0 +1,108 @@
+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include <msp/fs/utils.h>
+#include <msp/strings/formatter.h>
+#include "binary.h"
+#include "builder.h"
+#include "component.h"
+#include "install.h"
+#include "link.h"
+#include "objectfile.h"
+#include "package.h"
+#include "sharedlibrary.h"
+#include "staticlibrary.h"
+
+using namespace std;
+using namespace Msp;
+
+Binary::Binary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
+       FileTarget(b, &c.get_package(), generate_target_path(c)),
+       comp(c)
+{
+       buildable=true;
+       for(list<ObjectFile *>::const_iterator i=objs.begin(); i!=objs.end(); ++i)
+               add_depend(*i);
+}
+
+void Binary::find_depends()
+{
+       LibMode libmode=comp.get_package().get_library_mode();
+       if(dynamic_cast<SharedLibrary *>(this))
+               libmode=DYNAMIC;
+
+       list<const Component *> queue;
+       list<Target *> dep_libs;
+       queue.push_back(&comp);
+       while(!queue.empty())
+       {
+               const Component *c=queue.front();
+               queue.erase(queue.begin());
+
+               const StringList &libpath=c->get_build_info().libpath;
+
+               const list<string> &libs=c->get_build_info().libs;
+               for(StringList::const_iterator i=libs.begin(); i!=libs.end(); ++i)
+               {
+                       Target *lib=builder.get_library(*i, libpath, libmode);
+                       if(lib)
+                       {
+                               dep_libs.push_back(lib);
+
+                               if(Install *inst=dynamic_cast<Install *>(lib))
+                                       lib=&inst->get_source();
+                               if(StaticLibrary *stlib=dynamic_cast<StaticLibrary *>(lib))
+                                       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)));
+               }
+       }
+
+       /* Add only the last occurrence of each library to the actual dependencies.
+       This ensures that static library ordering is correct. */
+       for(list<Target *>::iterator i=dep_libs.begin(); i!=dep_libs.end(); ++i)
+       {
+               bool last=true;
+               for(list<Target *>::iterator j=i; (last && j!=dep_libs.end()); ++j)
+                       last=(j==i || *j!=*i);
+               if(last)
+                       add_depend(*i);
+       }
+
+       deps_ready=true;
+}
+
+Action *Binary::create_action()
+{
+       return new Link(builder, *this);
+}
+
+FS::Path Binary::generate_target_path(const Component &c)
+{
+       const SourcePackage &pkg=c.get_package();
+       string prefix, suffix;
+       const string &arch=pkg.get_builder().get_current_arch().get_name();
+
+       if(c.get_type()==Component::LIBRARY)
+       {
+               prefix="lib";
+               if(arch=="win32")
+                       suffix=".dll";
+               else
+                       suffix=".so";
+       }
+       else if(c.get_type()==Component::MODULE)
+               suffix=".m";
+       else if(c.get_type()==Component::PROGRAM)
+       {
+               if(arch=="win32")
+                       suffix=".exe";
+       }
+
+       return pkg.get_out_dir()/(prefix+c.get_name()+suffix);
+}
diff --git a/source/binary.h b/source/binary.h
new file mode 100644 (file)
index 0000000..cb9a56e
--- /dev/null
@@ -0,0 +1,37 @@
+/* $Id$
+
+This file is part of builder
+Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef BINARY_H_
+#define BINARY_H_
+
+#include "filetarget.h"
+
+class Component;
+class ObjectFile;
+
+/**
+Produces a binary file, which may be either a standalone executable or a shared
+library.
+*/
+class Binary: public virtual FileTarget
+{
+protected:
+       const Component &comp;
+
+       Binary(Builder &, const Component &, const std::list<ObjectFile *> &);
+public:
+       const Component &get_component() const { return comp; }
+       virtual void find_depends();
+protected:
+       virtual Action *create_action();
+
+       /** Returns the path for the binary.  We can't do this in the constructor
+       since we need to pass the value to the Target c'tor. */
+       static Msp::FS::Path generate_target_path(const Component &);
+};
+
+#endif
index 3838ae5c0ba14813cb0c3ae795ad7c1f40649d60..bbf6eb1d046dbf8fee32e4d2279de3d2ccaad329 100644 (file)
@@ -134,7 +134,7 @@ Builder::Builder(int argc, char **argv):
                cmdline_targets.push_back("default");
 
        if(!work_dir.empty())
-               chdir(work_dir.c_str());
+               FS::chdir(work_dir);
 
        cwd=FS::getcwd();
 
@@ -300,17 +300,18 @@ Package *Builder::get_package(const string &name)
 
 Target *Builder::get_target(const string &n) const
 {
+       // XXX Used for getting targets by path.  get_target(const FS::Path &)?
        TargetMap::const_iterator i=targets.find(n);
        if(i!=targets.end())
                return i->second;
        return 0;
 }
 
-Target *Builder::get_header(const string &include, const string &from, const list<string> &path)
+Target *Builder::get_header(const string &include, const FS::Path &from, const list<string> &path)
 {
        string hash(8, 0);
        if(include[0]=='\"')
-               update_hash(hash, from);
+               update_hash(hash, from.str());
        for(list<string>::const_iterator i=path.begin(); i!=path.end(); ++i)
                update_hash(hash, *i);
 
@@ -669,8 +670,8 @@ Target *Builder::get_library(const string &lib, const FS::Path &path, LibMode mo
                if(tgt)
                {
                        Target *real_tgt=tgt;
-                       if(dynamic_cast<Install *>(tgt))
-                               real_tgt=real_tgt->get_depends().front();
+                       if(Install *inst=dynamic_cast<Install *>(tgt))
+                               real_tgt=&inst->get_source();
 
                        /* Ignore dynamic libraries from local packages unless library mode is
                        DYNAMIC */
@@ -784,11 +785,12 @@ int Builder::do_clean()
        }
 
        for(set<Target *>::iterator i=clean_tgts.begin(); i!=clean_tgts.end(); ++i)
-       {
-               Action *action=new Unlink(*this, **i);
-               while(action->check()<0) ;
-               delete action;
-       }
+               if(FileTarget *ft=dynamic_cast<FileTarget *>(*i))
+               {
+                       Action *action=new Unlink(*this, *ft);
+                       while(action->check()<0) ;
+                       delete action;
+               }
 
        return 0;
 }
index 90a8a7c4efe600b1341bf5d5934d0273447394df..0ebf2df1eb0ddada01c1651bc4baeb44045d2b95 100644 (file)
@@ -124,7 +124,7 @@ public:
        path.  Considers known targets as well as existing files.  If a matching
        target is not found but a file exists, a new SystemHeader target will be
        created and returned. */
-       Target *get_header(const std::string &, const std::string &, const StringList &);
+       Target *get_header(const std::string &, const Msp::FS::Path &, const StringList &);
 
        /** Tries to locate a library in a library path.  The library name should be
        the same as would be given to the linker with -l, i.e. without the "lib"
index 4157ccb58f0afa305fb035bd33088eb3d5906aa0..da1cfefc636adf55e3e05890cec9c43134af026b 100644 (file)
@@ -12,6 +12,7 @@ Distributed under the LGPL
 #include "compile.h"
 #include "component.h"
 #include "objectfile.h"
+#include "sourcefile.h"
 #include "sourcepackage.h"
 
 using namespace std;
@@ -24,8 +25,7 @@ Compile::Compile(Builder &b, const ObjectFile &obj):
 
        work_dir=comp.get_package().get_source();
 
-       const TargetList &deps=obj.get_depends();
-       FS::Path spath=deps.front()->get_name();
+       FS::Path spath=obj.get_source().get_path();
 
        string ext=FS::extpart(spath.str());
        const char *tool=0;
@@ -47,7 +47,7 @@ Compile::Compile(Builder &b, const ObjectFile &obj):
        for(list<string>::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
                argv.push_back("-D"+*i);
 
-       FS::Path opath=obj.get_name();
+       FS::Path opath=obj.get_path();
        argv.push_back("-o");
        argv.push_back(relative(opath, work_dir).str());
        argv.push_back(relative(spath, work_dir).str());
index dcbaf373e19c0c16360fbfa468988575767fd5ff..dd33941c7ed20f6b08b0bf8e4929f26ddf5c57fe 100644 (file)
@@ -12,6 +12,7 @@ Distributed under the LGPL
 #include <msp/strings/lexicalcast.h>
 #include "builder.h"
 #include "component.h"
+#include "executable.h"
 #include "header.h"
 #include "install.h"
 #include "objectfile.h"
@@ -89,7 +90,7 @@ void Component::create_targets() const
        bool build_exe=(type!=HEADERS);
 
        list<ObjectFile *> objs;
-       list<Target *> inst_tgts;
+       list<FileTarget *> inst_tgts;
        for(PathList::const_iterator i=files.begin(); i!=files.end(); ++i)
        {
                string ext=FS::extpart(FS::basename(*i));
@@ -103,7 +104,7 @@ void Component::create_targets() const
                }
                else if(ext==".h")
                {
-                       Target *hdr=builder.get_target(i->str());
+                       FileTarget *hdr=dynamic_cast<FileTarget *>(builder.get_target(i->str()));
                        if(!hdr)
                                hdr=new Header(builder, this, i->str());
 
@@ -115,37 +116,37 @@ void Component::create_targets() const
 
        if(build_exe)
        {
-               Executable *exe=0;
+               Binary *bin=0;
                StaticLibrary *slib=0;
                if(type==LIBRARY)
                {
-                       exe=new SharedLibrary(builder, *this, objs);
+                       bin=new SharedLibrary(builder, *this, objs);
                        slib=new StaticLibrary(builder, *this, objs);
                }
                else
-                       exe=new Executable(builder, *this, objs);
+                       bin=new Executable(builder, *this, objs);
 
                if(&pkg==builder.get_main_package() && deflt)
                {
-                       def_tgt->add_depend(exe);
+                       def_tgt->add_depend(bin);
                        if(slib) def_tgt->add_depend(slib);
                }
                else
                {
-                       world->add_depend(exe);
+                       world->add_depend(bin);
                        if(slib) world->add_depend(slib);
                }
 
                if(install)
                {
-                       inst_tgts.push_back(exe);
+                       inst_tgts.push_back(bin);
                        if(slib)
                                inst_tgts.push_back(slib);
                }
        }
 
        Target *inst_tgt=builder.get_target("install");
-       for(TargetList::const_iterator i=inst_tgts.begin(); i!=inst_tgts.end(); ++i)
+       for(list<FileTarget *>::const_iterator i=inst_tgts.begin(); i!=inst_tgts.end(); ++i)
                inst_tgt->add_depend(new Install(builder, pkg, **i));
 }
 
index 50ac3d3cbc60a9d4276f9662e63843527d90b566..44d461268a35bd287f216961a71573626972bb3d 100644 (file)
 /* $Id$
 
 This file is part of builder
-Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
+Copyright © 2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
-#include <msp/fs/utils.h>
-#include <msp/strings/formatter.h>
-#include "builder.h"
 #include "component.h"
 #include "executable.h"
-#include "install.h"
-#include "link.h"
-#include "objectfile.h"
-#include "package.h"
-#include "sharedlibrary.h"
-#include "staticlibrary.h"
+#include "sourcepackage.h"
 
-using namespace std;
-using namespace Msp;
-
-Executable::Executable(Builder &b, const Component &c, const list<ObjectFile *> &objs):
-       Target(b, &c.get_package(), generate_target_name(c)),
-       comp(c)
-{
-       buildable=true;
-       for(list<ObjectFile *>::const_iterator i=objs.begin(); i!=objs.end(); ++i)
-               add_depend(*i);
-}
-
-void Executable::find_depends()
-{
-       LibMode libmode=comp.get_package().get_library_mode();
-       if(dynamic_cast<SharedLibrary *>(this))
-               libmode=DYNAMIC;
-
-       list<const Component *> queue;
-       list<Target *> dep_libs;
-       queue.push_back(&comp);
-       while(!queue.empty())
-       {
-               const Component *c=queue.front();
-               queue.erase(queue.begin());
-
-               const StringList &libpath=c->get_build_info().libpath;
-
-               const list<string> &libs=c->get_build_info().libs;
-               for(StringList::const_iterator i=libs.begin(); i!=libs.end(); ++i)
-               {
-                       Target *lib=builder.get_library(*i, libpath, libmode);
-                       if(lib)
-                       {
-                               dep_libs.push_back(lib);
-
-                               if(dynamic_cast<Install *>(lib))
-                                       lib=lib->get_depends().front();
-                               if(StaticLibrary *stlib=dynamic_cast<StaticLibrary *>(lib))
-                                       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)));
-               }
-       }
-
-       /* Add only the last occurrence of each library to the actual dependencies.
-       This ensures that static library ordering is correct. */
-       for(list<Target *>::iterator i=dep_libs.begin(); i!=dep_libs.end(); ++i)
-       {
-               bool last=true;
-               for(list<Target *>::iterator j=i; (last && j!=dep_libs.end()); ++j)
-                       last=(j==i || *j!=*i);
-               if(last)
-                       add_depend(*i);
-       }
-
-       deps_ready=true;
-}
-
-Action *Executable::create_action()
-{
-       return new Link(builder, *this);
-}
-
-string Executable::generate_target_name(const Component &c)
-{
-       const SourcePackage &pkg=c.get_package();
-       string prefix, suffix;
-       const string &arch=pkg.get_builder().get_current_arch().get_name();
-
-       if(c.get_type()==Component::LIBRARY)
-       {
-               prefix="lib";
-               if(arch=="win32")
-                       suffix=".dll";
-               else
-                       suffix=".so";
-       }
-       else if(c.get_type()==Component::MODULE)
-               suffix=".m";
-       else if(c.get_type()==Component::PROGRAM)
-       {
-               if(arch=="win32")
-                       suffix=".exe";
-       }
-
-       return (pkg.get_out_dir()/(prefix+c.get_name()+suffix)).str();
-}
+Executable::Executable(Builder &b, const Component &c, const std::list<ObjectFile *> &objs):
+       FileTarget(b, &c.get_package(), generate_target_path(c)),
+       Binary(b, c, objs)
+{ }
index a6ebb978175c46029ae804728418d3a423fc1efc..0dc4fc5223b0f671af15901397af594a63dc6679 100644 (file)
@@ -1,38 +1,20 @@
 /* $Id$
 
 This file is part of builder
-Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
+Copyright © 2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
 #ifndef EXECUTABLE_H_
 #define EXECUTABLE_H_
 
-#include "target.h"
+#include "binary.h"
 
-class Component;
-class ObjectFile;
-
-/**
-Produces a binary file, which may be either a standalone executable or a shared
-library.
-*/
-class Executable: public Target
+class Executable: public Binary
 {
-private:
-       const Component &comp;
-
 public:
        Executable(Builder &, const Component &, const std::list<ObjectFile *> &);
        virtual const char *get_type() const { return "Executable"; }
-       const Component &get_component() const { return comp; }
-       virtual void find_depends();
-private:
-       virtual Action *create_action();
-
-       /** Returns the name for the executable.  We can't do this in the
-       constructor since we need to pass the value to the Target c'tor. */
-       static std::string generate_target_name(const Component &);
 };
 
 #endif
index e2b3c27b429a11d5d82df497d30fa282bfdcc2d1..4a870e718069cfd2a0cc4c45a819d8b1bc5dc8c3 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of builder
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007, 2009  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -10,5 +10,5 @@ Distributed under the LGPL
 using namespace std;
 
 File::File(Builder &b, const string &n):
-       Target(b, 0, n)
+       FileTarget(b, 0, n)
 { }
index bc71df87a25d02ff30542b08ab329f67303cc3d0..19d14af92749a425e2f8268fcb483cc62d9fb0f5 100644 (file)
@@ -8,9 +8,12 @@ Distributed under the LGPL
 #ifndef FILE_H_
 #define FILE_H_
 
-#include "target.h"
+#include "filetarget.h"
 
-class File: public Target
+/**
+Just a file.  Any file, not attached to a package.
+*/
+class File: public FileTarget
 {
 public:
        File(Builder &, const std::string &);
diff --git a/source/filetarget.cpp b/source/filetarget.cpp
new file mode 100644 (file)
index 0000000..ed3e66b
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Id$
+
+This file is part of builder
+Copyright © 2009  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include <msp/fs/stat.h>
+#include <msp/fs/utils.h>
+#include "file.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())),
+       path(a)
+{
+       struct stat st;
+       if(!FS::stat(path, st))
+               mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
+}
diff --git a/source/filetarget.h b/source/filetarget.h
new file mode 100644 (file)
index 0000000..3b8bfcc
--- /dev/null
@@ -0,0 +1,28 @@
+/* $Id$
+
+This file is part of builder
+Copyright © 2009  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef FILETARGET_H_
+#define FILETARGET_H_
+
+#include <msp/fs/path.h>
+#include "target.h"
+
+/**
+An intermediate base class for targets that represent files.  Almost all target
+classes are derived from this.
+*/
+class FileTarget: public Target
+{
+protected:
+       Msp::FS::Path path;
+
+       FileTarget(Builder &, const Package *, const Msp::FS::Path &);
+public:
+       const Msp::FS::Path &get_path() const { return path; }
+};
+
+#endif
index d30eea03a060fd4d2e6aafa42548a342ceb1a5e3..1eb510e4505f768f49d82aebadfddcd51e126cc4 100644 (file)
@@ -13,54 +13,52 @@ Distributed under the LGPL
 #include "install.h"
 #include "package.h"
 #include "pkgconfig.h"
+#include "sharedlibrary.h"
 #include "staticlibrary.h"
 
 using namespace std;
 using namespace Msp;
 
-Install::Install(Builder &b, const SourcePackage &p, Target &tgt):
-       Target(b, &p, generate_target_name(tgt))
+Install::Install(Builder &b, const SourcePackage &p, FileTarget &s):
+       FileTarget(b, &p, generate_target_path(s)),
+       source(s)
 {
        buildable=true;
-       add_depend(&tgt);
+       add_depend(&source);
 }
 
 void Install::check_rebuild()
 {
        if(!mtime)
                mark_rebuild("Does not exist");
-       else
-       {
-               Target *dep=depends.front();
-               if(dep->get_mtime()>mtime)
-                       mark_rebuild(FS::basename(dep->get_name())+" has changed");
-               else if(dep->get_rebuild())
-                       mark_rebuild(FS::basename(dep->get_name())+" needs rebuilding");
-       }
+       else if(source.get_mtime()>mtime)
+               mark_rebuild(FS::basename(source.get_name())+" has changed");
+       else if(source.get_rebuild())
+               mark_rebuild(FS::basename(source.get_name())+" needs rebuilding");
 }
 
 Action *Install::create_action()
 {
-       return new Copy(builder, *package, depends.front()->get_name(), name);
+       return new Copy(builder, *package, source.get_path(), path);
 }
 
-string Install::generate_target_name(const Target &tgt)
+FS::Path Install::generate_target_path(const FileTarget &tgt)
 {
        const SourcePackage *spkg=dynamic_cast<const SourcePackage *>(tgt.get_package());
 
        FS::Path base=spkg->get_builder().get_prefix();
-       string tgtname=tgt.get_name().substr(tgt.get_name().rfind('/')+1);
+       string tgtname=FS::basename(tgt.get_path());
 
        string mid;
        if(const Header *hdr=dynamic_cast<const Header *>(&tgt))
                mid="include/"+hdr->get_component()->get_install_headers();
-       else if(const Executable *exe=dynamic_cast<const Executable *>(&tgt))
+       else if(dynamic_cast<const Executable *>(&tgt))
+               mid="bin";
+       else if(const SharedLibrary *shlib=dynamic_cast<const SharedLibrary *>(&tgt))
        {
-               const Component &comp=exe->get_component();
+               const Component &comp=shlib->get_component();
                if(comp.get_type()==Component::LIBRARY)
                        mid="lib";
-               else if(comp.get_type()==Component::PROGRAM)
-                       mid="bin";
                else if(comp.get_type()==Component::MODULE)
                        mid="lib/"+tgt.get_package()->get_name();
        }
index 41b43828e8a3304e546084d20756e7be33f3f75f..764d9a19bc20f8547ed484e281974eb840c32931 100644 (file)
@@ -9,21 +9,25 @@ Distributed under the LGPL
 #define INSTALL_H_
 
 #include "sourcepackage.h"
-#include "target.h"
+#include "filetarget.h"
 
 /**
 Represents the installation of a file.
 */
-class Install: public Target
+class Install: public FileTarget
 {
+private:
+       FileTarget &source;
+
 public:
-       Install(Builder &, const SourcePackage &, Target &);
+       Install(Builder &, const SourcePackage &, FileTarget &);
        virtual const char *get_type() const { return "Install"; }
+       FileTarget &get_source() const { return source; }
 private:
        virtual void check_rebuild();
        virtual Action *create_action();
 
-       static std::string generate_target_name(const Target &);
+       static Msp::FS::Path generate_target_path(const FileTarget &);
 };
 
 #endif
diff --git a/source/library.cpp b/source/library.cpp
new file mode 100644 (file)
index 0000000..23604eb
--- /dev/null
@@ -0,0 +1,13 @@
+/* $Id$
+
+This file is part of builder
+Copyright © 2009  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "library.h"
+
+Library::Library(Builder &b, const Package *p, const Msp::FS::Path &a, const std::string &l):
+       FileTarget(b, p, a),
+       libname(l)
+{ }
diff --git a/source/library.h b/source/library.h
new file mode 100644 (file)
index 0000000..8d8f13d
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Id$
+
+This file is part of builder
+Copyright © 2009  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef LIBRARY_H_
+#define LIBRARY_H_
+
+#include "filetarget.h"
+
+class Library: public virtual FileTarget
+{
+protected:
+       std::string libname;
+
+       Library(Builder &, const Package *, const Msp::FS::Path &, const std::string &);
+public:
+       const std::string &get_libname() const { return libname; }
+};
+
+#endif
index 25713e17f8acc26a21566fafef22e4de4c8d9e14..b165bad72550900f75c9e82400a86dd91f0816d7 100644 (file)
@@ -21,10 +21,10 @@ Distributed under the LGPL
 using namespace std;
 using namespace Msp;
 
-Link::Link(Builder &b, const Executable &exe):
+Link::Link(Builder &b, const Binary &bin):
        ExternalAction(b)
 {
-       const Component &comp=exe.get_component();
+       const Component &comp=bin.get_component();
 
        work_dir=comp.get_package().get_source();
 
@@ -44,29 +44,27 @@ Link::Link(Builder &b, const Executable &exe):
                argv.push_back("-L"+*i);
 
        argv.push_back("-o");
-       argv.push_back(relative(exe.get_name(), work_dir).str());
-       const TargetList &deps=exe.get_depends();
+       argv.push_back(relative(bin.get_path(), work_dir).str());
+       const TargetList &deps=bin.get_depends();
        for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
        {
                Target *tgt=*i;
-               if(dynamic_cast<Install *>(tgt))
-                       tgt=tgt->get_depends().front();
+               if(Install *inst=dynamic_cast<Install *>(tgt))
+                       tgt=&inst->get_source();
 
-               if(dynamic_cast<ObjectFile *>(tgt))
-                       argv.push_back(relative((*i)->get_name(), work_dir).str());
-               else if(SharedLibrary *shlib=dynamic_cast<SharedLibrary *>(tgt))
-                       argv.push_back("-l"+shlib->get_libname());
-               else if(dynamic_cast<StaticLibrary *>(tgt))
-                       argv.push_back((*i)->get_name());
-               else if(SystemLibrary *syslib=dynamic_cast<SystemLibrary *>(tgt))
-                       argv.push_back("-l"+syslib->get_libname());
+               if(ObjectFile *obj=dynamic_cast<ObjectFile *>(tgt))
+                       argv.push_back(relative(obj->get_path(), work_dir).str());
+               else if(StaticLibrary *stlib=dynamic_cast<StaticLibrary *>(tgt))
+                       argv.push_back(stlib->get_path().str());
+               else if(Library *lib=dynamic_cast<Library *>(tgt))
+                       argv.push_back("-l"+lib->get_libname());
        }
 
-       FS::Path epath=exe.get_name();
+       FS::Path binpath=bin.get_path();
        if(!builder.get_dry_run())
-               FS::mkpath(FS::dirname(epath), 0755);
+               FS::mkpath(FS::dirname(binpath), 0755);
 
-       announce(comp.get_package().get_name(), tool, relative(epath, work_dir).str());
+       announce(comp.get_package().get_name(), tool, relative(binpath, work_dir).str());
 
        launch();
 }
index d58d821ccd1ab41c365fdf395f642cec4a797937..ec227c5cf4d5fbb8df3bfaf3e4af1b589d05b0c1 100644 (file)
@@ -18,7 +18,7 @@ Links object files and libraries to produce an executable.
 class Link: public ExternalAction
 {
 public:
-       Link(Builder &, const Executable &);
+       Link(Builder &, const Binary &);
 };
 
 #endif
index 683c724306d1f56db62a9585b69aeaf78cadbff7..fd1c9758d8f498e04f227bd752cb80f866e4fd30 100644 (file)
@@ -18,12 +18,13 @@ Distributed under the LGPL
 using namespace std;
 using namespace Msp;
 
-ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &src):
-       Target(b, &c.get_package(), generate_target_name(c, src.get_name())),
-       comp(c)
+ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s):
+       FileTarget(b, &c.get_package(), generate_target_path(c, FS::basename(s.get_path()))),
+       comp(c),
+       source(s)       
 {
        buildable=true;
-       add_depend(&src);
+       add_depend(&source);
 }
 
 void ObjectFile::find_depends()
@@ -46,25 +47,22 @@ void ObjectFile::find_depends()
 
 void ObjectFile::find_depends(Target *tgt)
 {
-       const string &tname=tgt->get_name();
-       string path=tname.substr(0, tname.rfind('/'));
-
        SourceFile *src=dynamic_cast<SourceFile *>(tgt);
        if(!src)
        {
-               Install *inst=dynamic_cast<Install *>(tgt);
-               if(inst)
-                       src=dynamic_cast<SourceFile *>(inst->get_depends().front());
+               if(Install *inst=dynamic_cast<Install *>(tgt))
+                       src=dynamic_cast<SourceFile *>(&inst->get_source());
        }
        if(!src)
                return;
 
+       FS::Path spath=src->get_path();
        const StringList &incpath=comp.get_build_info().incpath;
 
        const list<string> &includes=src->get_includes();
        for(list<string>::const_iterator i=includes.begin(); i!=includes.end(); ++i)
        {
-               Target *hdr2=builder.get_header(*i, path, incpath);
+               Target *hdr2=builder.get_header(*i, spath, incpath);
                if(hdr2 && find(depends.begin(), depends.end(), hdr2)==depends.end())
                        add_depend(hdr2);
        }
@@ -81,8 +79,8 @@ Action *ObjectFile::create_action()
        return new Compile(builder, *this);
 }
 
-string ObjectFile::generate_target_name(const Component &comp, const string &src)
+FS::Path ObjectFile::generate_target_path(const Component &comp, const string &src)
 {
        const SourcePackage &pkg=comp.get_package();
-       return (pkg.get_temp_dir()/comp.get_name()/(FS::basepart(FS::basename(src))+".o")).str();
+       return pkg.get_temp_dir()/comp.get_name()/(FS::basepart(src)+".o");
 }
index 4845a0f15c0ca3490e619fa618766533e7852f43..7cc6f604c685ef343d744d39dfb4067cde2240a2 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef OBJECTFILE_H_
 #define OBJECTFILE_H_
 
-#include "target.h"
+#include "filetarget.h"
 
 class Component;
 class SourceFile;
@@ -16,16 +16,18 @@ class SourceFile;
 /**
 Object files are compiled from source files.
 */
-class ObjectFile: public Target
+class ObjectFile: public FileTarget
 {
 private:
        const Component &comp;
+       SourceFile &source;
        TargetList new_deps;
        
 public:
        ObjectFile(Builder &, const Component &, SourceFile &);
        virtual const char *get_type() const { return "ObjectFile"; }
        const Component &get_component() const { return comp; }
+       SourceFile &get_source() const { return source; }
 
        /** Processes as many new dependences as possible.  Some may be created on
        the fly and can't be processed until their own dependencies are ready.  In
@@ -41,7 +43,7 @@ private:
        void add_depend(Target *);
        virtual Action *create_action();
 
-       static std::string generate_target_name(const Component &, const std::string &);
+       static Msp::FS::Path generate_target_path(const Component &, const std::string &);
 };
 
 #endif
index b38da6a7e3f0b68cdb38daa343463d69b911ea39..5daf455d25c4e080c5b5159fdb4cad7e4e96f56f 100644 (file)
@@ -10,8 +10,7 @@ Distributed under the LGPL
 #include "pkgconfigaction.h"
 
 PkgConfig::PkgConfig(Builder &b, const SourcePackage &p):
-       Target(b, &p, (p.get_source()/(p.get_name()+".pc")).str()),
-       pkg(p)
+       FileTarget(b, &p, p.get_source()/(p.get_name()+".pc"))
 {
        buildable=true;
 }
index b4d4d3b9f0194c7b1cc874aaed0528502724853a..75280dc90d99820b46adf5d176058f6be7a4f7f1 100644 (file)
@@ -9,16 +9,13 @@ Distributed under the LGPL
 #define PKGCONFIG_H_
 
 #include "sourcepackage.h"
-#include "target.h"
+#include "filetarget.h"
 
 /**
 Creates a .pc file to enable other packages fetch build options with pkg-config.
 */
-class PkgConfig: public Target
+class PkgConfig: public FileTarget
 {
-private:
-       const Package &pkg;
-
 public:
        PkgConfig(Builder &, const SourcePackage &);
        virtual const char *get_type() const { return "PkgConfig"; }
index ddc6742c31b80a5538617b482a1eac4b442480dc..b21c6b74bde2e79664b19ae0836aa69953d451bf 100644 (file)
@@ -21,9 +21,9 @@ PkgConfigAction::PkgConfigAction(Builder &b, const PkgConfig &p):
 {
        const SourcePackage &spkg=*static_cast<const SourcePackage *>(p.get_package());
 
-       announce(spkg.get_name(), "PC", relative(p.get_name(), spkg.get_source()).str());
+       announce(spkg.get_name(), "PC", relative(p.get_path(), spkg.get_source()).str());
 
-       IO::BufferedFile out(p.get_name(), IO::M_WRITE);
+       IO::BufferedFile out(p.get_path().str(), IO::M_WRITE);
        // Prefix is already included in the various paths
        //IO::print(out, "prefix=%s\n", pkg.get_prefix());
        IO::print(out, "source=%s\n\n", spkg.get_source());
index 25034f3fcd0245bf1a8d848f81d8fba413744c09..5c2d26fea27f799521c6697fc3803db959ea23f4 100644 (file)
@@ -6,13 +6,13 @@ Distributed under the LGPL
 */
 
 #include "component.h"
-#include "package.h"
 #include "sharedlibrary.h"
+#include "sourcepackage.h"
 
 using namespace std;
 
 SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
-       Executable(b, c, objs),
-       libname(c.get_name())
+       FileTarget(b, &c.get_package(), generate_target_path(c)),
+       Binary(b, c, objs),
+       Library(b, &c.get_package(), path, c.get_name())
 { }
-
index f86fa814978804f73d7fef03a3d241de6f3734b8..13e358fe069f21def86727194abc8195aa21a76f 100644 (file)
@@ -8,21 +8,18 @@ Distributed under the LGPL
 #ifndef SHAREDLIB_H_
 #define SHAREDLIB_H_
 
-#include "executable.h"
+#include "binary.h"
+#include "library.h"
 
 /**
 Represents a shared library.  Mainly exists to give extra information to the
 user.
 */
-class SharedLibrary: public Executable
+class SharedLibrary: public Binary, public Library
 {
-private:
-       std::string libname;
-
 public:
        SharedLibrary(Builder &, const Component &, const std::list<ObjectFile *> &);
        virtual const char *get_type() const { return "SharedLibrary"; }
-       const std::string &get_libname() const { return libname; }
 };
 
 #endif
index 6c2cb760d763a8d8f949b40526b67c1cb88036f9..cadd1330e0bc94b2816e6b26268b5d0a195e5efb 100644 (file)
@@ -17,8 +17,8 @@ Distributed under the LGPL
 using namespace std;
 using namespace Msp;
 
-SourceFile::SourceFile(Builder &b, const Component *c, const string &n):
-       Target(b, c?&c->get_package():0, n),
+SourceFile::SourceFile(Builder &b, const Component *c, const FS::Path &p):
+       FileTarget(b, (c ? &c->get_package() : 0), p),
        comp(c)
 { }
 
@@ -68,7 +68,7 @@ void SourceFile::find_depends()
 
        const StringList &incpath=comp->get_build_info().incpath;
 
-       string path=name.substr(0, name.rfind('/'));
+       FS::Path dir=FS::dirname(path);
        for(list<string>::iterator i=includes.begin(); i!=includes.end(); ++i)
        {
                Target *hdr=builder.get_header(*i, path, incpath);
index ec81d2466a896885d5027f97112661a062ab9525..cbfd93428de9a09631c977b39adf18603e478af0 100644 (file)
@@ -8,21 +8,21 @@ Distributed under the LGPL
 #ifndef SOURCEFILE_H_
 #define SOURCEFILE_H_
 
-#include "target.h"
+#include "filetarget.h"
 
 class Component;
 
 /**
 Represents a C or C++ source file.
 */
-class SourceFile: public Target
+class SourceFile: public FileTarget
 {
 private:
        const Component *comp;
        StringList includes;
 
 public:
-       SourceFile(Builder &, const Component *, const std::string &);
+       SourceFile(Builder &, const Component *, const Msp::FS::Path &);
        virtual const char *get_type() const { return "SourceFile"; }
        const StringList &get_includes() const { return includes; }
        const Component *get_component() const { return comp; }
index a72f8e01fd478b5b97522d562f50e7af44fa9550..b7e4eff1d43941391393986f92c1acecd1bdab43 100644 (file)
@@ -13,8 +13,9 @@ Distributed under the LGPL
 
 using namespace std;
 
-StaticLibrary::StaticLibrary(Builder &b, const Component &c, const std::list<ObjectFile *> &objs):
-       Target(b, &c.get_package(), generate_target_name(c)),
+StaticLibrary::StaticLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
+       FileTarget(b, &c.get_package(), generate_target_path(c)),
+       Library(b, package, path, c.get_name()),
        comp(c)
 {
        buildable=true;
@@ -27,7 +28,7 @@ Action *StaticLibrary::create_action()
        return new Archive(builder, *this);
 }
 
-string StaticLibrary::generate_target_name(const Component &c)
+Msp::FS::Path StaticLibrary::generate_target_path(const Component &c)
 {
-       return (c.get_package().get_out_dir()/("lib"+c.get_name()+".a")).str();
+       return c.get_package().get_out_dir()/("lib"+c.get_name()+".a");
 }
index e3bd4e33be20c2e8c3a513d6917781a8acedc005..efd48338ba68ca548837ad89671ca1bc6731242f 100644 (file)
@@ -8,7 +8,7 @@ Distributed under the LGPL
 #ifndef STATICLIB_H_
 #define STATICLIB_H_
 
-#include "target.h"
+#include "library.h"
 
 class Component;
 class ObjectFile;
@@ -16,7 +16,7 @@ class ObjectFile;
 /**
 A static library target.
 */
-class StaticLibrary: public Target
+class StaticLibrary: public Library
 {
 private:
        const Component &comp;
@@ -28,7 +28,7 @@ public:
 private:
        virtual Action *create_action();
 
-       static std::string generate_target_name(const Component &);
+       static Msp::FS::Path generate_target_path(const Component &);
 };
 
 #endif
index 2df0eb54e89a663b8ef7cab5049a84030670026b..2bfc04bb6f870e30cc6f890cff86ac1510d6058e 100644 (file)
@@ -12,10 +12,15 @@ Distributed under the LGPL
 using namespace std;
 using namespace Msp;
 
-SystemLibrary::SystemLibrary(Builder &b, const string &n):
-       Target(b, 0, n)
+SystemLibrary::SystemLibrary(Builder &b, const Msp::FS::Path &p):
+       FileTarget(b, 0, p),
+       Library(b, 0, p, extract_libname(p))
+{ }
+
+string SystemLibrary::extract_libname(const Msp::FS::Path &p)
 {
-       libname=FS::basepart(FS::basename(n));
-       if(!libname.compare(0, 3, "lib"))
-               libname.erase(0, 3);
+       string result=FS::basepart(FS::basename(p));
+       if(!result.compare(0, 3, "lib"))
+               result.erase(0, 3);
+       return result;
 }
index c49c9e426d330351c58b245c2a26563dde4aee5c..9048a69aa21963948bf9a606dcf0fbdad820a8a4 100644 (file)
@@ -8,22 +8,20 @@ Distributed under the LGPL
 #ifndef SYSTEMLIBRARY_H_
 #define SYSTEMLIBRARY_H_
 
-#include "target.h"
+#include "library.h"
 
 /**
 A library that doesn't belong to any known package.
 */
-class SystemLibrary: public Target
+class SystemLibrary: public Library
 {
-private:
-       std::string libname;
-
 public:
-       SystemLibrary(Builder &, const std::string &);
+       SystemLibrary(Builder &, const Msp::FS::Path &);
        virtual const char *get_type() const { return "SystemLibrary"; }
-       const std::string &get_libname() const { return libname; }
 private:
        virtual Action *create_action() { return 0; }
+
+       static std::string extract_libname(const Msp::FS::Path &);
 };
 
 #endif
index 797bf240425e4fe78451376a55c6e7ecaca38b79..6f7b154feabba71b738c66623080d4d02b68c1a6 100644 (file)
@@ -22,7 +22,7 @@ Tar::Tar(Builder &b, const TarBall &t):
        InternalAction(b),
        tarball(t)
 {
-       string basename=tarball.get_name().substr(tarball.get_name().rfind('/')+1);
+       string basename=FS::basename(tarball.get_path());
        announce(tarball.get_package()->get_name(), "TAR ", basename);
        if(builder.get_verbose()>=2)
                cout<<"Create "<<basename<<'\n';
@@ -41,16 +41,20 @@ Tar::Worker::Worker(Tar &t):
 void Tar::Worker::main()
 {
        const FS::Path &pkg_src=tar.tarball.get_package()->get_source();
-       FS::Path basedir=FS::basepart(FS::basename(tar.tarball.get_name()));
+       FS::Path basedir=FS::basepart(FS::basename(tar.tarball.get_path()));
 
-       IO::File out(tar.tarball.get_name(), IO::M_WRITE);
+       IO::File out(tar.tarball.get_path().str(), IO::M_WRITE);
        const TargetList &deps=tar.tarball.get_depends();
        for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
        {
+               FileTarget *ft=dynamic_cast<FileTarget *>(*i);
+               if(!ft)
+                       continue;
+
                char buf[4096];
                memset(buf, 0, 512);
 
-               string rel_path=(basedir/relative((*i)->get_name(), pkg_src)).str();
+               string rel_path=(basedir/relative(ft->get_path(), pkg_src)).str();
                if(rel_path.size()>99)
                {
                        cout<<"Can't store "<<rel_path<<" in tar archive - too long name\n";
@@ -60,7 +64,7 @@ void Tar::Worker::main()
 
                memcpy(buf, rel_path.data(), rel_path.size());
 
-               struct stat st=FS::stat((*i)->get_name());
+               struct stat st=FS::stat(ft->get_path());
                store_number(buf+100, st.st_mode, 7);
                store_number(buf+108, st.st_uid, 7);
                store_number(buf+116, st.st_gid, 7);
@@ -76,7 +80,7 @@ void Tar::Worker::main()
                buf[155]=0;
 
                out.write(buf, 512);
-               IO::File in((*i)->get_name());
+               IO::File in(ft->get_path().str());
                for(int j=0; j<st.st_size; j+=4096)
                {
                        unsigned len=in.read(buf, 4096);
index a8d2ef84762b5f3a0302c407e80903c5a37d1734..d727590808777b58125b294666c3e5990fe7aa9f 100644 (file)
@@ -14,7 +14,7 @@ Distributed under the LGPL
 using namespace std;
 
 TarBall::TarBall(Builder &b, const SourcePackage &p, const string &ev):
-       Target(b, &p, create_target_name(p, ev))
+       FileTarget(b, &p, create_target_name(p, ev))
 {
        buildable=true;
 }
index c2fa288321720ca743d2c64485514a00780a7176..6b89ffc0269d02b082f02d6bc17fec52bc4dccab 100644 (file)
@@ -8,13 +8,10 @@ Distributed under the LGPL
 #ifndef TARBALL_H_
 #define TARBALL_H_
 
-#include "target.h"
+#include "filetarget.h"
 
-class TarBall: public Target
+class TarBall: public FileTarget
 {
-private:
-       std::string tarname;
-
 public:
        TarBall(Builder &, const SourcePackage &, const std::string & =std::string());
        virtual const char *get_type() const { return "TarBall"; }
index b24013aaf55eabb094c72ef912480a956c6a9ae8..38eaab59708440fb3d70bd3761ac4e793e53f321 100644 (file)
@@ -10,6 +10,7 @@ Distributed under the LGPL
 #include <msp/time/utils.h>
 #include "action.h"
 #include "builder.h"
+#include "filetarget.h"
 #include "package.h"
 #include "sourcepackage.h"
 #include "target.h"
@@ -29,10 +30,6 @@ Target::Target(Builder &b, const Package *p, const string &n):
        counted(false)
 {
        builder.add_target(this);
-
-       struct stat st;
-       if(!FS::stat(name, st))
-               mtime=Time::TimeStamp::from_unixtime(st.st_mtime);
 }
 
 Target *Target::get_buildable_target()
@@ -85,8 +82,9 @@ Action *Target::build()
                return 0;
        }
 
-       if(!builder.get_dry_run() && FS::exists(name))
-               FS::unlink(name);
+       if(FileTarget *ft=dynamic_cast<FileTarget *>(this))
+               if(!builder.get_dry_run() && FS::exists(ft->get_path()))
+                       FS::unlink(ft->get_path());
 
        Action *action=create_action();
        if(action)
index 208fcf9ff17b739307c38a1c8f39faebe5e7df99..458f5a904f7c5207837c23c33a59e57a868db435 100644 (file)
@@ -6,18 +6,18 @@ Distributed under the LGPL
 */
 
 #include <msp/fs/utils.h>
+#include "filetarget.h"
 #include "sourcepackage.h"
-#include "target.h"
 #include "unlink.h"
 
-Unlink::Unlink(Builder &b, const Target &t):
+Unlink::Unlink(Builder &b, const FileTarget &t):
        Action(b)
 {
        const SourcePackage &spkg=*static_cast<const SourcePackage *>(t.get_package());
 
-       announce(spkg.get_name(), "RM", relative(t.get_name(), spkg.get_source()).str());
+       announce(spkg.get_name(), "RM", relative(t.get_path(), spkg.get_source()).str());
 
-       unlink(t.get_name().c_str());
+       unlink(t.get_path());
 }
 
 int Unlink::check()
index f26d1637ac6f5ebcbcddb39b6afd357c2d98ac01..a26ca0eb5421b2e28d41cec390a4f93af2f49ac4 100644 (file)
@@ -10,12 +10,12 @@ Distributed under the LGPL
 
 #include "action.h"
 
-class Target;
+class FileTarget;
 
 class Unlink: public Action
 {
 public:
-       Unlink(Builder &, const Target &);
+       Unlink(Builder &, const FileTarget &);
        virtual int check();
 };