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

Side by Side Diff: tools/gn/target_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: Split CL to only include tool change & address comments 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/target_generator.h" 5 #include "tools/gn/target_generator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "tools/gn/action_target_generator.h" 9 #include "tools/gn/action_target_generator.h"
10 #include "tools/gn/binary_target_generator.h" 10 #include "tools/gn/binary_target_generator.h"
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 void TargetGenerator::Run() { 39 void TargetGenerator::Run() {
40 // All target types use these. 40 // All target types use these.
41 if (!FillDependentConfigs()) 41 if (!FillDependentConfigs())
42 return; 42 return;
43 43
44 if (!FillData()) 44 if (!FillData())
45 return; 45 return;
46 46
47 if (!FillBundleData())
48 return;
49
47 if (!FillDependencies()) 50 if (!FillDependencies())
48 return; 51 return;
49 52
50 if (!FillTestonly()) 53 if (!FillTestonly())
51 return; 54 return;
52 55
53 if (!Visibility::FillItemVisibility(target_, scope_, err_)) 56 if (!Visibility::FillItemVisibility(target_, scope_, err_))
54 return; 57 return;
55 58
56 // Do type-specific generation. 59 // Do type-specific generation.
(...skipping 20 matching lines...) Expand all
77 Label label(scope->GetSourceDir(), args[0].string_value(), 80 Label label(scope->GetSourceDir(), args[0].string_value(),
78 toolchain_label.dir(), toolchain_label.name()); 81 toolchain_label.dir(), toolchain_label.name());
79 82
80 if (g_scheduler->verbose_logging()) 83 if (g_scheduler->verbose_logging())
81 g_scheduler->Log("Defining target", label.GetUserVisibleName(true)); 84 g_scheduler->Log("Defining target", label.GetUserVisibleName(true));
82 85
83 scoped_ptr<Target> target(new Target(scope->settings(), label)); 86 scoped_ptr<Target> target(new Target(scope->settings(), label));
84 target->set_defined_from(function_call); 87 target->set_defined_from(function_call);
85 88
86 // Create and call out to the proper generator. 89 // Create and call out to the proper generator.
87 if (output_type == functions::kCopy) { 90 if (output_type == functions::kCopy ||
88 CopyTargetGenerator generator(target.get(), scope, function_call, err); 91 output_type == functions::kCopyBundleData) {
92 Target::OutputType target_output_type = output_type == functions::kCopy
93 ? Target::COPY_FILES
94 : Target::COPY_BUNDLE_DATA;
95 CopyTargetGenerator generator(target.get(), scope, function_call,
96 target_output_type, err);
89 generator.Run(); 97 generator.Run();
90 } else if (output_type == functions::kAction) { 98 } else if (output_type == functions::kAction) {
91 ActionTargetGenerator generator(target.get(), scope, function_call, 99 ActionTargetGenerator generator(target.get(), scope, function_call,
92 Target::ACTION, err); 100 Target::ACTION, err);
93 generator.Run(); 101 generator.Run();
94 } else if (output_type == functions::kActionForEach) { 102 } else if (output_type == functions::kActionForEach) {
95 ActionTargetGenerator generator(target.get(), scope, function_call, 103 ActionTargetGenerator generator(target.get(), scope, function_call,
96 Target::ACTION_FOREACH, err); 104 Target::ACTION_FOREACH, err);
97 generator.Run(); 105 generator.Run();
98 } else if (output_type == functions::kExecutable) { 106 } else if (output_type == functions::kExecutable) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // Resolve as file. 239 // Resolve as file.
232 SourceFile resolved = dir.ResolveRelativeFile(input, err_, root_path); 240 SourceFile resolved = dir.ResolveRelativeFile(input, err_, root_path);
233 if (err_->has_error()) 241 if (err_->has_error())
234 return false; 242 return false;
235 output_list.push_back(resolved.value()); 243 output_list.push_back(resolved.value());
236 } 244 }
237 } 245 }
238 return true; 246 return true;
239 } 247 }
240 248
249 bool TargetGenerator::FillBundleData() {
250 const Value* value = scope_->GetValue(variables::kBundleData, true);
251 if (!value)
252 return true;
253
254 Target::FileList bundle_data;
255 if (!ExtractListOfRelativeFiles(scope_->settings()->build_settings(), *value,
256 scope_->GetSourceDir(), &bundle_data, err_))
257 return false;
258
259 target_->bundle_data().insert(bundle_data.begin(), bundle_data.end());
260 return true;
261 }
262
241 bool TargetGenerator::FillDependencies() { 263 bool TargetGenerator::FillDependencies() {
242 if (!FillGenericDeps(variables::kDeps, &target_->private_deps())) 264 if (!FillGenericDeps(variables::kDeps, &target_->private_deps()))
243 return false; 265 return false;
244 if (!FillGenericDeps(variables::kPublicDeps, &target_->public_deps())) 266 if (!FillGenericDeps(variables::kPublicDeps, &target_->public_deps()))
245 return false; 267 return false;
246 if (!FillGenericDeps(variables::kDataDeps, &target_->data_deps())) 268 if (!FillGenericDeps(variables::kDataDeps, &target_->data_deps()))
247 return false; 269 return false;
248 270
249 // "data_deps" was previously named "datadeps". For backwards-compat, read 271 // "data_deps" was previously named "datadeps". For backwards-compat, read
250 // the old one if no "data_deps" were specified. 272 // the old one if no "data_deps" were specified.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 376
355 bool TargetGenerator::FillGenericDeps(const char* var_name, 377 bool TargetGenerator::FillGenericDeps(const char* var_name,
356 LabelTargetVector* dest) { 378 LabelTargetVector* dest) {
357 const Value* value = scope_->GetValue(var_name, true); 379 const Value* value = scope_->GetValue(var_name, true);
358 if (value) { 380 if (value) {
359 ExtractListOfLabels(*value, scope_->GetSourceDir(), 381 ExtractListOfLabels(*value, scope_->GetSourceDir(),
360 ToolchainLabelForScope(scope_), dest, err_); 382 ToolchainLabelForScope(scope_), dest, err_);
361 } 383 }
362 return !err_->has_error(); 384 return !err_->has_error();
363 } 385 }
OLDNEW
« no previous file with comments | « tools/gn/target_generator.h ('k') | tools/gn/toolchain.h » ('j') | tools/gn/variables.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698