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

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

Issue 21983003: Make the Mac build work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dunnow 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/input_file.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/config_values_generator.h" 5 #include "tools/gn/config_values_generator.h"
6 6
7 #include "tools/gn/config_values.h" 7 #include "tools/gn/config_values.h"
8 #include "tools/gn/scope.h" 8 #include "tools/gn/scope.h"
9 #include "tools/gn/value.h" 9 #include "tools/gn/value.h"
10 #include "tools/gn/value_extractors.h" 10 #include "tools/gn/value_extractors.h"
11 11
12 namespace { 12 namespace {
13 13
14 void GetStringList( 14 void GetStringList(
15 const Scope* scope, 15 Scope* scope,
16 const char* var_name, 16 const char* var_name,
17 ConfigValues* config_values, 17 ConfigValues* config_values,
18 void (ConfigValues::* swapper_inner)(std::vector<std::string>*), 18 void (ConfigValues::* swapper_inner)(std::vector<std::string>*),
19 Err* err) { 19 Err* err) {
20 const Value* value = scope->GetValue(var_name); 20 const Value* value = scope->GetValue(var_name, true);
21 if (!value) 21 if (!value)
22 return; // No value, empty input and succeed. 22 return; // No value, empty input and succeed.
23 23
24 std::vector<std::string> result; 24 std::vector<std::string> result;
25 ExtractListOfStringValues(*value, &result, err); 25 ExtractListOfStringValues(*value, &result, err);
26 (config_values->*swapper_inner)(&result); 26 (config_values->*swapper_inner)(&result);
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 ConfigValuesGenerator::ConfigValuesGenerator(ConfigValues* dest_values, 31 ConfigValuesGenerator::ConfigValuesGenerator(ConfigValues* dest_values,
32 const Scope* scope, 32 Scope* scope,
33 const Token& function_token, 33 const Token& function_token,
34 const SourceDir& input_dir, 34 const SourceDir& input_dir,
35 Err* err) 35 Err* err)
36 : config_values_(dest_values), 36 : config_values_(dest_values),
37 scope_(scope), 37 scope_(scope),
38 function_token_(function_token), 38 function_token_(function_token),
39 input_dir_(input_dir), 39 input_dir_(input_dir),
40 err_(err) { 40 err_(err) {
41 } 41 }
42 42
43 ConfigValuesGenerator::~ConfigValuesGenerator() { 43 ConfigValuesGenerator::~ConfigValuesGenerator() {
44 } 44 }
45 45
46 void ConfigValuesGenerator::Run() { 46 void ConfigValuesGenerator::Run() {
47 FillDefines();
48 FillIncludes(); 47 FillIncludes();
49 FillCflags();
50 FillCflags_C();
51 FillCflags_CC();
52 FillLdflags();
53 }
54 48
55 void ConfigValuesGenerator::FillDefines() { 49 #define FILL_CONFIG_VALUE(name) \
56 GetStringList(scope_, "defines", config_values_, 50 GetStringList(scope_, #name, config_values_, \
57 &ConfigValues::swap_in_defines, err_); 51 &ConfigValues::swap_in_##name, err_);
52
53 FILL_CONFIG_VALUE(defines)
54 FILL_CONFIG_VALUE(cflags)
55 FILL_CONFIG_VALUE(cflags_c)
56 FILL_CONFIG_VALUE(cflags_cc)
57 FILL_CONFIG_VALUE(cflags_objc)
58 FILL_CONFIG_VALUE(cflags_objcc)
59 FILL_CONFIG_VALUE(ldflags)
60
61 #undef FILL_CONFIG_VALUE
58 } 62 }
59 63
60 void ConfigValuesGenerator::FillIncludes() { 64 void ConfigValuesGenerator::FillIncludes() {
61 const Value* value = scope_->GetValue("includes"); 65 const Value* value = scope_->GetValue("includes", true);
62 if (!value) 66 if (!value)
63 return; // No value, empty input and succeed. 67 return; // No value, empty input and succeed.
64 68
65 std::vector<SourceDir> includes; 69 std::vector<SourceDir> includes;
66 if (!ExtractListOfRelativeDirs(*value, input_dir_, &includes, err_)) 70 if (!ExtractListOfRelativeDirs(*value, input_dir_, &includes, err_))
67 return; 71 return;
68 config_values_->swap_in_includes(&includes); 72 config_values_->swap_in_includes(&includes);
69 } 73 }
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/input_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698