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 <algorithm> | 5 #include <algorithm> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "tools/gn/err.h" | 8 #include "tools/gn/err.h" |
9 #include "tools/gn/functions.h" | 9 #include "tools/gn/functions.h" |
10 #include "tools/gn/parse_tree.h" | 10 #include "tools/gn/parse_tree.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 if (value->string_value()[0] != '.') { | 108 if (value->string_value()[0] != '.') { |
109 *err = Err(*value, "default_output_extension must begin with a '.'"); | 109 *err = Err(*value, "default_output_extension must begin with a '.'"); |
110 return false; | 110 return false; |
111 } | 111 } |
112 | 112 |
113 tool->set_default_output_extension(value->string_value()); | 113 tool->set_default_output_extension(value->string_value()); |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
| 117 bool ReadPrecompiledHeaderType(Scope* scope, Tool* tool, Err* err) { |
| 118 const Value* value = scope->GetValue("precompiled_header_type", true); |
| 119 if (!value) |
| 120 return true; // Not present is fine. |
| 121 if (!value->VerifyTypeIs(Value::STRING, err)) |
| 122 return false; |
| 123 |
| 124 if (value->string_value().empty()) |
| 125 return true; // Accept empty string, do nothing (default is "no PCH"). |
| 126 |
| 127 if (value->string_value() == "msvc") { |
| 128 tool->set_precompiled_header_type(Tool::PCH_MSVC); |
| 129 return true; |
| 130 } |
| 131 *err = Err(*value, "Invalid precompiled_header_type", |
| 132 "Must either be empty or \"msvc\"."); |
| 133 return false; |
| 134 } |
| 135 |
117 bool ReadDepsFormat(Scope* scope, Tool* tool, Err* err) { | 136 bool ReadDepsFormat(Scope* scope, Tool* tool, Err* err) { |
118 const Value* value = scope->GetValue("depsformat", true); | 137 const Value* value = scope->GetValue("depsformat", true); |
119 if (!value) | 138 if (!value) |
120 return true; // Not present is fine. | 139 return true; // Not present is fine. |
121 if (!value->VerifyTypeIs(Value::STRING, err)) | 140 if (!value->VerifyTypeIs(Value::STRING, err)) |
122 return false; | 141 return false; |
123 | 142 |
124 if (value->string_value() == "gcc") { | 143 if (value->string_value() == "gcc") { |
125 tool->set_depsformat(Tool::DEPS_GCC); | 144 tool->set_depsformat(Tool::DEPS_GCC); |
126 } else if (value->string_value() == "msvc") { | 145 } else if (value->string_value() == "msvc") { |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 " Prefix to use for the output name. Defaults to empty. This\n" | 515 " Prefix to use for the output name. Defaults to empty. This\n" |
497 " prefix will be prepended to the name of the target (or the\n" | 516 " prefix will be prepended to the name of the target (or the\n" |
498 " output_name if one is manually specified for it) if the prefix\n" | 517 " output_name if one is manually specified for it) if the prefix\n" |
499 " is not already there. The result will show up in the\n" | 518 " is not already there. The result will show up in the\n" |
500 " {{output_name}} substitution pattern.\n" | 519 " {{output_name}} substitution pattern.\n" |
501 "\n" | 520 "\n" |
502 " This is typically used to prepend \"lib\" to libraries on\n" | 521 " This is typically used to prepend \"lib\" to libraries on\n" |
503 " Posix systems:\n" | 522 " Posix systems:\n" |
504 " output_prefix = \"lib\"\n" | 523 " output_prefix = \"lib\"\n" |
505 "\n" | 524 "\n" |
| 525 " precompiled_header_type [string]\n" |
| 526 " Valid for: \"cc\", \"cxx\", \"objc\", \"objcxx\"\n" |
| 527 "\n" |
| 528 " Type of precompiled headers. If undefined or the empty string,\n" |
| 529 " precompiled headers will not be used for this tool. Otherwise\n" |
| 530 " use \"msvc\" which is the only currently supported value.\n" |
| 531 "\n" |
| 532 " For precompiled headers to be used for a given target, the\n" |
| 533 " target (or a config applied to it) must also specify a\n" |
| 534 " \"precompiled_header\" and, for \"msvc\"-style headers, a\n" |
| 535 " \"precompiled_source\" value.\n" |
| 536 "\n" |
| 537 " See \"gn help precompiled_header\" for more.\n" |
| 538 "\n" |
506 " restat [boolean]\n" | 539 " restat [boolean]\n" |
507 " Valid for: all tools (optional, defaults to false)\n" | 540 " Valid for: all tools (optional, defaults to false)\n" |
508 "\n" | 541 "\n" |
509 " Requests that Ninja check the file timestamp after this tool has\n" | 542 " Requests that Ninja check the file timestamp after this tool has\n" |
510 " run to determine if anything changed. Set this if your tool has\n" | 543 " run to determine if anything changed. Set this if your tool has\n" |
511 " the ability to skip writing output if the output file has not\n" | 544 " the ability to skip writing output if the output file has not\n" |
512 " changed.\n" | 545 " changed.\n" |
513 "\n" | 546 "\n" |
514 " Normally, Ninja will assume that when a tool runs the output\n" | 547 " Normally, Ninja will assume that when a tool runs the output\n" |
515 " be new and downstream dependents must be rebuild. When this is\n" | 548 " be new and downstream dependents must be rebuild. When this is\n" |
(...skipping 17 matching lines...) Expand all Loading... |
533 " allows you to get around OS command-line length limits.\n" | 566 " allows you to get around OS command-line length limits.\n" |
534 "\n" | 567 "\n" |
535 " This example adds the inputs and libraries to a response file,\n" | 568 " This example adds the inputs and libraries to a response file,\n" |
536 " but passes the linker flags directly on the command line:\n" | 569 " but passes the linker flags directly on the command line:\n" |
537 " tool(\"link\") {\n" | 570 " tool(\"link\") {\n" |
538 " command = \"link -o {{output}} {{ldflags}} @{{output}}.rsp\"\n" | 571 " command = \"link -o {{output}} {{ldflags}} @{{output}}.rsp\"\n" |
539 " rspfile = \"{{output}}.rsp\"\n" | 572 " rspfile = \"{{output}}.rsp\"\n" |
540 " rspfile_content = \"{{inputs}} {{solibs}} {{libs}}\"\n" | 573 " rspfile_content = \"{{inputs}} {{solibs}} {{libs}}\"\n" |
541 " }\n" | 574 " }\n" |
542 "\n" | 575 "\n" |
543 "Expansions for tool variables" | 576 "Expansions for tool variables\n" |
544 "\n" | 577 "\n" |
545 " All paths are relative to the root build directory, which is the\n" | 578 " All paths are relative to the root build directory, which is the\n" |
546 " current directory for running all tools. These expansions are\n" | 579 " current directory for running all tools. These expansions are\n" |
547 " available to all tools:\n" | 580 " available to all tools:\n" |
548 "\n" | 581 "\n" |
549 " {{label}}\n" | 582 " {{label}}\n" |
550 " The label of the current target. This is typically used in the\n" | 583 " The label of the current target. This is typically used in the\n" |
551 " \"description\" field for link tools. The toolchain will be\n" | 584 " \"description\" field for link tools. The toolchain will be\n" |
552 " omitted from the label for targets in the default toolchain, and\n" | 585 " omitted from the label for targets in the default toolchain, and\n" |
553 " will be included for targets in other toolchains.\n" | 586 " will be included for targets in other toolchains.\n" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 !ReadString(&block_scope, "lib_switch", tool.get(), | 810 !ReadString(&block_scope, "lib_switch", tool.get(), |
778 &Tool::set_lib_switch, err) || | 811 &Tool::set_lib_switch, err) || |
779 !ReadString(&block_scope, "lib_dir_switch", tool.get(), | 812 !ReadString(&block_scope, "lib_dir_switch", tool.get(), |
780 &Tool::set_lib_dir_switch, err) || | 813 &Tool::set_lib_dir_switch, err) || |
781 !ReadPattern(&block_scope, "link_output", subst_validator, tool.get(), | 814 !ReadPattern(&block_scope, "link_output", subst_validator, tool.get(), |
782 &Tool::set_link_output, err) || | 815 &Tool::set_link_output, err) || |
783 !ReadPattern(&block_scope, "depend_output", subst_validator, tool.get(), | 816 !ReadPattern(&block_scope, "depend_output", subst_validator, tool.get(), |
784 &Tool::set_depend_output, err) || | 817 &Tool::set_depend_output, err) || |
785 !ReadString(&block_scope, "output_prefix", tool.get(), | 818 !ReadString(&block_scope, "output_prefix", tool.get(), |
786 &Tool::set_output_prefix, err) || | 819 &Tool::set_output_prefix, err) || |
| 820 !ReadPrecompiledHeaderType(&block_scope, tool.get(), err) || |
787 !ReadBool(&block_scope, "restat", tool.get(), &Tool::set_restat, err) || | 821 !ReadBool(&block_scope, "restat", tool.get(), &Tool::set_restat, err) || |
788 !ReadPattern(&block_scope, "rspfile", subst_validator, tool.get(), | 822 !ReadPattern(&block_scope, "rspfile", subst_validator, tool.get(), |
789 &Tool::set_rspfile, err) || | 823 &Tool::set_rspfile, err) || |
790 !ReadPattern(&block_scope, "rspfile_content", subst_validator, tool.get(), | 824 !ReadPattern(&block_scope, "rspfile_content", subst_validator, tool.get(), |
791 &Tool::set_rspfile_content, err)) { | 825 &Tool::set_rspfile_content, err)) { |
792 return Value(); | 826 return Value(); |
793 } | 827 } |
794 | 828 |
795 if (tool_type != Toolchain::TYPE_COPY && tool_type != Toolchain::TYPE_STAMP) { | 829 if (tool_type != Toolchain::TYPE_COPY && tool_type != Toolchain::TYPE_STAMP) { |
796 // All tools except the copy and stamp tools should have outputs. The copy | 830 // All tools except the copy and stamp tools should have outputs. The copy |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 return Value(); | 945 return Value(); |
912 | 946 |
913 Scope::KeyValueMap values; | 947 Scope::KeyValueMap values; |
914 block_scope.GetCurrentScopeValues(&values); | 948 block_scope.GetCurrentScopeValues(&values); |
915 toolchain->args() = values; | 949 toolchain->args() = values; |
916 | 950 |
917 return Value(); | 951 return Value(); |
918 } | 952 } |
919 | 953 |
920 } // namespace functions | 954 } // namespace functions |
OLD | NEW |