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

Side by Side Diff: tools/gn/target.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.h" 5 #include "tools/gn/target.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 case LOADABLE_MODULE: 131 case LOADABLE_MODULE:
132 return "Loadable module"; 132 return "Loadable module";
133 case SHARED_LIBRARY: 133 case SHARED_LIBRARY:
134 return "Shared library"; 134 return "Shared library";
135 case STATIC_LIBRARY: 135 case STATIC_LIBRARY:
136 return "Static library"; 136 return "Static library";
137 case SOURCE_SET: 137 case SOURCE_SET:
138 return "Source set"; 138 return "Source set";
139 case COPY_FILES: 139 case COPY_FILES:
140 return "Copy"; 140 return "Copy";
141 case COPY_BUNDLE_DATA:
142 return "Copy bundle data";
141 case ACTION: 143 case ACTION:
142 return "Action"; 144 return "Action";
143 case ACTION_FOREACH: 145 case ACTION_FOREACH:
144 return "ActionForEach"; 146 return "ActionForEach";
145 default: 147 default:
146 return ""; 148 return "";
147 } 149 }
148 } 150 }
149 151
150 Target* Target::AsTarget() { 152 Target* Target::AsTarget() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // This needs to happen after we pull dependent target configs for the 190 // This needs to happen after we pull dependent target configs for the
189 // public config's libs to be included here. And it needs to happen 191 // public config's libs to be included here. And it needs to happen
190 // before pulling the dependent target libs so the libs are in the correct 192 // before pulling the dependent target libs so the libs are in the correct
191 // order (local ones first, then the dependency's). 193 // order (local ones first, then the dependency's).
192 for (ConfigValuesIterator iter(this); !iter.done(); iter.Next()) { 194 for (ConfigValuesIterator iter(this); !iter.done(); iter.Next()) {
193 const ConfigValues& cur = iter.cur(); 195 const ConfigValues& cur = iter.cur();
194 all_lib_dirs_.append(cur.lib_dirs().begin(), cur.lib_dirs().end()); 196 all_lib_dirs_.append(cur.lib_dirs().begin(), cur.lib_dirs().end());
195 all_libs_.append(cur.libs().begin(), cur.libs().end()); 197 all_libs_.append(cur.libs().begin(), cur.libs().end());
196 } 198 }
197 199
200 PullRecursiveBundleData();
198 PullDependentTargetLibs(); 201 PullDependentTargetLibs();
199 PullRecursiveHardDeps(); 202 PullRecursiveHardDeps();
200 if (!ResolvePrecompiledHeaders(err)) 203 if (!ResolvePrecompiledHeaders(err))
201 return false; 204 return false;
202 205
203 FillOutputFiles(); 206 FillOutputFiles();
204 207
205 if (settings()->build_settings()->check_for_bad_items()) { 208 if (settings()->build_settings()->check_for_bad_items()) {
206 if (!CheckVisibility(err)) 209 if (!CheckVisibility(err))
207 return false; 210 return false;
(...skipping 11 matching lines...) Expand all
219 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; 222 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY;
220 } 223 }
221 224
222 bool Target::IsFinal() const { 225 bool Target::IsFinal() const {
223 return output_type_ == EXECUTABLE || 226 return output_type_ == EXECUTABLE ||
224 output_type_ == SHARED_LIBRARY || 227 output_type_ == SHARED_LIBRARY ||
225 output_type_ == LOADABLE_MODULE || 228 output_type_ == LOADABLE_MODULE ||
226 output_type_ == ACTION || 229 output_type_ == ACTION ||
227 output_type_ == ACTION_FOREACH || 230 output_type_ == ACTION_FOREACH ||
228 output_type_ == COPY_FILES || 231 output_type_ == COPY_FILES ||
232 output_type_ == COPY_BUNDLE_DATA ||
229 (output_type_ == STATIC_LIBRARY && complete_static_lib_); 233 (output_type_ == STATIC_LIBRARY && complete_static_lib_);
230 } 234 }
231 235
232 DepsIteratorRange Target::GetDeps(DepsIterationType type) const { 236 DepsIteratorRange Target::GetDeps(DepsIterationType type) const {
233 if (type == DEPS_LINKED) { 237 if (type == DEPS_LINKED) {
234 return DepsIteratorRange(DepsIterator( 238 return DepsIteratorRange(DepsIterator(
235 &public_deps_, &private_deps_, nullptr)); 239 &public_deps_, &private_deps_, nullptr));
236 } 240 }
237 // All deps. 241 // All deps.
238 return DepsIteratorRange(DepsIterator( 242 return DepsIteratorRange(DepsIterator(
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Direct hard dependencies. 353 // Direct hard dependencies.
350 if (pair.ptr->hard_dep()) 354 if (pair.ptr->hard_dep())
351 recursive_hard_deps_.insert(pair.ptr); 355 recursive_hard_deps_.insert(pair.ptr);
352 356
353 // Recursive hard dependencies of all dependencies. 357 // Recursive hard dependencies of all dependencies.
354 recursive_hard_deps_.insert(pair.ptr->recursive_hard_deps().begin(), 358 recursive_hard_deps_.insert(pair.ptr->recursive_hard_deps().begin(),
355 pair.ptr->recursive_hard_deps().end()); 359 pair.ptr->recursive_hard_deps().end());
356 } 360 }
357 } 361 }
358 362
363 void Target::PullRecursiveBundleData() {
364 for (const auto& pair : GetDeps(DEPS_LINKED)) {
365 if (pair.ptr->output_type() == EXECUTABLE ||
366 pair.ptr->output_type() == SHARED_LIBRARY ||
367 pair.ptr->output_type() == LOADABLE_MODULE ||
368 pair.ptr->output_type() == COPY_BUNDLE_DATA)
369 continue;
370
371 bundle_data_.insert(pair.ptr->bundle_data().begin(),
372 pair.ptr->bundle_data().end());
373 }
374
375 if (output_type_ != COPY_BUNDLE_DATA)
376 return;
377
378 // TODO(sdefresne): .xcasset needs to have a specific treatment. This will
379 // requires a second target using the "bundle_data" information, and for a
380 // way to filter out .xcasset from "copy_bundle_data".
381 sources_.insert(sources_.end(), bundle_data_.begin(), bundle_data_.end());
382 }
383
359 void Target::FillOutputFiles() { 384 void Target::FillOutputFiles() {
360 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); 385 const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this);
361 bool check_tool_outputs = false; 386 bool check_tool_outputs = false;
362 switch (output_type_) { 387 switch (output_type_) {
363 case GROUP: 388 case GROUP:
364 case SOURCE_SET: 389 case SOURCE_SET:
365 case COPY_FILES: 390 case COPY_FILES:
391 case COPY_BUNDLE_DATA:
366 case ACTION: 392 case ACTION:
367 case ACTION_FOREACH: { 393 case ACTION_FOREACH: {
368 // These don't get linked to and use stamps which should be the first 394 // These don't get linked to and use stamps which should be the first
369 // entry in the outputs. These stamps are named 395 // entry in the outputs. These stamps are named
370 // "<target_out_dir>/<targetname>.stamp". 396 // "<target_out_dir>/<targetname>.stamp".
371 dependency_output_file_ = GetTargetOutputDirAsOutputFile(this); 397 dependency_output_file_ = GetTargetOutputDirAsOutputFile(this);
372 dependency_output_file_.value().append(GetComputedOutputName(true)); 398 dependency_output_file_.value().append(GetComputedOutputName(true));
373 dependency_output_file_.value().append(".stamp"); 399 dependency_output_file_.value().append(".stamp");
374 break; 400 break;
375 } 401 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 return; // Not in output dir, this is OK. 590 return; // Not in output dir, this is OK.
565 591
566 // Tell the scheduler about unknown files. This will be noted for later so 592 // Tell the scheduler about unknown files. This will be noted for later so
567 // the list of files written by the GN build itself (often response files) 593 // the list of files written by the GN build itself (often response files)
568 // can be filtered out of this list. 594 // can be filtered out of this list.
569 OutputFile out_file(settings()->build_settings(), source); 595 OutputFile out_file(settings()->build_settings(), source);
570 std::set<const Target*> seen_targets; 596 std::set<const Target*> seen_targets;
571 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, &seen_targets)) 597 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, &seen_targets))
572 g_scheduler->AddUnknownGeneratedInput(this, source); 598 g_scheduler->AddUnknownGeneratedInput(this, source);
573 } 599 }
OLDNEW
« no previous file with comments | « tools/gn/target.h ('k') | tools/gn/target_generator.h » ('j') | tools/gn/variables.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698