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

Unified Diff: tools/gn/template.cc

Issue 2149213002: Document GN invoker and target name variables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reference Created 4 years, 5 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
« no previous file with comments | « tools/gn/functions.cc ('k') | tools/gn/variables.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/template.cc
diff --git a/tools/gn/template.cc b/tools/gn/template.cc
index 3c4d76dafaef69bfa1d943fb163656ee448fc2c9..e865264174a1740c7fe8a9821dd8d18f5764b84c 100644
--- a/tools/gn/template.cc
+++ b/tools/gn/template.cc
@@ -12,6 +12,7 @@
#include "tools/gn/scope.h"
#include "tools/gn/scope_per_file_provider.h"
#include "tools/gn/value.h"
+#include "tools/gn/variables.h"
Template::Template(const Scope* scope, const FunctionCallNode* def)
: closure_(scope->MakeClosure()),
@@ -77,14 +78,14 @@ Value Template::Invoke(Scope* scope,
// Scope.SetValue will copy the value which will in turn copy the scope, but
// if we instead create a value and then set the scope on it, the copy can
// be avoided.
- const char kInvoker[] = "invoker";
- template_scope.SetValue(kInvoker, Value(nullptr, std::unique_ptr<Scope>()),
- invocation);
- Value* invoker_value = template_scope.GetMutableValue(kInvoker, false);
+ template_scope.SetValue(variables::kInvoker,
+ Value(nullptr, std::unique_ptr<Scope>()), invocation);
+ Value* invoker_value =
+ template_scope.GetMutableValue(variables::kInvoker, false);
invoker_value->SetScopeValue(std::move(invocation_scope));
template_scope.set_source_dir(scope->GetSourceDir());
- const base::StringPiece target_name("target_name");
+ const base::StringPiece target_name(variables::kTargetName);
template_scope.SetValue(target_name,
Value(invocation, args[0].string_value()),
invocation);
@@ -107,7 +108,7 @@ Value Template::Invoke(Scope* scope,
// to overwrite the value of "invoker" and free the Scope owned by the
// value. So we need to look it up again and don't do anything if it doesn't
// exist.
- invoker_value = template_scope.GetMutableValue(kInvoker, false);
+ invoker_value = template_scope.GetMutableValue(variables::kInvoker, false);
if (invoker_value && invoker_value->type() == Value::SCOPE) {
if (!invoker_value->scope_value()->CheckForUnusedVars(err))
return Value();
« no previous file with comments | « tools/gn/functions.cc ('k') | tools/gn/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698