• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "gn/config_values.h"
6 
7 namespace {
8 
9 template <typename T>
VectorAppend(std::vector<T> * append_to,const std::vector<T> & append_this)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 
19 ConfigValues::ConfigValues() = default;
20 
21 ConfigValues::~ConfigValues() = default;
22 
AppendValues(const ConfigValues & append)23 void ConfigValues::AppendValues(const ConfigValues& append) {
24   VectorAppend(&asmflags_, append.asmflags_);
25   VectorAppend(&arflags_, append.arflags_);
26   VectorAppend(&cflags_, append.cflags_);
27   VectorAppend(&cflags_c_, append.cflags_c_);
28   VectorAppend(&cflags_cc_, append.cflags_cc_);
29   VectorAppend(&cflags_objc_, append.cflags_objc_);
30   VectorAppend(&cflags_objcc_, append.cflags_objcc_);
31   VectorAppend(&defines_, append.defines_);
32   VectorAppend(&frameworks_, append.frameworks_);
33   VectorAppend(&weak_frameworks_, append.weak_frameworks_);
34   VectorAppend(&framework_dirs_, append.framework_dirs_);
35   VectorAppend(&include_dirs_, append.include_dirs_);
36   VectorAppend(&inputs_, append.inputs_);
37   VectorAppend(&ldflags_, append.ldflags_);
38   VectorAppend(&lib_dirs_, append.lib_dirs_);
39   VectorAppend(&libs_, append.libs_);
40   VectorAppend(&rustflags_, append.rustflags_);
41   VectorAppend(&rustenv_, append.rustenv_);
42   VectorAppend(&swiftflags_, append.swiftflags_);
43 
44   // Only append precompiled header if there isn't one. It might be nice to
45   // throw an error if there are conflicting precompiled headers, but that
46   // requires piping through some context of the actual configs involved, and
47   // conflicts here should be very unusual. Instead, use the first value.
48   if (!append.precompiled_header_.empty() && !precompiled_header_.empty())
49     precompiled_header_ = append.precompiled_header_;
50   if (!append.precompiled_source_.is_null() && !precompiled_source_.is_null())
51     precompiled_source_ = append.precompiled_source_;
52 }
53