-#include <algorithm>
+#include <msp/core/algorithm.h>
#include "builder.h"
#include "file.h"
#include "sourcearchivecomponent.h"
#include "tool.h"
using namespace std;
+using namespace Msp;
SourceArchiveComponent::SourceArchiveComponent(SourcePackage &p):
Component(p, p.get_name()+"-source")
list<Target *> files;
files.insert(files.begin(), &package.get_build_file());
- SourceList source_filenames = collect_source_files();
- for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+ for(const FS::Path &s: collect_source_files())
{
- FileTarget *file = builder.get_vfs().get_target(*i);
+ FileTarget *file = builder.get_vfs().get_target(s);
if(!file)
- file = new File(builder, package, *i);
+ file = new File(builder, package, s);
files.push_back(file);
}
BuildGraph &build_graph = builder.get_build_graph();
- const BuildGraph::TargetMap &targets = build_graph.get_targets();
- for(BuildGraph::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i)
- if(i->second->get_package()==&package && !i->second->is_buildable())
- if(find(files.begin(), files.end(), i->second)==files.end())
- files.push_back(i->second);
+ for(const auto &kvp: build_graph.get_targets())
+ if(kvp.second->get_package()==&package && !kvp.second->is_buildable())
+ if(!any_equals(files, kvp.second))
+ files.push_back(kvp.second);
const Toolchain &toolchain = builder.get_toolchain();
- string archive_name = package.get_name()+"-"+package.get_version()+"-source";
+ string archive_name = package.get_name();
+ if(!package.get_version().empty())
+ archive_name += "-"+package.get_version();
+ archive_name += "-source";
Target *result = toolchain.get_tool("TAR").create_target(files, archive_name);
build_graph.get_target("archives")->add_dependency(*result);
}