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

Side by Side Diff: tools/gn/functions_target.cc

Issue 1386783003: [GN]: Support for loadable modules (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 348
349 Value RunGroup(Scope* scope, 349 Value RunGroup(Scope* scope,
350 const FunctionCallNode* function, 350 const FunctionCallNode* function,
351 const std::vector<Value>& args, 351 const std::vector<Value>& args,
352 BlockNode* block, 352 BlockNode* block,
353 Err* err) { 353 Err* err) {
354 return ExecuteGenericTarget(functions::kGroup, scope, function, args, 354 return ExecuteGenericTarget(functions::kGroup, scope, function, args,
355 block, err); 355 block, err);
356 } 356 }
357 357
358 // loadable_module -------------------------------------------------------------
359
360 const char kLoadableModule[] = "loadable_module";
361 const char kLoadableModule_HelpShort[] =
362 "loadable_module: Declare a loadable module target.";
363 const char kLoadableModule_Help[] =
364 "loadable_module: Declare a loadable module target.\n"
365 "\n"
366 " This target type allows you to create an object file that is (and can\n"
367 " only be) loaded and unloaded at runtime.\n"
368 "\n"
369 " A loadable module will be specified on the linker line for targets\n"
370 " listing the loadable module in its \"deps\". If you don't want this\n"
371 " (if you don't need to dynamically load the library at runtime), then\n"
372 " you should use a \"shared_library\" target type instead.\n"
373 "\n"
374 "Variables\n"
375 "\n"
376 CONFIG_VALUES_VARS_HELP
377 DEPS_VARS
378 DEPENDENT_CONFIG_VARS
379 GENERAL_TARGET_VARS;
380
381 Value RunLoadableModule(Scope* scope,
382 const FunctionCallNode* function,
383 const std::vector<Value>& args,
384 BlockNode* block,
385 Err* err) {
386 return ExecuteGenericTarget(functions::kLoadableModule, scope, function, args,
387 block, err);
388 }
389
358 // shared_library -------------------------------------------------------------- 390 // shared_library --------------------------------------------------------------
359 391
360 const char kSharedLibrary[] = "shared_library"; 392 const char kSharedLibrary[] = "shared_library";
361 const char kSharedLibrary_HelpShort[] = 393 const char kSharedLibrary_HelpShort[] =
362 "shared_library: Declare a shared library target."; 394 "shared_library: Declare a shared library target.";
363 const char kSharedLibrary_Help[] = 395 const char kSharedLibrary_Help[] =
364 "shared_library: Declare a shared library target.\n" 396 "shared_library: Declare a shared library target.\n"
365 "\n" 397 "\n"
366 " A shared library will be specified on the linker line for targets\n" 398 " A shared library will be specified on the linker line for targets\n"
367 " listing the shared library in its \"deps\". If you don't want this\n" 399 " listing the shared library in its \"deps\". If you don't want this\n"
368 " (say you dynamically load the library at runtime), then you should\n" 400 " (say you dynamically load the library at runtime), then you should\n"
369 " depend on the shared library via \"data_deps\" instead.\n" 401 " depend on the shared library via \"data_deps\" or, on Darwin\n"
402 " platforms, use a \"loadable_module\" target type instead.\n"
370 "\n" 403 "\n"
371 "Variables\n" 404 "Variables\n"
372 "\n" 405 "\n"
373 CONFIG_VALUES_VARS_HELP 406 CONFIG_VALUES_VARS_HELP
374 DEPS_VARS 407 DEPS_VARS
375 DEPENDENT_CONFIG_VARS 408 DEPENDENT_CONFIG_VARS
376 GENERAL_TARGET_VARS; 409 GENERAL_TARGET_VARS;
377 410
378 Value RunSharedLibrary(Scope* scope, 411 Value RunSharedLibrary(Scope* scope,
379 const FunctionCallNode* function, 412 const FunctionCallNode* function,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 "\n" 527 "\n"
495 " target(my_type, \"foo\") {\n" 528 " target(my_type, \"foo\") {\n"
496 " ...\n" 529 " ...\n"
497 " }\n"; 530 " }\n";
498 Value RunTarget(Scope* scope, 531 Value RunTarget(Scope* scope,
499 const FunctionCallNode* function, 532 const FunctionCallNode* function,
500 const std::vector<Value>& args, 533 const std::vector<Value>& args,
501 BlockNode* block, 534 BlockNode* block,
502 Err* err) { 535 Err* err) {
503 if (args.size() != 2) { 536 if (args.size() != 2) {
504 *err = Err(function, "Expected two arguments.", 537 *err = Err(function, "Expected two arguments.", "Try \"gn help target\".");
505 "Dude, try \"gn help target\".");
506 return Value(); 538 return Value();
507 } 539 }
508 540
509 // The first argument must be a string (the target type). Don't type-check 541 // The first argument must be a string (the target type). Don't type-check
510 // the second argument since the target-specific function will do that. 542 // the second argument since the target-specific function will do that.
511 if (!args[0].VerifyTypeIs(Value::STRING, err)) 543 if (!args[0].VerifyTypeIs(Value::STRING, err))
512 return Value(); 544 return Value();
513 const std::string& target_type = args[0].string_value(); 545 const std::string& target_type = args[0].string_value();
514 546
515 // The rest of the args are passed to the function. 547 // The rest of the args are passed to the function.
516 std::vector<Value> sub_args(args.begin() + 1, args.end()); 548 std::vector<Value> sub_args(args.begin() + 1, args.end());
517 549
518 // Run a template if it is one. 550 // Run a template if it is one.
519 const Template* templ = scope->GetTemplate(target_type); 551 const Template* templ = scope->GetTemplate(target_type);
520 if (templ) 552 if (templ)
521 return templ->Invoke(scope, function, sub_args, block, err); 553 return templ->Invoke(scope, function, sub_args, block, err);
522 554
523 // Otherwise, assume the target is a built-in target type. 555 // Otherwise, assume the target is a built-in target type.
524 return ExecuteGenericTarget(target_type.c_str(), scope, function, sub_args, 556 return ExecuteGenericTarget(target_type.c_str(), scope, function, sub_args,
525 block, err); 557 block, err);
526 } 558 }
527 559
528 } // namespace functions 560 } // namespace functions
OLDNEW
« tools/gn/function_toolchain.cc ('K') | « tools/gn/functions.cc ('k') | tools/gn/gn.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698