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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 205 } |
206 | 206 |
207 return true; | 207 return true; |
208 } | 208 } |
209 | 209 |
210 } // namespace | 210 } // namespace |
211 | 211 |
212 Target::Target(const Settings* settings, const Label& label) | 212 Target::Target(const Settings* settings, const Label& label) |
213 : Item(settings, label), | 213 : Item(settings, label), |
214 output_type_(UNKNOWN), | 214 output_type_(UNKNOWN), |
| 215 output_prefix_override_(false), |
| 216 output_extension_set_(false), |
215 all_headers_public_(true), | 217 all_headers_public_(true), |
216 check_includes_(true), | 218 check_includes_(true), |
217 complete_static_lib_(false), | 219 complete_static_lib_(false), |
218 testonly_(false), | 220 testonly_(false), |
219 toolchain_(nullptr) { | 221 toolchain_(nullptr) { |
220 } | 222 } |
221 | 223 |
222 Target::~Target() { | 224 Target::~Target() { |
223 } | 225 } |
224 | 226 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 DepsIteratorRange Target::GetDeps(DepsIterationType type) const { | 353 DepsIteratorRange Target::GetDeps(DepsIterationType type) const { |
352 if (type == DEPS_LINKED) { | 354 if (type == DEPS_LINKED) { |
353 return DepsIteratorRange(DepsIterator( | 355 return DepsIteratorRange(DepsIterator( |
354 &public_deps_, &private_deps_, nullptr)); | 356 &public_deps_, &private_deps_, nullptr)); |
355 } | 357 } |
356 // All deps. | 358 // All deps. |
357 return DepsIteratorRange(DepsIterator( | 359 return DepsIteratorRange(DepsIterator( |
358 &public_deps_, &private_deps_, &data_deps_)); | 360 &public_deps_, &private_deps_, &data_deps_)); |
359 } | 361 } |
360 | 362 |
361 std::string Target::GetComputedOutputName(bool include_prefix) const { | 363 std::string Target::GetComputedOutputName() const { |
362 DCHECK(toolchain_) | 364 DCHECK(toolchain_) |
363 << "Toolchain must be specified before getting the computed output name."; | 365 << "Toolchain must be specified before getting the computed output name."; |
364 | 366 |
365 const std::string& name = output_name_.empty() ? label().name() | 367 const std::string& name = output_name_.empty() ? label().name() |
366 : output_name_; | 368 : output_name_; |
367 | 369 |
368 std::string result; | 370 std::string result; |
369 if (include_prefix) { | 371 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); |
370 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); | 372 if (tool) { |
371 if (tool) { | 373 // Only add the prefix if the name doesn't already have it and it's not |
372 // Only add the prefix if the name doesn't already have it. | 374 // being overridden. |
373 if (!base::StartsWith(name, tool->output_prefix(), | 375 if (!output_prefix_override_ && |
374 base::CompareCase::SENSITIVE)) | 376 !base::StartsWith(name, tool->output_prefix(), |
375 result = tool->output_prefix(); | 377 base::CompareCase::SENSITIVE)) |
376 } | 378 result = tool->output_prefix(); |
377 } | 379 } |
378 result.append(name); | 380 result.append(name); |
379 return result; | 381 return result; |
380 } | 382 } |
381 | 383 |
382 bool Target::SetToolchain(const Toolchain* toolchain, Err* err) { | 384 bool Target::SetToolchain(const Toolchain* toolchain, Err* err) { |
383 DCHECK(!toolchain_); | 385 DCHECK(!toolchain_); |
384 DCHECK_NE(UNKNOWN, output_type_); | 386 DCHECK_NE(UNKNOWN, output_type_); |
385 toolchain_ = toolchain; | 387 toolchain_ = toolchain; |
386 | 388 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 case BUNDLE_DATA: | 531 case BUNDLE_DATA: |
530 case CREATE_BUNDLE: | 532 case CREATE_BUNDLE: |
531 case SOURCE_SET: | 533 case SOURCE_SET: |
532 case COPY_FILES: | 534 case COPY_FILES: |
533 case ACTION: | 535 case ACTION: |
534 case ACTION_FOREACH: { | 536 case ACTION_FOREACH: { |
535 // These don't get linked to and use stamps which should be the first | 537 // These don't get linked to and use stamps which should be the first |
536 // entry in the outputs. These stamps are named | 538 // entry in the outputs. These stamps are named |
537 // "<target_out_dir>/<targetname>.stamp". | 539 // "<target_out_dir>/<targetname>.stamp". |
538 dependency_output_file_ = GetTargetOutputDirAsOutputFile(this); | 540 dependency_output_file_ = GetTargetOutputDirAsOutputFile(this); |
539 dependency_output_file_.value().append(GetComputedOutputName(true)); | 541 dependency_output_file_.value().append(GetComputedOutputName()); |
540 dependency_output_file_.value().append(".stamp"); | 542 dependency_output_file_.value().append(".stamp"); |
541 break; | 543 break; |
542 } | 544 } |
543 case EXECUTABLE: | 545 case EXECUTABLE: |
544 case LOADABLE_MODULE: | 546 case LOADABLE_MODULE: |
545 // Executables and loadable modules don't get linked to, but the first | 547 // Executables and loadable modules don't get linked to, but the first |
546 // output is used for dependency management. | 548 // output is used for dependency management. |
547 CHECK_GE(tool->outputs().list().size(), 1u); | 549 CHECK_GE(tool->outputs().list().size(), 1u); |
548 check_tool_outputs = true; | 550 check_tool_outputs = true; |
549 dependency_output_file_ = | 551 dependency_output_file_ = |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 check_data_deps = g_scheduler->IsFileGeneratedByWriteRuntimeDeps(out_file); | 779 check_data_deps = g_scheduler->IsFileGeneratedByWriteRuntimeDeps(out_file); |
778 // Check object files (much slower and very rare) only if the "normal" | 780 // Check object files (much slower and very rare) only if the "normal" |
779 // output check failed. | 781 // output check failed. |
780 consider_object_files = !check_data_deps; | 782 consider_object_files = !check_data_deps; |
781 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, | 783 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, |
782 consider_object_files, | 784 consider_object_files, |
783 check_data_deps, &seen_targets)) | 785 check_data_deps, &seen_targets)) |
784 g_scheduler->AddUnknownGeneratedInput(this, source); | 786 g_scheduler->AddUnknownGeneratedInput(this, source); |
785 } | 787 } |
786 } | 788 } |
OLD | NEW |