| 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/target.h" | 5 #include "tools/gn/target.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "tools/gn/config_values_extractors.h" | 10 #include "tools/gn/config_values_extractors.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 } // namespace | 104 } // namespace |
| 105 | 105 |
| 106 Target::Target(const Settings* settings, const Label& label) | 106 Target::Target(const Settings* settings, const Label& label) |
| 107 : Item(settings, label), | 107 : Item(settings, label), |
| 108 output_type_(UNKNOWN), | 108 output_type_(UNKNOWN), |
| 109 all_headers_public_(true), | 109 all_headers_public_(true), |
| 110 check_includes_(true), | 110 check_includes_(true), |
| 111 complete_static_lib_(false), | 111 complete_static_lib_(false), |
| 112 testonly_(false), | 112 testonly_(false), |
| 113 darwin_bundle_(false), |
| 113 toolchain_(nullptr) { | 114 toolchain_(nullptr) { |
| 114 } | 115 } |
| 115 | 116 |
| 116 Target::~Target() { | 117 Target::~Target() { |
| 117 } | 118 } |
| 118 | 119 |
| 119 // static | 120 // static |
| 120 const char* Target::GetStringForOutputType(OutputType type) { | 121 const char* Target::GetStringForOutputType(OutputType type) { |
| 121 switch (type) { | 122 switch (type) { |
| 122 case UNKNOWN: | 123 case UNKNOWN: |
| 123 return "Unknown"; | 124 return "Unknown"; |
| 124 case GROUP: | 125 case GROUP: |
| 125 return "Group"; | 126 return "Group"; |
| 126 case EXECUTABLE: | 127 case EXECUTABLE: |
| 127 return "Executable"; | 128 return "Executable"; |
| 129 case LOADABLE_MODULE: |
| 130 return "Loadable module"; |
| 128 case SHARED_LIBRARY: | 131 case SHARED_LIBRARY: |
| 129 return "Shared library"; | 132 return "Shared library"; |
| 130 case STATIC_LIBRARY: | 133 case STATIC_LIBRARY: |
| 131 return "Static library"; | 134 return "Static library"; |
| 132 case SOURCE_SET: | 135 case SOURCE_SET: |
| 133 return "Source set"; | 136 return "Source set"; |
| 134 case COPY_FILES: | 137 case COPY_FILES: |
| 135 return "Copy"; | 138 return "Copy"; |
| 136 case ACTION: | 139 case ACTION: |
| 137 return "Action"; | 140 return "Action"; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 189 } |
| 187 | 190 |
| 188 return true; | 191 return true; |
| 189 } | 192 } |
| 190 | 193 |
| 191 bool Target::IsLinkable() const { | 194 bool Target::IsLinkable() const { |
| 192 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; | 195 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; |
| 193 } | 196 } |
| 194 | 197 |
| 195 bool Target::IsFinal() const { | 198 bool Target::IsFinal() const { |
| 196 return output_type_ == EXECUTABLE || output_type_ == SHARED_LIBRARY || | 199 return output_type_ == EXECUTABLE || |
| 200 output_type_ == SHARED_LIBRARY || |
| 201 output_type_ == LOADABLE_MODULE || |
| 197 (output_type_ == STATIC_LIBRARY && complete_static_lib_); | 202 (output_type_ == STATIC_LIBRARY && complete_static_lib_); |
| 198 } | 203 } |
| 199 | 204 |
| 200 DepsIteratorRange Target::GetDeps(DepsIterationType type) const { | 205 DepsIteratorRange Target::GetDeps(DepsIterationType type) const { |
| 201 if (type == DEPS_LINKED) { | 206 if (type == DEPS_LINKED) { |
| 202 return DepsIteratorRange(DepsIterator( | 207 return DepsIteratorRange(DepsIterator( |
| 203 &public_deps_, &private_deps_, nullptr)); | 208 &public_deps_, &private_deps_, nullptr)); |
| 204 } | 209 } |
| 205 // All deps. | 210 // All deps. |
| 206 return DepsIteratorRange(DepsIterator( | 211 return DepsIteratorRange(DepsIterator( |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 case ACTION_FOREACH: { | 348 case ACTION_FOREACH: { |
| 344 // These don't get linked to and use stamps which should be the first | 349 // These don't get linked to and use stamps which should be the first |
| 345 // entry in the outputs. These stamps are named | 350 // entry in the outputs. These stamps are named |
| 346 // "<target_out_dir>/<targetname>.stamp". | 351 // "<target_out_dir>/<targetname>.stamp". |
| 347 dependency_output_file_ = GetTargetOutputDirAsOutputFile(this); | 352 dependency_output_file_ = GetTargetOutputDirAsOutputFile(this); |
| 348 dependency_output_file_.value().append(GetComputedOutputName(true)); | 353 dependency_output_file_.value().append(GetComputedOutputName(true)); |
| 349 dependency_output_file_.value().append(".stamp"); | 354 dependency_output_file_.value().append(".stamp"); |
| 350 break; | 355 break; |
| 351 } | 356 } |
| 352 case EXECUTABLE: | 357 case EXECUTABLE: |
| 353 // Executables don't get linked to, but the first output is used for | 358 case LOADABLE_MODULE: |
| 354 // dependency management. | 359 // Executables and loadable modules don't get linked to, but the first |
| 360 // output is used for dependency management. |
| 355 CHECK_GE(tool->outputs().list().size(), 1u); | 361 CHECK_GE(tool->outputs().list().size(), 1u); |
| 356 check_tool_outputs = true; | 362 check_tool_outputs = true; |
| 357 dependency_output_file_ = | 363 dependency_output_file_ = |
| 358 SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( | 364 SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( |
| 359 this, tool, tool->outputs().list()[0]); | 365 this, tool, tool->outputs().list()[0]); |
| 360 break; | 366 break; |
| 361 case STATIC_LIBRARY: | 367 case STATIC_LIBRARY: |
| 362 // Static libraries both have dependencies and linking going off of the | 368 // Static libraries both have dependencies and linking going off of the |
| 363 // first output. | 369 // first output. |
| 364 CHECK(tool->outputs().list().size() >= 1); | 370 CHECK(tool->outputs().list().size() >= 1); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 return; // Not in output dir, this is OK. | 543 return; // Not in output dir, this is OK. |
| 538 | 544 |
| 539 // Tell the scheduler about unknown files. This will be noted for later so | 545 // Tell the scheduler about unknown files. This will be noted for later so |
| 540 // the list of files written by the GN build itself (often response files) | 546 // the list of files written by the GN build itself (often response files) |
| 541 // can be filtered out of this list. | 547 // can be filtered out of this list. |
| 542 OutputFile out_file(settings()->build_settings(), source); | 548 OutputFile out_file(settings()->build_settings(), source); |
| 543 std::set<const Target*> seen_targets; | 549 std::set<const Target*> seen_targets; |
| 544 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, &seen_targets)) | 550 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, &seen_targets)) |
| 545 g_scheduler->AddUnknownGeneratedInput(this, source); | 551 g_scheduler->AddUnknownGeneratedInput(this, source); |
| 546 } | 552 } |
| OLD | NEW |