]> git.tdb.fi Git - builder.git/blobdiff - source/filetarget.cpp
Don't store component locally in object and source files
[builder.git] / source / filetarget.cpp
index 6626db8ded177b79ed8ecd1f0b8bd5a81f3bf456..634b297b996070e45ed9a98ee736c6e9f4826718 100644 (file)
@@ -9,7 +9,7 @@
 using namespace std;
 using namespace Msp;
 
-FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a):
+FileTarget::FileTarget(Builder &b, const SourcePackage *p, const FS::Path &a):
        Target(b, generate_name(p, a)),
        path(a),
        size(0)
@@ -25,6 +25,25 @@ FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a):
        }
 }
 
+string FileTarget::generate_name(const SourcePackage *pkg, const FS::Path &pth)
+{
+       if(pkg)
+       {
+               if(FS::descendant_depth(pth, pkg->get_source())>=0)
+               {
+                       FS::Path relpath = FS::relative(pth, pkg->get_source());
+                       return format("<%s>%s", pkg->get_name(), relpath.str().substr(1));
+               }
+               else if(FS::descendant_depth(pth, pkg->get_builder().get_prefix())>=0)
+               {
+                       FS::Path relpath = FS::relative(pth, pkg->get_builder().get_prefix());
+                       return "<prefix>"+relpath.str().substr(1);
+               }
+       }
+
+       return pth.str();
+}
+
 void FileTarget::touch()
 {
        mtime = Time::now();
@@ -50,26 +69,6 @@ void FileTarget::check_rebuild()
                }
        }
 
-       const SourcePackage *spkg = dynamic_cast<const SourcePackage *>(package);
-       if(!needs_rebuild() && spkg && spkg->get_config().get_mtime()>mtime)
+       if(!needs_rebuild() && package && package->get_config().get_mtime()>mtime)
                mark_rebuild("Package options changed");
 }
-
-string FileTarget::generate_name(const Package *pkg, const FS::Path &pth)
-{
-       if(const SourcePackage *spkg = dynamic_cast<const SourcePackage *>(pkg))
-       {
-               if(FS::descendant_depth(pth, spkg->get_source())>=0)
-               {
-                       FS::Path relpath = FS::relative(pth, spkg->get_source());
-                       return format("<%s>%s", pkg->get_name(), relpath.str().substr(1));
-               }
-               else if(FS::descendant_depth(pth, pkg->get_builder().get_prefix())>=0)
-               {
-                       FS::Path relpath = FS::relative(pth, pkg->get_builder().get_prefix());
-                       return "<prefix>"+relpath.str().substr(1);
-               }
-       }
-
-       return pth.str();
-}