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

Side by Side Diff: tools/gn/config_values_generator.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/config_values_generator.h ('k') | tools/gn/err.h » ('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/config_values_generator.h"
6
7 #include "tools/gn/config_values.h"
8 #include "tools/gn/scope.h"
9 #include "tools/gn/value.h"
10 #include "tools/gn/value_extractors.h"
11
12 namespace {
13
14 void GetStringList(
15 const Scope* scope,
16 const char* var_name,
17 ConfigValues* config_values,
18 void (ConfigValues::* swapper_inner)(std::vector<std::string>*),
19 Err* err) {
20 const Value* value = scope->GetValue(var_name);
21 if (!value)
22 return; // No value, empty input and succeed.
23
24 std::vector<std::string> result;
25 ExtractListOfStringValues(*value, &result, err);
26 (config_values->*swapper_inner)(&result);
27 }
28
29 } // namespace
30
31 ConfigValuesGenerator::ConfigValuesGenerator(ConfigValues* dest_values,
32 const Scope* scope,
33 const Token& function_token,
34 const SourceDir& input_dir,
35 Err* err)
36 : config_values_(dest_values),
37 scope_(scope),
38 function_token_(function_token),
39 input_dir_(input_dir),
40 err_(err) {
41 }
42
43 ConfigValuesGenerator::~ConfigValuesGenerator() {
44 }
45
46 void ConfigValuesGenerator::Run() {
47 FillDefines();
48 FillIncludes();
49 FillCflags();
50 FillCflags_C();
51 FillCflags_CC();
52 FillLdflags();
53 }
54
55 void ConfigValuesGenerator::FillDefines() {
56 GetStringList(scope_, "defines", config_values_,
57 &ConfigValues::swap_in_defines, err_);
58 }
59
60 void ConfigValuesGenerator::FillIncludes() {
61 const Value* value = scope_->GetValue("includes");
62 if (!value)
63 return; // No value, empty input and succeed.
64
65 std::vector<SourceDir> includes;
66 if (!ExtractListOfRelativeDirs(*value, input_dir_, &includes, err_))
67 return;
68 config_values_->swap_in_includes(&includes);
69 }
70
71 void ConfigValuesGenerator::FillCflags() {
72 GetStringList(scope_, "cflags", config_values_,
73 &ConfigValues::swap_in_cflags, err_);
74 }
75
76 void ConfigValuesGenerator::FillCflags_C() {
77 GetStringList(scope_, "cflags_c", config_values_,
78 &ConfigValues::swap_in_cflags_c, err_);
79 }
80
81 void ConfigValuesGenerator::FillCflags_CC() {
82 GetStringList(scope_, "cflags_cc", config_values_,
83 &ConfigValues::swap_in_cflags_cc, err_);
84 }
85
86 void ConfigValuesGenerator::FillLdflags() {
87 GetStringList(scope_, "ldflags", config_values_,
88 &ConfigValues::swap_in_ldflags, err_);
89 }
OLDNEW
« no previous file with comments | « tools/gn/config_values_generator.h ('k') | tools/gn/err.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698