]> git.tdb.fi Git - builder.git/blobdiff - source/sourcearchivecomponent.cpp
Use shortcut functions for find calls
[builder.git] / source / sourcearchivecomponent.cpp
index 6dc5fe6caa2a6dd96d88736d45a1f1a430aa9839..027debcf2881200ad536fdd9a2d8be81c6989886 100644 (file)
@@ -1,4 +1,4 @@
-#include <algorithm>
+#include <msp/core/algorithm.h>
 #include "builder.h"
 #include "file.h"
 #include "sourcearchivecomponent.h"
@@ -6,6 +6,7 @@
 #include "tool.h"
 
 using namespace std;
+using namespace Msp;
 
 SourceArchiveComponent::SourceArchiveComponent(SourcePackage &p):
        Component(p, p.get_name()+"-source")
@@ -18,24 +19,25 @@ void SourceArchiveComponent::create_targets() const
        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);
 }