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

Side by Side Diff: tools/gn/functions_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: Add unit tests & support for bundle_data_filter Created 4 years, 10 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/functions.h" 5 #include "tools/gn/functions.h"
6 6
7 #include "tools/gn/config_values_generator.h" 7 #include "tools/gn/config_values_generator.h"
8 #include "tools/gn/err.h" 8 #include "tools/gn/err.h"
9 #include "tools/gn/parse_tree.h" 9 #include "tools/gn/parse_tree.h"
10 #include "tools/gn/scope.h" 10 #include "tools/gn/scope.h"
11 #include "tools/gn/target_generator.h" 11 #include "tools/gn/target_generator.h"
12 #include "tools/gn/template.h" 12 #include "tools/gn/template.h"
13 #include "tools/gn/value.h" 13 #include "tools/gn/value.h"
14 #include "tools/gn/variables.h" 14 #include "tools/gn/variables.h"
15 15
16 #define DEPENDENT_CONFIG_VARS \ 16 #define DEPENDENT_CONFIG_VARS \
17 " Dependent configs: all_dependent_configs, public_configs\n" 17 " Dependent configs: all_dependent_configs, public_configs\n"
18 #define DEPS_VARS \ 18 #define DEPS_VARS \
19 " Deps: data_deps, deps, public_deps\n" 19 " Deps: data_deps, deps, public_deps\n"
20 #define GENERAL_TARGET_VARS \ 20 #define GENERAL_TARGET_VARS \
21 " General: check_includes, configs, data, inputs, output_name,\n" \ 21 " General: bundle_data, check_includes, configs, data, inputs,\n" \
22 " output_extension, public, sources, testonly, visibility\n" 22 " output_name, output_extension, public, sources, testonly,\n" \
23 " visibility\n"
23 24
24 namespace functions { 25 namespace functions {
25 26
26 namespace { 27 namespace {
27 28
28 Value ExecuteGenericTarget(const char* target_type, 29 Value ExecuteGenericTarget(const char* target_type,
29 Scope* scope, 30 Scope* scope,
30 const FunctionCallNode* function, 31 const FunctionCallNode* function,
31 const std::vector<Value>& args, 32 const std::vector<Value>& args,
32 BlockNode* block, 33 BlockNode* block,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 const std::vector<Value>& args, 293 const std::vector<Value>& args,
293 Scope* scope, 294 Scope* scope,
294 Err* err) { 295 Err* err) {
295 if (!EnsureNotProcessingImport(function, scope, err) || 296 if (!EnsureNotProcessingImport(function, scope, err) ||
296 !EnsureNotProcessingBuildConfig(function, scope, err)) 297 !EnsureNotProcessingBuildConfig(function, scope, err))
297 return Value(); 298 return Value();
298 TargetGenerator::GenerateTarget(scope, function, args, functions::kCopy, err); 299 TargetGenerator::GenerateTarget(scope, function, args, functions::kCopy, err);
299 return Value(); 300 return Value();
300 } 301 }
301 302
303 // copy bundle data ------------------------------------------------------------
304
305 const char kCopyBundleData[] = "copy_bundle_data";
306 const char kCopyBundleData_HelpShort[] =
307 "copy_bundle_data: Declare a target that copy \"bundle_data\" files.";
308 const char kCopyBundleData_Help[] =
309 "copy_bundle_data: Declare a target that copy \"bundle_data\" files.\n"
310 "\n"
311 " Similar to the \"copy\" target, but the list of files to copy comes\n"
312 " from the \"bundle_data\" property of all dependencies recursively.\n"
313 " It can be used to copy files required at runtime by the application\n"
314 " into a location where it can be found.\n"
315 "\n"
316 " This uses the \"copy_bundle_data\" tool from the toolchain.\n"
317 "\n"
318 " See \"gn help copy\" for more information.\n"
319 "\n"
320 "Examples\n"
321 "\n"
322 " # A source_set that has a runtime dependency expressed as bundle_data\n"
323 " source_set(\"icu\") {\n"
324 " sources = [ \"icu.h\", \"icu.cc\" ]\n"
325 " bundle_data = [ \"icudtl.dat\" ]\n"
326 " }\n"
327 "\n"
328 " # Main application executable.\n"
329 " executable(\"app.app\") {\n"
330 " visibility = [ \":app\" ]\n"
331 " deps = [ \":icu\" ]\n"
332 " output_name = \"$root_build_dir/app.app/app\"\n"
333 " sources = [ \"main.cc\" ]\n"
334 " }\n"
335 "\n"
336 " # Copy runtime dependencies into the application bundle, filtering\n"
337 " # the .xcassets files as they need to be compiled into a .car file\n"
338 " # on Mac/iOS.\n"
339 " copy_bundle_data(\"app.bundle\") {\n"
340 " visibility = [ \":app\" ]\n"
341 " deps = [ \":icu\" ] # Same deps as the executable.\n"
342 " outputs = [ $root_build_dir/app.app/{{source_file_name}}\" ]\n"
343 " bundle_data_filter = [ \"*.xcassets\" ]\n"
344 " }\n"
345 "\n"
346 " # Main application target.\n"
347 " group(\"app\") {\n"
348 " deps = [ \":app.app\", \"app.bundle\" ]\n"
349 " }\n"
350 "";
351
352 Value RunCopyBundleData(const FunctionCallNode* function,
353 const std::vector<Value>& args,
354 Scope* scope,
355 Err* err) {
356 if (!EnsureNotProcessingImport(function, scope, err) ||
357 !EnsureNotProcessingBuildConfig(function, scope, err))
358 return Value();
359 TargetGenerator::GenerateTarget(scope, function, args,
360 functions::kCopyBundleData, err);
361 return Value();
362 }
363
302 // executable ------------------------------------------------------------------ 364 // executable ------------------------------------------------------------------
303 365
304 const char kExecutable[] = "executable"; 366 const char kExecutable[] = "executable";
305 const char kExecutable_HelpShort[] = 367 const char kExecutable_HelpShort[] =
306 "executable: Declare an executable target."; 368 "executable: Declare an executable target.";
307 const char kExecutable_Help[] = 369 const char kExecutable_Help[] =
308 "executable: Declare an executable target.\n" 370 "executable: Declare an executable target.\n"
309 "\n" 371 "\n"
310 "Variables\n" 372 "Variables\n"
311 "\n" 373 "\n"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 const Template* templ = scope->GetTemplate(target_type); 619 const Template* templ = scope->GetTemplate(target_type);
558 if (templ) 620 if (templ)
559 return templ->Invoke(scope, function, sub_args, block, err); 621 return templ->Invoke(scope, function, sub_args, block, err);
560 622
561 // Otherwise, assume the target is a built-in target type. 623 // Otherwise, assume the target is a built-in target type.
562 return ExecuteGenericTarget(target_type.c_str(), scope, function, sub_args, 624 return ExecuteGenericTarget(target_type.c_str(), scope, function, sub_args,
563 block, err); 625 block, err);
564 } 626 }
565 627
566 } // namespace functions 628 } // namespace functions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698