Fix crash when using remote DevTools on CrOS WebUI - check for response_headers
[chromium-blink-merge.git] / tools / gn / config_values_generator.cc
blobf66ddfd688199e6c35e01abfd1cb23f84720d69e
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.
5 #include "tools/gn/config_values_generator.h"
7 #include "tools/gn/config_values.h"
8 #include "tools/gn/scope.h"
9 #include "tools/gn/settings.h"
10 #include "tools/gn/value.h"
11 #include "tools/gn/value_extractors.h"
12 #include "tools/gn/variables.h"
14 namespace {
16 void GetStringList(
17 Scope* scope,
18 const char* var_name,
19 ConfigValues* config_values,
20 std::vector<std::string>& (ConfigValues::* accessor)(),
21 Err* err) {
22 const Value* value = scope->GetValue(var_name, true);
23 if (!value)
24 return; // No value, empty input and succeed.
26 std::vector<std::string> result;
27 ExtractListOfStringValues(*value, &result, err);
28 (config_values->*accessor)().swap(result);
31 void GetDirList(
32 Scope* scope,
33 const char* var_name,
34 ConfigValues* config_values,
35 const SourceDir input_dir,
36 std::vector<SourceDir>& (ConfigValues::* accessor)(),
37 Err* err) {
38 const Value* value = scope->GetValue(var_name, true);
39 if (!value)
40 return; // No value, empty input and succeed.
42 std::vector<SourceDir> result;
43 ExtractListOfRelativeDirs(scope->settings()->build_settings(),
44 *value, input_dir, &result, err);
45 (config_values->*accessor)().swap(result);
48 } // namespace
50 ConfigValuesGenerator::ConfigValuesGenerator(
51 ConfigValues* dest_values,
52 Scope* scope,
53 const SourceDir& input_dir,
54 Err* err)
55 : config_values_(dest_values),
56 scope_(scope),
57 input_dir_(input_dir),
58 err_(err) {
61 ConfigValuesGenerator::~ConfigValuesGenerator() {
64 void ConfigValuesGenerator::Run() {
65 #define FILL_STRING_CONFIG_VALUE(name) \
66 GetStringList(scope_, #name, config_values_, &ConfigValues::name, err_);
67 #define FILL_DIR_CONFIG_VALUE(name) \
68 GetDirList(scope_, #name, config_values_, input_dir_, \
69 &ConfigValues::name, err_);
71 FILL_STRING_CONFIG_VALUE(cflags)
72 FILL_STRING_CONFIG_VALUE(cflags_c)
73 FILL_STRING_CONFIG_VALUE(cflags_cc)
74 FILL_STRING_CONFIG_VALUE(cflags_objc)
75 FILL_STRING_CONFIG_VALUE(cflags_objcc)
76 FILL_STRING_CONFIG_VALUE(defines)
77 FILL_DIR_CONFIG_VALUE( include_dirs)
78 FILL_STRING_CONFIG_VALUE(ldflags)
79 FILL_DIR_CONFIG_VALUE( lib_dirs)
80 FILL_STRING_CONFIG_VALUE(libs)
82 #undef FILL_STRING_CONFIG_VALUE
83 #undef FILL_DIR_CONFIG_VALUE