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)
{
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;
}