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"
19 ConfigValues
* config_values
,
20 std::vector
<std::string
>& (ConfigValues::* accessor
)(),
22 const Value
* value
= scope
->GetValue(var_name
, true);
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
);
34 ConfigValues
* config_values
,
35 const SourceDir input_dir
,
36 std::vector
<SourceDir
>& (ConfigValues::* accessor
)(),
38 const Value
* value
= scope
->GetValue(var_name
, true);
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
);
50 ConfigValuesGenerator::ConfigValuesGenerator(
51 ConfigValues
* dest_values
,
53 const SourceDir
& input_dir
,
55 : config_values_(dest_values
),
57 input_dir_(input_dir
),
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