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

Side by Side Diff: tools/gn/function_define_rule.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/filesystem_utils_unittest.cc ('k') | tools/gn/function_exec_script.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 ExecuteDefineRule(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 define_rule.");
21 return Value();
22 }
23 if (!args[0].VerifyTypeIs(Value::STRING, err))
24 return Value();
25 std::string rule_name = args[0].string_value();
26
27 const FunctionCallNode* existing_rule = scope->GetRule(rule_name);
28 if (existing_rule) {
29 *err = Err(function, "Duplicate rule definition.",
30 "A rule with this name was already defined.");
31 err->AppendSubErr(Err(existing_rule->function(), "Previous definition."));
32 return Value();
33 }
34
35 scope->AddRule(rule_name, function);
36 return Value();
37 }
OLDNEW
« no previous file with comments | « tools/gn/filesystem_utils_unittest.cc ('k') | tools/gn/function_exec_script.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698