OLD | NEW |
---|---|
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 "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "tools/gn/config_values.h" | 8 #include "tools/gn/config_values.h" |
9 #include "tools/gn/scope.h" | 9 #include "tools/gn/scope.h" |
10 #include "tools/gn/settings.h" | 10 #include "tools/gn/settings.h" |
11 #include "tools/gn/value.h" | 11 #include "tools/gn/value.h" |
12 #include "tools/gn/value_extractors.h" | 12 #include "tools/gn/value_extractors.h" |
13 #include "tools/gn/variables.h" | 13 #include "tools/gn/variables.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 void GetStringList( | 17 void GetStringList( |
18 Scope* scope, | 18 Scope* scope, |
19 const char* var_name, | 19 const char* var_name, |
20 ConfigValues* config_values, | 20 ConfigValues* config_values, |
21 std::vector<std::string>& (ConfigValues::* accessor)(), | 21 std::vector<std::string>& (ConfigValues::* accessor)(), |
22 Err* err) { | 22 Err* err) { |
23 const Value* value = scope->GetValue(var_name, true); | 23 const Value* value = scope->GetValue(var_name, true); |
24 if (!value) | 24 if (!value) |
25 return; // No value, empty input and succeed. | 25 return; // No value, empty input and succeed. |
26 | 26 |
27 std::vector<std::string> result; | 27 ExtractListOfStringValues(*value, &(config_values->*accessor)(), err); |
28 ExtractListOfStringValues(*value, &result, err); | |
29 (config_values->*accessor)().swap(result); | |
30 } | 28 } |
31 | 29 |
32 void GetDirList( | 30 void GetDirList( |
33 Scope* scope, | 31 Scope* scope, |
34 const char* var_name, | 32 const char* var_name, |
35 ConfigValues* config_values, | 33 ConfigValues* config_values, |
36 const SourceDir input_dir, | 34 const SourceDir input_dir, |
37 std::vector<SourceDir>& (ConfigValues::* accessor)(), | 35 std::vector<SourceDir>& (ConfigValues::* accessor)(), |
38 Err* err) { | 36 Err* err) { |
39 const Value* value = scope->GetValue(var_name, true); | 37 const Value* value = scope->GetValue(var_name, true); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 FILL_STRING_CONFIG_VALUE(asmflags) | 70 FILL_STRING_CONFIG_VALUE(asmflags) |
73 FILL_STRING_CONFIG_VALUE(cflags) | 71 FILL_STRING_CONFIG_VALUE(cflags) |
74 FILL_STRING_CONFIG_VALUE(cflags_c) | 72 FILL_STRING_CONFIG_VALUE(cflags_c) |
75 FILL_STRING_CONFIG_VALUE(cflags_cc) | 73 FILL_STRING_CONFIG_VALUE(cflags_cc) |
76 FILL_STRING_CONFIG_VALUE(cflags_objc) | 74 FILL_STRING_CONFIG_VALUE(cflags_objc) |
77 FILL_STRING_CONFIG_VALUE(cflags_objcc) | 75 FILL_STRING_CONFIG_VALUE(cflags_objcc) |
78 FILL_STRING_CONFIG_VALUE(defines) | 76 FILL_STRING_CONFIG_VALUE(defines) |
79 FILL_DIR_CONFIG_VALUE( include_dirs) | 77 FILL_DIR_CONFIG_VALUE( include_dirs) |
80 FILL_STRING_CONFIG_VALUE(ldflags) | 78 FILL_STRING_CONFIG_VALUE(ldflags) |
81 FILL_DIR_CONFIG_VALUE( lib_dirs) | 79 FILL_DIR_CONFIG_VALUE( lib_dirs) |
82 FILL_STRING_CONFIG_VALUE(libs) | |
83 | 80 |
84 #undef FILL_STRING_CONFIG_VALUE | 81 #undef FILL_STRING_CONFIG_VALUE |
85 #undef FILL_DIR_CONFIG_VALUE | 82 #undef FILL_DIR_CONFIG_VALUE |
86 | 83 |
84 // Libs | |
85 const Value* libs_value = scope_->GetValue("libs", true); | |
86 if (libs_value) | |
brettw
2015/12/21 22:39:28
Since this is multi-line, always use {}
agrieve
2015/12/22 01:17:05
Done.
| |
87 ExtractListOfLibs(scope_->settings()->build_settings(), *libs_value, | |
88 input_dir_, &config_values_->libs(), err_); | |
89 | |
87 // Precompiled headers. | 90 // Precompiled headers. |
88 const Value* precompiled_header_value = | 91 const Value* precompiled_header_value = |
89 scope_->GetValue(variables::kPrecompiledHeader, true); | 92 scope_->GetValue(variables::kPrecompiledHeader, true); |
90 if (precompiled_header_value) { | 93 if (precompiled_header_value) { |
91 if (!precompiled_header_value->VerifyTypeIs(Value::STRING, err_)) | 94 if (!precompiled_header_value->VerifyTypeIs(Value::STRING, err_)) |
92 return; | 95 return; |
93 | 96 |
94 // Check for common errors. This is a string and not a file. | 97 // Check for common errors. This is a string and not a file. |
95 const std::string& pch_string = precompiled_header_value->string_value(); | 98 const std::string& pch_string = precompiled_header_value->string_value(); |
96 if (base::StartsWith(pch_string, "//", base::CompareCase::SENSITIVE)) { | 99 if (base::StartsWith(pch_string, "//", base::CompareCase::SENSITIVE)) { |
(...skipping 10 matching lines...) Expand all Loading... | |
107 scope_->GetValue(variables::kPrecompiledSource, true); | 110 scope_->GetValue(variables::kPrecompiledSource, true); |
108 if (precompiled_source_value) { | 111 if (precompiled_source_value) { |
109 config_values_->set_precompiled_source( | 112 config_values_->set_precompiled_source( |
110 input_dir_.ResolveRelativeFile( | 113 input_dir_.ResolveRelativeFile( |
111 *precompiled_source_value, err_, | 114 *precompiled_source_value, err_, |
112 scope_->settings()->build_settings()->root_path_utf8())); | 115 scope_->settings()->build_settings()->root_path_utf8())); |
113 if (err_->has_error()) | 116 if (err_->has_error()) |
114 return; | 117 return; |
115 } | 118 } |
116 } | 119 } |
OLD | NEW |