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

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

Issue 2481423002: Convert gn docstrings to C++11 raw strings. (Closed)
Patch Set: Fixes Created 4 years, 1 month 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/function_set_default_toolchain.cc ('k') | tools/gn/function_template.cc » ('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 "tools/gn/err.h" 5 #include "tools/gn/err.h"
6 #include "tools/gn/functions.h" 6 #include "tools/gn/functions.h"
7 #include "tools/gn/parse_tree.h" 7 #include "tools/gn/parse_tree.h"
8 #include "tools/gn/scope.h" 8 #include "tools/gn/scope.h"
9 9
10 namespace functions { 10 namespace functions {
11 11
12 const char kSetDefaults[] = "set_defaults"; 12 const char kSetDefaults[] = "set_defaults";
13 const char kSetDefaults_HelpShort[] = 13 const char kSetDefaults_HelpShort[] =
14 "set_defaults: Set default values for a target type."; 14 "set_defaults: Set default values for a target type.";
15 const char kSetDefaults_Help[] = 15 const char kSetDefaults_Help[] =
16 "set_defaults: Set default values for a target type.\n" 16 R"(set_defaults: Set default values for a target type.
17 "\n" 17
18 " set_defaults(<target_type_name>) { <values...> }\n" 18 set_defaults(<target_type_name>) { <values...> }
19 "\n" 19
20 " Sets the default values for a given target type. Whenever\n" 20 Sets the default values for a given target type. Whenever target_type_name is
21 " target_type_name is seen in the future, the values specified in\n" 21 seen in the future, the values specified in set_default's block will be
22 " set_default's block will be copied into the current scope.\n" 22 copied into the current scope.
23 "\n" 23
24 " When the target type is used, the variable copying is very strict.\n" 24 When the target type is used, the variable copying is very strict. If a
25 " If a variable with that name is already in scope, the build will fail\n" 25 variable with that name is already in scope, the build will fail with an
26 " with an error.\n" 26 error.
27 "\n" 27
28 " set_defaults can be used for built-in target types (\"executable\",\n" 28 set_defaults can be used for built-in target types ("executable",
29 " \"shared_library\", etc.) and custom ones defined via the \"template\"\n" 29 "shared_library", etc.) and custom ones defined via the "template" command.
30 " command. It can be called more than once and the most recent call in\n" 30 It can be called more than once and the most recent call in any scope will
31 " any scope will apply, but there is no way to refer to the previous\n" 31 apply, but there is no way to refer to the previous defaults and modify them
32 " defaults and modify them (each call to set_defaults must supply a\n" 32 (each call to set_defaults must supply a complete list of all defaults it
33 " complete list of all defaults it wants). If you want to share\n" 33 wants). If you want to share defaults, store them in a separate variable.
34 " defaults, store them in a separate variable.\n" 34
35 "\n" 35 Example
36 "Example\n" 36
37 "\n" 37 set_defaults("static_library") {
38 " set_defaults(\"static_library\") {\n" 38 configs = [ "//tools/mything:settings" ]
39 " configs = [ \"//tools/mything:settings\" ]\n" 39 }
40 " }\n" 40
41 "\n" 41 static_library("mylib")
42 " static_library(\"mylib\")\n" 42 # The configs will be auto-populated as above. You can remove it if
43 " # The configs will be auto-populated as above. You can remove it if\n" 43 # you don't want the default for a particular default:
44 " # you don't want the default for a particular default:\n" 44 configs -= [ "//tools/mything:settings" ]
45 " configs -= \"//tools/mything:settings\"\n" 45 }
46 " }\n"; 46 )";
47 47
48 Value RunSetDefaults(Scope* scope, 48 Value RunSetDefaults(Scope* scope,
49 const FunctionCallNode* function, 49 const FunctionCallNode* function,
50 const std::vector<Value>& args, 50 const std::vector<Value>& args,
51 BlockNode* block, 51 BlockNode* block,
52 Err* err) { 52 Err* err) {
53 if (!EnsureSingleStringArg(function, args, err)) 53 if (!EnsureSingleStringArg(function, args, err))
54 return Value(); 54 return Value();
55 const std::string& target_type(args[0].string_value()); 55 const std::string& target_type(args[0].string_value());
56 56
(...skipping 10 matching lines...) Expand all
67 67
68 // Now copy the values set on the scope we made into the free-floating one 68 // Now copy the values set on the scope we made into the free-floating one
69 // (with no containing scope) used to hold the target defaults. 69 // (with no containing scope) used to hold the target defaults.
70 Scope* dest = scope->MakeTargetDefaults(target_type); 70 Scope* dest = scope->MakeTargetDefaults(target_type);
71 block_scope.NonRecursiveMergeTo(dest, Scope::MergeOptions(), function, 71 block_scope.NonRecursiveMergeTo(dest, Scope::MergeOptions(), function,
72 "<SHOULD NOT FAIL>", err); 72 "<SHOULD NOT FAIL>", err);
73 return Value(); 73 return Value();
74 } 74 }
75 75
76 } // namespace functions 76 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/function_set_default_toolchain.cc ('k') | tools/gn/function_template.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698