| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/gn/ninja_target_writer.h" | 5 #include "tools/gn/ninja_target_writer.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "tools/gn/dereference_comparator.h" |
| 11 #include "tools/gn/err.h" | 12 #include "tools/gn/err.h" |
| 12 #include "tools/gn/escape.h" | 13 #include "tools/gn/escape.h" |
| 13 #include "tools/gn/filesystem_utils.h" | 14 #include "tools/gn/filesystem_utils.h" |
| 14 #include "tools/gn/ninja_action_target_writer.h" | 15 #include "tools/gn/ninja_action_target_writer.h" |
| 15 #include "tools/gn/ninja_binary_target_writer.h" | 16 #include "tools/gn/ninja_binary_target_writer.h" |
| 16 #include "tools/gn/ninja_copy_target_writer.h" | 17 #include "tools/gn/ninja_copy_target_writer.h" |
| 17 #include "tools/gn/ninja_group_target_writer.h" | 18 #include "tools/gn/ninja_group_target_writer.h" |
| 18 #include "tools/gn/ninja_utils.h" | 19 #include "tools/gn/ninja_utils.h" |
| 19 #include "tools/gn/output_file.h" | 20 #include "tools/gn/output_file.h" |
| 20 #include "tools/gn/scheduler.h" | 21 #include "tools/gn/scheduler.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 path_output_.WriteFile(out_, input); | 201 path_output_.WriteFile(out_, input); |
| 201 } | 202 } |
| 202 if (list_sources_as_input_deps) { | 203 if (list_sources_as_input_deps) { |
| 203 for (const auto& source : target_->sources()) { | 204 for (const auto& source : target_->sources()) { |
| 204 out_ << " "; | 205 out_ << " "; |
| 205 path_output_.WriteFile(out_, source); | 206 path_output_.WriteFile(out_, source); |
| 206 } | 207 } |
| 207 } | 208 } |
| 208 | 209 |
| 209 // The different souces of input deps may duplicate some targets, so uniquify | 210 // The different souces of input deps may duplicate some targets, so uniquify |
| 210 // them (ordering doesn't matter for this case). | 211 // them. Note that the order matters, or the output is non-deterministic. |
| 211 std::set<const Target*> unique_deps; | 212 PointerSet<const Target> unique_deps; |
| 212 | 213 |
| 213 // Hard dependencies that are direct or indirect dependencies. | 214 // Hard dependencies that are direct or indirect dependencies. |
| 214 const std::set<const Target*>& hard_deps = target_->recursive_hard_deps(); | 215 const PointerSet<const Target>& hard_deps = target_->recursive_hard_deps(); |
| 215 for (const auto& dep : hard_deps) | |
| 216 unique_deps.insert(dep); | |
| 217 | 216 |
| 217 unique_deps.insert(hard_deps.begin(), hard_deps.end()); |
| 218 // Extra hard dependencies passed in. | 218 // Extra hard dependencies passed in. |
| 219 unique_deps.insert(extra_hard_deps.begin(), extra_hard_deps.end()); | 219 unique_deps.insert(extra_hard_deps.begin(), extra_hard_deps.end()); |
| 220 | 220 |
| 221 // Toolchain dependencies. These must be resolved before doing anything. | 221 // Toolchain dependencies. These must be resolved before doing anything. |
| 222 // This just writs all toolchain deps for simplicity. If we find that | 222 // This just writs all toolchain deps for simplicity. If we find that |
| 223 // toolchains often have more than one dependency, we could consider writing | 223 // toolchains often have more than one dependency, we could consider writing |
| 224 // a toolchain-specific stamp file and only include the stamp here. | 224 // a toolchain-specific stamp file and only include the stamp here. |
| 225 const LabelTargetVector& toolchain_deps = target_->toolchain()->deps(); | 225 const LabelTargetVector& toolchain_deps = target_->toolchain()->deps(); |
| 226 for (const auto& toolchain_dep : toolchain_deps) | 226 for (const auto& toolchain_dep : toolchain_deps) |
| 227 unique_deps.insert(toolchain_dep.ptr); | 227 unique_deps.insert(toolchain_dep.ptr); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 255 << GetNinjaRulePrefixForToolchain(settings_) | 255 << GetNinjaRulePrefixForToolchain(settings_) |
| 256 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); | 256 << Toolchain::ToolTypeToName(Toolchain::TYPE_STAMP); |
| 257 path_output_.WriteFiles(out_, files); | 257 path_output_.WriteFiles(out_, files); |
| 258 | 258 |
| 259 if (!order_only_deps.empty()) { | 259 if (!order_only_deps.empty()) { |
| 260 out_ << " ||"; | 260 out_ << " ||"; |
| 261 path_output_.WriteFiles(out_, order_only_deps); | 261 path_output_.WriteFiles(out_, order_only_deps); |
| 262 } | 262 } |
| 263 out_ << std::endl; | 263 out_ << std::endl; |
| 264 } | 264 } |
| OLD | NEW |