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

Side by Side Diff: tools/gn/function_exec_script.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/docs/reference.md ('k') | tools/gn/function_foreach.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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 "if you need to modify the whitelist."); 56 "if you need to modify the whitelist.");
57 return false; 57 return false;
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 const char kExecScript[] = "exec_script"; 62 const char kExecScript[] = "exec_script";
63 const char kExecScript_HelpShort[] = 63 const char kExecScript_HelpShort[] =
64 "exec_script: Synchronously run a script and return the output."; 64 "exec_script: Synchronously run a script and return the output.";
65 const char kExecScript_Help[] = 65 const char kExecScript_Help[] =
66 "exec_script: Synchronously run a script and return the output.\n" 66 R"(exec_script: Synchronously run a script and return the output.
67 "\n" 67
68 " exec_script(filename,\n" 68 exec_script(filename,
69 " arguments = [],\n" 69 arguments = [],
70 " input_conversion = \"\",\n" 70 input_conversion = "",
71 " file_dependencies = [])\n" 71 file_dependencies = [])
72 "\n" 72
73 " Runs the given script, returning the stdout of the script. The build\n" 73 Runs the given script, returning the stdout of the script. The build
74 " generation will fail if the script does not exist or returns a nonzero\n" 74 generation will fail if the script does not exist or returns a nonzero exit
75 " exit code.\n" 75 code.
76 "\n" 76
77 " The current directory when executing the script will be the root\n" 77 The current directory when executing the script will be the root build
78 " build directory. If you are passing file names, you will want to use\n" 78 directory. If you are passing file names, you will want to use the
79 " the rebase_path() function to make file names relative to this\n" 79 rebase_path() function to make file names relative to this path (see "gn help
80 " path (see \"gn help rebase_path\").\n" 80 rebase_path").
81 "\n" 81
82 "Arguments:\n" 82 Arguments:
83 "\n" 83
84 " filename:\n" 84 filename:
85 " File name of python script to execute. Non-absolute names will\n" 85 File name of python script to execute. Non-absolute names will be treated
86 " be treated as relative to the current build file.\n" 86 as relative to the current build file.
87 "\n" 87
88 " arguments:\n" 88 arguments:
89 " A list of strings to be passed to the script as arguments.\n" 89 A list of strings to be passed to the script as arguments. May be
90 " May be unspecified or the empty list which means no arguments.\n" 90 unspecified or the empty list which means no arguments.
91 "\n" 91
92 " input_conversion:\n" 92 input_conversion:
93 " Controls how the file is read and parsed.\n" 93 Controls how the file is read and parsed. See "gn help input_conversion".
94 " See \"gn help input_conversion\".\n" 94
95 "\n" 95 If unspecified, defaults to the empty string which causes the script
96 " If unspecified, defaults to the empty string which causes the\n" 96 result to be discarded. exec script will return None.
97 " script result to be discarded. exec script will return None.\n" 97
98 "\n" 98 dependencies:
99 " dependencies:\n" 99 (Optional) A list of files that this script reads or otherwise depends
100 " (Optional) A list of files that this script reads or otherwise\n" 100 on. These dependencies will be added to the build result such that if any
101 " depends on. These dependencies will be added to the build result\n" 101 of them change, the build will be regenerated and the script will be
102 " such that if any of them change, the build will be regenerated and\n" 102 re-run.
103 " the script will be re-run.\n" 103
104 "\n" 104 The script itself will be an implicit dependency so you do not need to
105 " The script itself will be an implicit dependency so you do not\n" 105 list it.
106 " need to list it.\n" 106
107 "\n" 107 Example
108 "Example:\n" 108
109 "\n" 109 all_lines = exec_script(
110 " all_lines = exec_script(\n" 110 "myscript.py", [some_input], "list lines",
111 " \"myscript.py\", [some_input], \"list lines\",\n" 111 [ rebase_path("data_file.txt", root_build_dir) ])
112 " [ rebase_path(\"data_file.txt\", root_build_dir) ])\n" 112
113 "\n" 113 # This example just calls the script with no arguments and discards the
114 " # This example just calls the script with no arguments and discards\n" 114 # result.
115 " # the result.\n" 115 exec_script("//foo/bar/myscript.py")
116 " exec_script(\"//foo/bar/myscript.py\")\n"; 116 )";
117 117
118 Value RunExecScript(Scope* scope, 118 Value RunExecScript(Scope* scope,
119 const FunctionCallNode* function, 119 const FunctionCallNode* function,
120 const std::vector<Value>& args, 120 const std::vector<Value>& args,
121 Err* err) { 121 Err* err) {
122 if (args.size() < 1 || args.size() > 4) { 122 if (args.size() < 1 || args.size() > 4) {
123 *err = Err(function->function(), "Wrong number of arguments to exec_script", 123 *err = Err(function->function(), "Wrong number of arguments to exec_script",
124 "I expected between one and four arguments."); 124 "I expected between one and four arguments.");
125 return Value(); 125 return Value();
126 } 126 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 msg); 249 msg);
250 return Value(); 250 return Value();
251 } 251 }
252 252
253 // Default to None value for the input conversion if unspecified. 253 // Default to None value for the input conversion if unspecified.
254 return ConvertInputToValue(scope->settings(), output, function, 254 return ConvertInputToValue(scope->settings(), output, function,
255 args.size() >= 3 ? args[2] : Value(), err); 255 args.size() >= 3 ? args[2] : Value(), err);
256 } 256 }
257 257
258 } // namespace functions 258 } // namespace functions
OLDNEW
« no previous file with comments | « tools/gn/docs/reference.md ('k') | tools/gn/function_foreach.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698