X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fobjectfile.cpp;h=97e52552b8d553ae3d360245a56bd15a440efc91;hb=766dad2d4f7ca73dc182f22e306ba0def6fd8722;hp=ea4421674b0632372e5bddfb8ae5f18782ec9c56;hpb=69cdee2c53972c1dd7e1b9d83ddcd8f6c3c589f7;p=builder.git diff --git a/source/objectfile.cpp b/source/objectfile.cpp index ea44216..97e5255 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -10,23 +10,26 @@ 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::relative(s.get_path(), c.get_package().get_source_directory()).str())), + FileTarget(b, c.get_package(), generate_target_path(c, s.get_path())), source(s) { component = &c; add_dependency(source); } -FS::Path ObjectFile::generate_target_path(const Component &comp, const string &src) +FS::Path ObjectFile::generate_target_path(const Component &comp, const FS::Path &src) { const SourcePackage &pkg = comp.get_package(); - 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; + FS::Path rel_src = FS::relative(src, pkg.get_source_directory()).str(); + string fn; + for(FS::Path::Iterator i=rel_src.begin(); i!=rel_src.end(); ++i) + { + if(!fn.empty()) + fn += '_'; + if(*i!=".") + fn += *i; + } + return pkg.get_temp_directory()/comp.get_name()/(FS::basepart(fn)+".o"); } void ObjectFile::find_dependencies()