From c9a64955c551ad341f07505262d0e6ff9fb93a2c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 3 Oct 2013 11:09:26 +0300 Subject: [PATCH] Generate shorter object file names for generated source files --- source/objectfile.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/objectfile.cpp b/source/objectfile.cpp index 7208f42..27883bb 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -20,7 +20,12 @@ ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s): FS::Path ObjectFile::generate_target_path(const Component &comp, const FS::Path &src) { const SourcePackage &pkg = comp.get_package(); - FS::Path rel_src = FS::relative(src, pkg.get_source_directory()).str(); + FS::Path temp_dir = pkg.get_temp_directory()/comp.get_name(); + FS::Path rel_src; + if(FS::descendant_depth(src, temp_dir)>=0) + rel_src = FS::relative(src, temp_dir); + else + rel_src = FS::relative(src, pkg.get_source_directory()); string fn; for(FS::Path::Iterator i=rel_src.begin(); i!=rel_src.end(); ++i) { @@ -29,7 +34,7 @@ FS::Path ObjectFile::generate_target_path(const Component &comp, const FS::Path if(*i!=".") fn += *i; } - return pkg.get_temp_directory()/comp.get_name()/(FS::basepart(fn)+".o"); + return temp_dir/(FS::basepart(fn)+".o"); } void ObjectFile::find_dependencies() -- 2.45.2