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, forward_dependent_configs_from, public_deps\n" | 19 " Deps: data_deps, deps, forward_dependent_configs_from, 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: check_includes, configs, data, inputs, output_name,\n" \ |
22 " output_extension, public, sources, testonly, visibility\n" | 22 " output_extension, public, sources, testonly, visibility,\n" \ |
| 23 " loadable_module, darwin_bundle\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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 "\n" | 497 "\n" |
497 " target(my_type, \"foo\") {\n" | 498 " target(my_type, \"foo\") {\n" |
498 " ...\n" | 499 " ...\n" |
499 " }\n"; | 500 " }\n"; |
500 Value RunTarget(Scope* scope, | 501 Value RunTarget(Scope* scope, |
501 const FunctionCallNode* function, | 502 const FunctionCallNode* function, |
502 const std::vector<Value>& args, | 503 const std::vector<Value>& args, |
503 BlockNode* block, | 504 BlockNode* block, |
504 Err* err) { | 505 Err* err) { |
505 if (args.size() != 2) { | 506 if (args.size() != 2) { |
506 *err = Err(function, "Expected two arguments.", | 507 *err = Err(function, "Expected two arguments. Try \"gn help target\"."); |
507 "Dude, try \"gn help target\"."); | |
508 return Value(); | 508 return Value(); |
509 } | 509 } |
510 | 510 |
511 // The first argument must be a string (the target type). Don't type-check | 511 // The first argument must be a string (the target type). Don't type-check |
512 // the second argument since the target-specific function will do that. | 512 // the second argument since the target-specific function will do that. |
513 if (!args[0].VerifyTypeIs(Value::STRING, err)) | 513 if (!args[0].VerifyTypeIs(Value::STRING, err)) |
514 return Value(); | 514 return Value(); |
515 const std::string& target_type = args[0].string_value(); | 515 const std::string& target_type = args[0].string_value(); |
516 | 516 |
517 // The rest of the args are passed to the function. | 517 // The rest of the args are passed to the function. |
518 std::vector<Value> sub_args(args.begin() + 1, args.end()); | 518 std::vector<Value> sub_args(args.begin() + 1, args.end()); |
519 | 519 |
520 // Run a template if it is one. | 520 // Run a template if it is one. |
521 const Template* templ = scope->GetTemplate(target_type); | 521 const Template* templ = scope->GetTemplate(target_type); |
522 if (templ) | 522 if (templ) |
523 return templ->Invoke(scope, function, sub_args, block, err); | 523 return templ->Invoke(scope, function, sub_args, block, err); |
524 | 524 |
525 // Otherwise, assume the target is a built-in target type. | 525 // Otherwise, assume the target is a built-in target type. |
526 return ExecuteGenericTarget(target_type.c_str(), scope, function, sub_args, | 526 return ExecuteGenericTarget(target_type.c_str(), scope, function, sub_args, |
527 block, err); | 527 block, err); |
528 } | 528 } |
529 | 529 |
530 } // namespace functions | 530 } // namespace functions |
OLD | NEW |