Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: tools/gn/config_values_generator.cc

Issue 1606553002: Add support for Mac/iOS application bundles to GN tool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: base_unittests builds and pass all tests with GN Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 26 matching lines...) Expand all
37 const Value* value = scope->GetValue(var_name, true); 37 const Value* value = scope->GetValue(var_name, true);
38 if (!value) 38 if (!value)
39 return; // No value, empty input and succeed. 39 return; // No value, empty input and succeed.
40 40
41 std::vector<SourceDir> result; 41 std::vector<SourceDir> result;
42 ExtractListOfRelativeDirs(scope->settings()->build_settings(), 42 ExtractListOfRelativeDirs(scope->settings()->build_settings(),
43 *value, input_dir, &result, err); 43 *value, input_dir, &result, err);
44 (config_values->*accessor)().swap(result); 44 (config_values->*accessor)().swap(result);
45 } 45 }
46 46
47 void GetSrcList(
48 Scope* scope,
49 const char* var_name,
50 ConfigValues* config_values,
51 const SourceDir input_dir,
52 std::vector<SourceFile>& (ConfigValues::* accessor)(),
53 Err* err) {
54 const Value* value = scope->GetValue(var_name, true);
55 if (!value)
56 return; // No value, empty input and succeed.
57
58 std::vector<SourceFile> result;
59 ExtractListOfRelativeFiles(scope->settings()->build_settings(),
60 *value, input_dir, &result, err);
61 (config_values->*accessor)().swap(result);
62 }
63
47 } // namespace 64 } // namespace
48 65
49 ConfigValuesGenerator::ConfigValuesGenerator( 66 ConfigValuesGenerator::ConfigValuesGenerator(
50 ConfigValues* dest_values, 67 ConfigValues* dest_values,
51 Scope* scope, 68 Scope* scope,
52 const SourceDir& input_dir, 69 const SourceDir& input_dir,
53 Err* err) 70 Err* err)
54 : config_values_(dest_values), 71 : config_values_(dest_values),
55 scope_(scope), 72 scope_(scope),
56 input_dir_(input_dir), 73 input_dir_(input_dir),
57 err_(err) { 74 err_(err) {
58 } 75 }
59 76
60 ConfigValuesGenerator::~ConfigValuesGenerator() { 77 ConfigValuesGenerator::~ConfigValuesGenerator() {
61 } 78 }
62 79
63 void ConfigValuesGenerator::Run() { 80 void ConfigValuesGenerator::Run() {
64 #define FILL_STRING_CONFIG_VALUE(name) \ 81 #define FILL_STRING_CONFIG_VALUE(name) \
65 GetStringList(scope_, #name, config_values_, &ConfigValues::name, err_); 82 GetStringList(scope_, #name, config_values_, &ConfigValues::name, err_);
66 #define FILL_DIR_CONFIG_VALUE(name) \ 83 #define FILL_DIR_CONFIG_VALUE(name) \
67 GetDirList(scope_, #name, config_values_, input_dir_, \ 84 GetDirList(scope_, #name, config_values_, input_dir_, \
68 &ConfigValues::name, err_); 85 &ConfigValues::name, err_);
86 #define FILL_SRC_CONFIG_VALUE(name) \
87 GetSrcList(scope_, #name, config_values_, input_dir_, \
88 &ConfigValues::name, err_);
69 89
70 FILL_STRING_CONFIG_VALUE(asmflags) 90 FILL_STRING_CONFIG_VALUE(asmflags)
71 FILL_STRING_CONFIG_VALUE(cflags) 91 FILL_STRING_CONFIG_VALUE(cflags)
72 FILL_STRING_CONFIG_VALUE(cflags_c) 92 FILL_STRING_CONFIG_VALUE(cflags_c)
73 FILL_STRING_CONFIG_VALUE(cflags_cc) 93 FILL_STRING_CONFIG_VALUE(cflags_cc)
74 FILL_STRING_CONFIG_VALUE(cflags_objc) 94 FILL_STRING_CONFIG_VALUE(cflags_objc)
75 FILL_STRING_CONFIG_VALUE(cflags_objcc) 95 FILL_STRING_CONFIG_VALUE(cflags_objcc)
76 FILL_STRING_CONFIG_VALUE(defines) 96 FILL_STRING_CONFIG_VALUE(defines)
77 FILL_DIR_CONFIG_VALUE( include_dirs) 97 FILL_DIR_CONFIG_VALUE( include_dirs)
78 FILL_STRING_CONFIG_VALUE(ldflags) 98 FILL_STRING_CONFIG_VALUE(ldflags)
79 FILL_DIR_CONFIG_VALUE( lib_dirs) 99 FILL_DIR_CONFIG_VALUE( lib_dirs)
100 FILL_SRC_CONFIG_VALUE( bundle_data)
80 101
81 #undef FILL_STRING_CONFIG_VALUE 102 #undef FILL_STRING_CONFIG_VALUE
82 #undef FILL_DIR_CONFIG_VALUE 103 #undef FILL_DIR_CONFIG_VALUE
104 #undef FILL_SRC_CONFIG_VALUE
83 105
84 // Libs 106 // Libs
85 const Value* libs_value = scope_->GetValue("libs", true); 107 const Value* libs_value = scope_->GetValue("libs", true);
86 if (libs_value) { 108 if (libs_value) {
87 ExtractListOfLibs(scope_->settings()->build_settings(), *libs_value, 109 ExtractListOfLibs(scope_->settings()->build_settings(), *libs_value,
88 input_dir_, &config_values_->libs(), err_); 110 input_dir_, &config_values_->libs(), err_);
89 } 111 }
90 112
91 // Precompiled headers. 113 // Precompiled headers.
92 const Value* precompiled_header_value = 114 const Value* precompiled_header_value =
(...skipping 18 matching lines...) Expand all
111 scope_->GetValue(variables::kPrecompiledSource, true); 133 scope_->GetValue(variables::kPrecompiledSource, true);
112 if (precompiled_source_value) { 134 if (precompiled_source_value) {
113 config_values_->set_precompiled_source( 135 config_values_->set_precompiled_source(
114 input_dir_.ResolveRelativeFile( 136 input_dir_.ResolveRelativeFile(
115 *precompiled_source_value, err_, 137 *precompiled_source_value, err_,
116 scope_->settings()->build_settings()->root_path_utf8())); 138 scope_->settings()->build_settings()->root_path_utf8()));
117 if (err_->has_error()) 139 if (err_->has_error())
118 return; 140 return;
119 } 141 }
120 } 142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698