broken |= r->is_broken();
}
+ if(!sources.empty())
+ {
+ for(auto i=sources.begin(); i!=sources.end(); ++i)
+ {
+ FS::Path s = *i;
+ if(!FS::is_dir(s))
+ s = FS::dirname(s);
+
+ if(i==sources.begin())
+ source_base_path = s;
+ else
+ source_base_path = FS::common_ancestor(source_base_path, s);
+ }
+ }
+
if(!problems.empty())
broken = true;
}
if(FS::descendant_depth(source, temp_dir)>=0)
rel_src = FS::relative(source, temp_dir);
else
- rel_src = FS::relative(source, package.get_source_directory());
+ rel_src = FS::relative(source, source_base_path);
string fn;
for(const string &c: rel_src)
#include <msp/fs/utils.h>
#include <msp/strings/format.h>
+#include <msp/strings/utils.h>
#include "builder.h"
#include "executable.h"
#include "sourcegenerator.h"
TemplateFile &tmpl = dynamic_cast<TemplateFile &>(*sources.front());
const Component *comp = tmpl.get_component();
- const SourcePackage *pkg = tmpl.get_package();
- FS::Path subdir;
+ string subdir = "generated";
string base;
if(processing_unit==COMPONENT)
base = comp->get_name();
else
{
- subdir = FS::dirname(FS::relative(tmpl.get_path(), pkg->get_source_directory()));
+ string flat_dir = comp->flatten_source_path(FS::dirname(tmpl.get_path()));
if(processing_unit==ONE_FILE)
- base = FS::basepart(FS::basename(tmpl.get_path()));
- else if(processing_unit==DIRECTORY)
{
- base = FS::basename(subdir);
- subdir = FS::dirname(subdir);
+ append(subdir, "_", flat_dir);
+ base = FS::basepart(FS::basename(tmpl.get_path()));
}
+ else if(processing_unit==DIRECTORY)
+ base = flat_dir;
}
Target *primary = 0;
Tool *tool = builder.get_toolchain().get_tool_for_suffix(s, true);
if(tool)
{
- FS::Path fn = pkg->get_temp_directory()/"generated"/subdir/(base+s);
+ FS::Path fn = comp->get_temp_directory()/subdir/(base+s);
Target *target = tool->create_source(*comp, fn);
target->set_tool(*this);
for(Target *t: sources)