OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/substitution_writer.h" | 5 #include "tools/gn/substitution_writer.h" |
6 | 6 |
7 #include "tools/gn/build_settings.h" | 7 #include "tools/gn/build_settings.h" |
8 #include "tools/gn/escape.h" | 8 #include "tools/gn/escape.h" |
9 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
10 #include "tools/gn/output_file.h" | 10 #include "tools/gn/output_file.h" |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 SetDirOrDotWithNoSlash( | 441 SetDirOrDotWithNoSlash( |
442 GetTargetGenDirAsOutputFile(target).value(), | 442 GetTargetGenDirAsOutputFile(target).value(), |
443 result); | 443 result); |
444 break; | 444 break; |
445 case SUBSTITUTION_TARGET_OUT_DIR: | 445 case SUBSTITUTION_TARGET_OUT_DIR: |
446 SetDirOrDotWithNoSlash( | 446 SetDirOrDotWithNoSlash( |
447 GetTargetOutputDirAsOutputFile(target).value(), | 447 GetTargetOutputDirAsOutputFile(target).value(), |
448 result); | 448 result); |
449 break; | 449 break; |
450 case SUBSTITUTION_TARGET_OUTPUT_NAME: | 450 case SUBSTITUTION_TARGET_OUTPUT_NAME: |
451 *result = target->GetComputedOutputName(true); | 451 *result = target->GetComputedOutputName(); |
452 break; | 452 break; |
453 default: | 453 default: |
454 return false; | 454 return false; |
455 } | 455 } |
456 return true; | 456 return true; |
457 } | 457 } |
458 | 458 |
459 // static | 459 // static |
460 std::string SubstitutionWriter::GetTargetSubstitution( | 460 std::string SubstitutionWriter::GetTargetSubstitution( |
461 const Target* target, | 461 const Target* target, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 const Tool* tool, | 540 const Tool* tool, |
541 SubstitutionType type) { | 541 SubstitutionType type) { |
542 // First try the common tool ones. | 542 // First try the common tool ones. |
543 std::string result; | 543 std::string result; |
544 if (GetTargetSubstitution(target, type, &result)) | 544 if (GetTargetSubstitution(target, type, &result)) |
545 return result; | 545 return result; |
546 | 546 |
547 // Fall-through to the linker-specific ones. | 547 // Fall-through to the linker-specific ones. |
548 switch (type) { | 548 switch (type) { |
549 case SUBSTITUTION_OUTPUT_EXTENSION: | 549 case SUBSTITUTION_OUTPUT_EXTENSION: |
550 // Use the extension provided on the target if nonempty, otherwise | 550 // Use the extension provided on the target if specified, otherwise |
551 // fall back on the default. Note that the target's output extension | 551 // fall back on the default. Note that the target's output extension |
552 // does not include the dot but the tool's does. | 552 // does not include the dot but the tool's does. |
| 553 if (!target->output_extension_set()) |
| 554 return tool->default_output_extension(); |
553 if (target->output_extension().empty()) | 555 if (target->output_extension().empty()) |
554 return tool->default_output_extension(); | 556 return std::string(); // Explicitly set to no extension. |
555 return std::string(".") + target->output_extension(); | 557 return std::string(".") + target->output_extension(); |
556 | 558 |
557 default: | 559 default: |
558 NOTREACHED(); | 560 NOTREACHED(); |
559 return std::string(); | 561 return std::string(); |
560 } | 562 } |
561 } | 563 } |
OLD | NEW |