+vector<FileTarget *> BinaryComponent::create_sources() const
+{
+ const Toolchain &toolchain = package.get_builder().get_toolchain();
+ const Toolchain &pkg_tools = package.get_toolchain();
+
+ vector<FileTarget *> targets;
+ for(const FS::Path &s: collect_source_files())
+ {
+ string ext = FS::extpart(FS::basename(s));
+ Target *src = 0;
+
+ Tool *tool = pkg_tools.get_tool_for_suffix(ext, true);
+ if(tool)
+ src = tool->create_source(*this, s);
+ if(!src)
+ {
+ tool = toolchain.get_tool_for_suffix(ext, true);
+ if(tool)
+ src = tool->create_source(*this, s);
+ }
+
+ if(FileTarget *file = dynamic_cast<FileTarget *>(src))
+ {
+ targets.push_back(file);
+ if(type==LIBRARY && install)
+ create_install(*file);
+ }
+ }
+
+ return targets;
+}
+
+vector<Target *> BinaryComponent::extract_group(vector<FileTarget *> &targets, const Tool &tool)
+{
+ Tool::ProcessingUnit processing_unit = tool.get_processing_unit();
+ vector<Target *> group;
+ FS::Path group_dir;
+ for(auto i=targets.begin(); i!=targets.end(); )
+ {
+ const FS::Path &path = (*i)->get_path();
+ string ext = FS::extpart(FS::basename(path));
+ FS::Path dir = FS::dirname(path);
+ if(tool.accepts_suffix(ext) && (processing_unit!=Tool::DIRECTORY || group.empty() || dir==group_dir))
+ {
+ group.push_back(*i);
+ group_dir = dir;
+ i = targets.erase(i);
+ }
+ else
+ ++i;
+ }
+
+ return group;
+}
+
+void BinaryComponent::create_install(FileTarget &target) const
+{
+ BuildGraph &build_graph = package.get_builder().get_build_graph();
+
+ if(target.is_installable())
+ build_graph.add_installed_target(target);
+
+ for(Target *s: target.get_side_effects())
+ if(dynamic_cast<FileTarget &>(*s).is_installable())
+ build_graph.add_installed_target(*s);
+}
+
+