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

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

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/function_set_default_toolchain.cc ('k') | tools/gn/function_toolchain.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "tools/gn/functions.h"
6
7 #include "tools/gn/parse_tree.h"
8 #include "tools/gn/scope.h"
9 #include "tools/gn/value.h"
10
11 Value ExecuteTemplate(Scope* scope,
12 const FunctionCallNode* function,
13 const std::vector<Value>& args,
14 BlockNode* block,
15 Err* err) {
16 // TODO(brettw) determine if the function is built-in and throw an error if
17 // it is.
18 if (args.size() != 1) {
19 *err = Err(function->function(),
20 "Need exactly one string arg to template.");
21 return Value();
22 }
23 if (!args[0].VerifyTypeIs(Value::STRING, err))
24 return Value();
25 std::string template_name = args[0].string_value();
26
27 const FunctionCallNode* existing_template = scope->GetTemplate(template_name);
28 if (existing_template) {
29 *err = Err(function, "Duplicate template definition.",
30 "A template with this name was already defined.");
31 err->AppendSubErr(Err(existing_template->function(),
32 "Previous definition."));
33 return Value();
34 }
35
36 scope->AddTemplate(template_name, function);
37 return Value();
38 }
OLDNEW
« no previous file with comments | « tools/gn/function_set_default_toolchain.cc ('k') | tools/gn/function_toolchain.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698