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.h" | 5 #include "tools/gn/config_values.h" |
6 | 6 |
7 namespace { | |
8 | |
9 template<typename T> | |
10 void VectorAppend(std::vector<T>* append_to, | |
11 const std::vector<T>& append_this) { | |
12 if (append_this.empty()) | |
13 return; | |
14 append_to->insert(append_to->end(),append_this.begin(), append_this.end()); | |
15 } | |
16 | |
17 } // namespace | |
18 | |
7 ConfigValues::ConfigValues() { | 19 ConfigValues::ConfigValues() { |
8 } | 20 } |
9 | 21 |
10 ConfigValues::~ConfigValues() { | 22 ConfigValues::~ConfigValues() { |
11 } | 23 } |
24 | |
25 void ConfigValues::AppendValues(const ConfigValues& append) { | |
26 #define APPEND_VALUES(variable) VectorAppend(&variable, append.variable) | |
27 APPEND_VALUES(cflags_); | |
28 APPEND_VALUES(cflags_c_); | |
29 APPEND_VALUES(cflags_cc_); | |
30 APPEND_VALUES(cflags_objcc_); | |
31 APPEND_VALUES(defines_); | |
32 APPEND_VALUES(include_dirs_); | |
33 APPEND_VALUES(ldflags_); | |
34 APPEND_VALUES(lib_dirs_); | |
35 APPEND_VALUES(libs_); | |
36 #undef APPEND_VALUES | |
Dirk Pranke
2015/09/15 21:31:31
I'm not sure the macro enhances readability much h
| |
37 | |
38 // Only append precompiled header if there isn't one. It might be nice to | |
39 // throw an error if there are conflicting precompiled headers, but that | |
40 // requires piping through some context of the actual configs involved, and | |
41 // conflicts here should be very unusual. Instead, use the first value. | |
42 if (!append.precompiled_header_.empty() && !precompiled_header_.empty()) | |
43 precompiled_header_ = append.precompiled_header_; | |
44 if (!append.precompiled_source_.is_null() && !precompiled_source_.is_null()) | |
45 precompiled_source_ = append.precompiled_source_; | |
46 } | |
OLD | NEW |