| OLD | NEW |
| 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 Loading... |
| 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 |
| 320 |
| 321 Value RunCopyBundleData(const FunctionCallNode* function, |
| 322 const std::vector<Value>& args, |
| 323 Scope* scope, |
| 324 Err* err) { |
| 325 if (!EnsureNotProcessingImport(function, scope, err) || |
| 326 !EnsureNotProcessingBuildConfig(function, scope, err)) |
| 327 return Value(); |
| 328 TargetGenerator::GenerateTarget(scope, function, args, |
| 329 functions::kCopyBundleData, err); |
| 330 return Value(); |
| 331 } |
| 332 |
| 302 // executable ------------------------------------------------------------------ | 333 // executable ------------------------------------------------------------------ |
| 303 | 334 |
| 304 const char kExecutable[] = "executable"; | 335 const char kExecutable[] = "executable"; |
| 305 const char kExecutable_HelpShort[] = | 336 const char kExecutable_HelpShort[] = |
| 306 "executable: Declare an executable target."; | 337 "executable: Declare an executable target."; |
| 307 const char kExecutable_Help[] = | 338 const char kExecutable_Help[] = |
| 308 "executable: Declare an executable target.\n" | 339 "executable: Declare an executable target.\n" |
| 309 "\n" | 340 "\n" |
| 310 "Variables\n" | 341 "Variables\n" |
| 311 "\n" | 342 "\n" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 const Template* templ = scope->GetTemplate(target_type); | 588 const Template* templ = scope->GetTemplate(target_type); |
| 558 if (templ) | 589 if (templ) |
| 559 return templ->Invoke(scope, function, sub_args, block, err); | 590 return templ->Invoke(scope, function, sub_args, block, err); |
| 560 | 591 |
| 561 // Otherwise, assume the target is a built-in target type. | 592 // Otherwise, assume the target is a built-in target type. |
| 562 return ExecuteGenericTarget(target_type.c_str(), scope, function, sub_args, | 593 return ExecuteGenericTarget(target_type.c_str(), scope, function, sub_args, |
| 563 block, err); | 594 block, err); |
| 564 } | 595 } |
| 565 | 596 |
| 566 } // namespace functions | 597 } // namespace functions |
| OLD | NEW |