| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 "\n" | 49 "\n" |
| 50 " If no placeholders are found, the outputs or args list will be treated\n" | 50 " If no placeholders are found, the outputs or args list will be treated\n" |
| 51 " as a static list of literal file names that do not depend on the\n" | 51 " as a static list of literal file names that do not depend on the\n" |
| 52 " sources.\n" | 52 " sources.\n" |
| 53 "\n" | 53 "\n" |
| 54 " See \"gn help copy\" and \"gn help action_foreach\" for more on how\n" | 54 " See \"gn help copy\" and \"gn help action_foreach\" for more on how\n" |
| 55 " this is applied.\n" | 55 " this is applied.\n" |
| 56 "\n" | 56 "\n" |
| 57 "Placeholders\n" | 57 "Placeholders\n" |
| 58 "\n" | 58 "\n" |
| 59 " This section discusses only placeholders for actions. There are other\n" |
| 60 " placeholders used in the definition of tools. See \"gn help tool\" for\n" |
| 61 " those.\n" |
| 62 "\n" |
| 59 " {{source}}\n" | 63 " {{source}}\n" |
| 60 " The name of the source file including directory (*). This will\n" | 64 " The name of the source file including directory (*). This will\n" |
| 61 " generally be used for specifying inputs to a script in the\n" | 65 " generally be used for specifying inputs to a script in the\n" |
| 62 " \"args\" variable.\n" | 66 " \"args\" variable.\n" |
| 63 " \"//foo/bar/baz.txt\" => \"../../foo/bar/baz.txt\"\n" | 67 " \"//foo/bar/baz.txt\" => \"../../foo/bar/baz.txt\"\n" |
| 64 "\n" | 68 "\n" |
| 65 " {{source_file_part}}\n" | 69 " {{source_file_part}}\n" |
| 66 " The file part of the source including the extension.\n" | 70 " The file part of the source including the extension.\n" |
| 67 " \"//foo/bar/baz.txt\" => \"baz.txt\"\n" | 71 " \"//foo/bar/baz.txt\" => \"baz.txt\"\n" |
| 68 "\n" | 72 "\n" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 const Target* target, | 543 const Target* target, |
| 540 const Tool* tool, | 544 const Tool* tool, |
| 541 SubstitutionType type) { | 545 SubstitutionType type) { |
| 542 // First try the common tool ones. | 546 // First try the common tool ones. |
| 543 std::string result; | 547 std::string result; |
| 544 if (GetTargetSubstitution(target, type, &result)) | 548 if (GetTargetSubstitution(target, type, &result)) |
| 545 return result; | 549 return result; |
| 546 | 550 |
| 547 // Fall-through to the linker-specific ones. | 551 // Fall-through to the linker-specific ones. |
| 548 switch (type) { | 552 switch (type) { |
| 553 case SUBSTITUTION_OUTPUT_DIR: |
| 554 // Use the target's value if there is one (it will have no expansion |
| 555 // patterns since it can directly use GN variables to compute whatever |
| 556 // path it wants), or the tool's default (which will contain further |
| 557 // expansions). |
| 558 if (target->output_dir().is_null()) { |
| 559 return ApplyPatternToLinkerAsOutputFile( |
| 560 target, tool, tool->default_output_dir()).value(); |
| 561 } else { |
| 562 SetDirOrDotWithNoSlash(RebasePath( |
| 563 target->output_dir().value(), |
| 564 target->settings()->build_settings()->build_dir()), |
| 565 &result); |
| 566 return result; |
| 567 } |
| 568 break; |
| 569 |
| 549 case SUBSTITUTION_OUTPUT_EXTENSION: | 570 case SUBSTITUTION_OUTPUT_EXTENSION: |
| 550 // Use the extension provided on the target if specified, otherwise | 571 // Use the extension provided on the target if specified, otherwise |
| 551 // fall back on the default. Note that the target's output extension | 572 // fall back on the default. Note that the target's output extension |
| 552 // does not include the dot but the tool's does. | 573 // does not include the dot but the tool's does. |
| 553 if (!target->output_extension_set()) | 574 if (!target->output_extension_set()) |
| 554 return tool->default_output_extension(); | 575 return tool->default_output_extension(); |
| 555 if (target->output_extension().empty()) | 576 if (target->output_extension().empty()) |
| 556 return std::string(); // Explicitly set to no extension. | 577 return std::string(); // Explicitly set to no extension. |
| 557 return std::string(".") + target->output_extension(); | 578 return std::string(".") + target->output_extension(); |
| 558 | 579 |
| 559 default: | 580 default: |
| 560 NOTREACHED(); | 581 NOTREACHED(); |
| 561 return std::string(); | 582 return std::string(); |
| 562 } | 583 } |
| 563 } | 584 } |
| OLD | NEW |