]> git.tdb.fi Git - builder.git/blobdiff - source/objectfile.cpp
Adjust to library changes
[builder.git] / source / objectfile.cpp
index 766188b5ad313bc73dd5e3db1660c36e637aa785..cd870592530f74b0220b6e5ed9692c090db16e8b 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$
 
 This file is part of builder
-Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
+Copyright © 2006-2010  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
@@ -19,7 +19,7 @@ using namespace std;
 using namespace Msp;
 
 ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s):
-       FileTarget(b, &c.get_package(), generate_target_path(c, FS::basename(s.get_path()))),
+       FileTarget(b, &c.get_package(), generate_target_path(c, FS::relative(s.get_path(), c.get_package().get_source()).str())),
        comp(c),
        source(s)       
 {
@@ -47,17 +47,9 @@ void ObjectFile::find_depends()
 
 void ObjectFile::find_depends(Target *tgt)
 {
-       SourceFile *src = dynamic_cast<SourceFile *>(tgt);
-       FileTarget *file = src;
-       if(!src)
-       {
-               if(Install *inst = dynamic_cast<Install *>(tgt))
-               {
-                       file = inst;
-                       src = dynamic_cast<SourceFile *>(&inst->get_source());
-               }
-       }
-       if(!src)
+       SourceFile *src = dynamic_cast<SourceFile *>(tgt->get_real_target());
+       FileTarget *file = dynamic_cast<FileTarget *>(tgt);
+       if(!src || !file)
                return;
 
        FS::Path spath = FS::dirname(file->get_path());
@@ -66,9 +58,9 @@ void ObjectFile::find_depends(Target *tgt)
        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, spath, incpath);
-               if(hdr2 && find(depends.begin(), depends.end(), hdr2)==depends.end())
-                       add_depend(hdr2);
+               Target *hdr = builder.get_header(*i, spath, incpath);
+               if(hdr && find(depends.begin(), depends.end(), hdr)==depends.end())
+                       add_depend(hdr);
        }
 }
 
@@ -86,5 +78,11 @@ Action *ObjectFile::create_action()
 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(src)+".o");
+       string fn = FS::basepart(src)+".o";
+       if(!fn.compare(0, 2, "./"))
+               fn.erase(0, 2);
+       for(string::iterator i=fn.begin(); i!=fn.end(); ++i)
+               if(*i=='/')
+                       *i = '_';
+       return pkg.get_temp_dir()/comp.get_name()/fn;
 }