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

Unified Diff: tools/gn/function_toolchain.cc

Issue 2006923004: Add support for user defined "pool" to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: tools/gn/function_toolchain.cc
diff --git a/tools/gn/function_toolchain.cc b/tools/gn/function_toolchain.cc
index aaa9b7efaa739fbe43fc3f0fae702de55b142373..210cc2c84b45c092f1c57732d9df70d6b2b66689 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,31 @@ 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 +545,14 @@ 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. Pools are used to limit\n"
+ " the number of tasks that can execute concurrently during the\n"
+ " build.\n"
+ "\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, err)) {
return Value();
}
« no previous file with comments | « tools/gn/docs/reference.md ('k') | tools/gn/functions.h » ('j') | tools/gn/functions.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698