Index: tools/gn/function_toolchain.cc |
diff --git a/tools/gn/function_toolchain.cc b/tools/gn/function_toolchain.cc |
index aaa9b7efaa739fbe43fc3f0fae702de55b142373..e4a5fb5715ad581dfad64b786bb4517ae1952105 100644 |
--- a/tools/gn/function_toolchain.cc |
+++ b/tools/gn/function_toolchain.cc |
@@ -8,6 +8,8 @@ |
#include "tools/gn/err.h" |
#include "tools/gn/functions.h" |
+#include "tools/gn/label.h" |
+#include "tools/gn/label_ptr.h" |
#include "tools/gn/parse_tree.h" |
#include "tools/gn/scheduler.h" |
#include "tools/gn/scope.h" |
@@ -57,6 +59,32 @@ bool ReadString(Scope* scope, |
return true; |
} |
+// Reads the given label from the scope (if present) and puts the result into |
+// dest. If the value is not a label, sets the error and returns false. |
+bool ReadLabel(Scope* scope, |
+ const char* var, |
+ Tool* tool, |
+ const ParseNode* origin, |
+ const Label& current_toolchain, |
+ void (Tool::*set)(const LabelPtrPair<Pool>&), |
+ Err* err) { |
+ const Value* v = scope->GetValue(var, true); |
+ if (!v) |
+ return true; // Not present is fine. |
+ |
+ Label label = Label::Resolve(scope->GetSourceDir(), |
+ current_toolchain, |
+ *v, err); |
+ if (err->has_error()) |
+ return false; |
+ |
+ LabelPtrPair<Pool> pair(label); |
+ pair.origin = origin; |
+ |
+ (tool->*set)(pair); |
+ return true; |
+} |
+ |
// Calls the given validate function on each type in the list. On failure, |
// sets the error, blame the value, and return false. |
bool ValidateSubstitutionList(const std::vector<SubstitutionType>& list, |
@@ -518,6 +546,13 @@ const char kTool_Help[] = |
" \"{{output_dir}}/{{target_output_name}}.lib\",\n" |
" ]\n" |
"\n" |
+ " pool [label, optional]\n" |
+ "\n" |
+ " Label of the pool to use for the tool. Pool are used to limit\n" |
Dirk Pranke
2016/05/25 02:04:52
Nit: "Pools are used" or "A pool is used"
sdefresne
2016/05/26 15:38:37
Done.
|
+ " the number of task to launch simultaneously during the build.\n" |
Dirk Pranke
2016/05/25 02:04:52
Nit: "number of tasks". In fact, I'd probably writ
sdefresne
2016/05/26 15:38:37
Done.
|
+ "\n" |
+ " See also \"gn help pool\".\n" |
+ "\n" |
" link_output [string with substitutions]\n" |
" depend_output [string with substitutions]\n" |
" runtime_link_output [string with substitutions]\n" |
@@ -908,7 +943,9 @@ Value RunTool(Scope* scope, |
!ReadPattern(&block_scope, "rspfile", subst_validator, tool.get(), |
&Tool::set_rspfile, err) || |
!ReadPattern(&block_scope, "rspfile_content", subst_validator, tool.get(), |
- &Tool::set_rspfile_content, err)) { |
+ &Tool::set_rspfile_content, err) || |
+ !ReadLabel(&block_scope, "pool", tool.get(), function, toolchain->label(), |
+ &Tool::set_pool_label_pair, err)) { |
return Value(); |
} |