Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: tools/gn/function_toolchain.cc

Issue 1292983004: [GN]: Precompiled header support for GCC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/config_values_generator.h ('k') | tools/gn/ninja_binary_target_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "tools/gn/scheduler.h" 11 #include "tools/gn/scheduler.h"
12 #include "tools/gn/scope.h" 12 #include "tools/gn/scope.h"
13 #include "tools/gn/settings.h" 13 #include "tools/gn/settings.h"
14 #include "tools/gn/tool.h" 14 #include "tools/gn/tool.h"
15 #include "tools/gn/toolchain.h" 15 #include "tools/gn/toolchain.h"
16 #include "tools/gn/value_extractors.h" 16 #include "tools/gn/value_extractors.h"
17 #include "tools/gn/variables.h" 17 #include "tools/gn/variables.h"
18 18
19 namespace functions { 19 namespace functions {
20 20
21 namespace { 21 namespace {
22 22
23 // This is jsut a unique value to take the address of to use as the key for 23 // This is just a unique value to take the address of to use as the key for
24 // the toolchain property on a scope. 24 // the toolchain property on a scope.
25 const int kToolchainPropertyKey = 0; 25 const int kToolchainPropertyKey = 0;
26 26
27 bool ReadBool(Scope* scope, 27 bool ReadBool(Scope* scope,
28 const char* var, 28 const char* var,
29 Tool* tool, 29 Tool* tool,
30 void (Tool::*set)(bool), 30 void (Tool::*set)(bool),
31 Err* err) { 31 Err* err) {
32 const Value* v = scope->GetValue(var, true); 32 const Value* v = scope->GetValue(var, true);
33 if (!v) 33 if (!v)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 bool ReadPrecompiledHeaderType(Scope* scope, Tool* tool, Err* err) { 117 bool ReadPrecompiledHeaderType(Scope* scope, Tool* tool, Err* err) {
118 const Value* value = scope->GetValue("precompiled_header_type", true); 118 const Value* value = scope->GetValue("precompiled_header_type", true);
119 if (!value) 119 if (!value)
120 return true; // Not present is fine. 120 return true; // Not present is fine.
121 if (!value->VerifyTypeIs(Value::STRING, err)) 121 if (!value->VerifyTypeIs(Value::STRING, err))
122 return false; 122 return false;
123 123
124 if (value->string_value().empty()) 124 if (value->string_value().empty())
125 return true; // Accept empty string, do nothing (default is "no PCH"). 125 return true; // Accept empty string, do nothing (default is "no PCH").
126 126
127 if (value->string_value() == "msvc") { 127 if (value->string_value() == "gcc") {
128 tool->set_precompiled_header_type(Tool::PCH_GCC);
129 return true;
130 } else if (value->string_value() == "msvc") {
128 tool->set_precompiled_header_type(Tool::PCH_MSVC); 131 tool->set_precompiled_header_type(Tool::PCH_MSVC);
129 return true; 132 return true;
130 } 133 }
131 *err = Err(*value, "Invalid precompiled_header_type", 134 *err = Err(*value, "Invalid precompiled_header_type",
132 "Must either be empty or \"msvc\"."); 135 "Must either be empty, \"gcc\", or \"msvc\".");
133 return false; 136 return false;
134 } 137 }
135 138
136 bool ReadDepsFormat(Scope* scope, Tool* tool, Err* err) { 139 bool ReadDepsFormat(Scope* scope, Tool* tool, Err* err) {
137 const Value* value = scope->GetValue("depsformat", true); 140 const Value* value = scope->GetValue("depsformat", true);
138 if (!value) 141 if (!value)
139 return true; // Not present is fine. 142 return true; // Not present is fine.
140 if (!value->VerifyTypeIs(Value::STRING, err)) 143 if (!value->VerifyTypeIs(Value::STRING, err))
141 return false; 144 return false;
142 145
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 "\n" 527 "\n"
525 " This is typically used to prepend \"lib\" to libraries on\n" 528 " This is typically used to prepend \"lib\" to libraries on\n"
526 " Posix systems:\n" 529 " Posix systems:\n"
527 " output_prefix = \"lib\"\n" 530 " output_prefix = \"lib\"\n"
528 "\n" 531 "\n"
529 " precompiled_header_type [string]\n" 532 " precompiled_header_type [string]\n"
530 " Valid for: \"cc\", \"cxx\", \"objc\", \"objcxx\"\n" 533 " Valid for: \"cc\", \"cxx\", \"objc\", \"objcxx\"\n"
531 "\n" 534 "\n"
532 " Type of precompiled headers. If undefined or the empty string,\n" 535 " Type of precompiled headers. If undefined or the empty string,\n"
533 " precompiled headers will not be used for this tool. Otherwise\n" 536 " precompiled headers will not be used for this tool. Otherwise\n"
534 " use \"msvc\" which is the only currently supported value.\n" 537 " use \"gcc\" or \"msvc\".\n"
535 "\n" 538 "\n"
536 " For precompiled headers to be used for a given target, the\n" 539 " For precompiled headers to be used for a given target, the\n"
537 " target (or a config applied to it) must also specify a\n" 540 " target (or a config applied to it) must also specify a\n"
538 " \"precompiled_header\" and, for \"msvc\"-style headers, a\n" 541 " \"precompiled_header\" and, for \"msvc\"-style headers, a\n"
539 " \"precompiled_source\" value.\n" 542 " \"precompiled_source\" value. If the type is \"gcc\", then both\n"
543 " \"precompiled_header\" and \"precompiled_source\" must resolve\n"
544 " to the same file, despite the different formats required for each."
540 "\n" 545 "\n"
541 " See \"gn help precompiled_header\" for more.\n" 546 " See \"gn help precompiled_header\" for more.\n"
542 "\n" 547 "\n"
543 " restat [boolean]\n" 548 " restat [boolean]\n"
544 " Valid for: all tools (optional, defaults to false)\n" 549 " Valid for: all tools (optional, defaults to false)\n"
545 "\n" 550 "\n"
546 " Requests that Ninja check the file timestamp after this tool has\n" 551 " Requests that Ninja check the file timestamp after this tool has\n"
547 " run to determine if anything changed. Set this if your tool has\n" 552 " run to determine if anything changed. Set this if your tool has\n"
548 " the ability to skip writing output if the output file has not\n" 553 " the ability to skip writing output if the output file has not\n"
549 " changed.\n" 554 " changed.\n"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 return Value(); 954 return Value();
950 955
951 Scope::KeyValueMap values; 956 Scope::KeyValueMap values;
952 block_scope.GetCurrentScopeValues(&values); 957 block_scope.GetCurrentScopeValues(&values);
953 toolchain->args() = values; 958 toolchain->args() = values;
954 959
955 return Value(); 960 return Value();
956 } 961 }
957 962
958 } // namespace functions 963 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/config_values_generator.h ('k') | tools/gn/ninja_binary_target_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698