#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)