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

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

Issue 1342183003: Allow GN configs to have sub-configs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « tools/gn/target_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/variables.h" 5 #include "tools/gn/variables.h"
6 6
7 namespace variables { 7 namespace variables {
8 8
9 // Built-in variables ---------------------------------------------------------- 9 // Built-in variables ----------------------------------------------------------
10 10
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 " action(\"myscript\") {\n" 299 " action(\"myscript\") {\n"
300 " # Pass the output dir to the script.\n" 300 " # Pass the output dir to the script.\n"
301 " args = [ \"-o\", rebase_path(target_out_dir, root_build_dir) ]" 301 " args = [ \"-o\", rebase_path(target_out_dir, root_build_dir) ]"
302 "\n" 302 "\n"
303 " }\n"; 303 " }\n";
304 304
305 // Target variables ------------------------------------------------------------ 305 // Target variables ------------------------------------------------------------
306 306
307 #define COMMON_ORDERING_HELP \ 307 #define COMMON_ORDERING_HELP \
308 "\n" \ 308 "\n" \
309 "Ordering of flags and values:\n" \ 309 "Ordering of flags and values\n" \
310 "\n" \ 310 "\n" \
311 " 1. Those set on the current target (not in a config).\n" \ 311 " 1. Those set on the current target (not in a config).\n" \
312 " 2. Those set on the \"configs\" on the target in order that the\n" \ 312 " 2. Those set on the \"configs\" on the target in order that the\n" \
313 " configs appear in the list.\n" \ 313 " configs appear in the list.\n" \
314 " 3. Those set on the \"all_dependent_configs\" on the target in order\n" \ 314 " 3. Those set on the \"all_dependent_configs\" on the target in order\n" \
315 " that the configs appear in the list.\n" \ 315 " that the configs appear in the list.\n" \
316 " 4. Those set on the \"public_configs\" on the target in order that\n" \ 316 " 4. Those set on the \"public_configs\" on the target in order that\n" \
317 " those configs appear in the list.\n" \ 317 " those configs appear in the list.\n" \
318 " 5. all_dependent_configs pulled from dependencies, in the order of\n" \ 318 " 5. all_dependent_configs pulled from dependencies, in the order of\n" \
319 " the \"deps\" list. This is done recursively. If a config appears\n" \ 319 " the \"deps\" list. This is done recursively. If a config appears\n" \
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 "\n" 494 "\n"
495 "Example\n" 495 "Example\n"
496 "\n" 496 "\n"
497 " static_library(\"foo\") {\n" 497 " static_library(\"foo\") {\n"
498 " complete_static_lib = true\n" 498 " complete_static_lib = true\n"
499 " deps = [ \"bar\" ]\n" 499 " deps = [ \"bar\" ]\n"
500 " }\n"; 500 " }\n";
501 501
502 const char kConfigs[] = "configs"; 502 const char kConfigs[] = "configs";
503 const char kConfigs_HelpShort[] = 503 const char kConfigs_HelpShort[] =
504 "configs: [label list] Configs applying to this target."; 504 "configs: [label list] Configs applying to this target or config.";
505 const char kConfigs_Help[] = 505 const char kConfigs_Help[] =
506 "configs: Configs applying to this target.\n" 506 "configs: Configs applying to this target or config.\n"
507 "\n" 507 "\n"
508 " A list of config labels.\n" 508 " A list of config labels.\n"
509 "\n" 509 "\n"
510 " The include_dirs, defines, etc. in each config are appended in the\n" 510 "Configs on a target\n"
511 " order they appear to the compile command for each file in the target.\n" 511 "\n"
512 " They will appear after the include_dirs, defines, etc. that the target\n" 512 " When used on a target, the include_dirs, defines, etc. in each config\n"
513 " sets directly.\n" 513 " are appended in the order they appear to the compile command for each\n"
514 " file in the target. They will appear after the include_dirs, defines,\n"
515 " etc. that the target sets directly.\n"
516 "\n"
517 " Since configs apply after the values set on a target, directly setting\n"
518 " a compiler flag will prepend it to the command line. If you want to\n"
519 " append a flag instead, you can put that flag in a one-off config and\n"
520 " append that config to the target's configs list.\n"
514 "\n" 521 "\n"
515 " The build configuration script will generally set up the default\n" 522 " The build configuration script will generally set up the default\n"
516 " configs applying to a given target type (see \"set_defaults\").\n" 523 " configs applying to a given target type (see \"set_defaults\").\n"
517 " When a target is being defined, it can add to or remove from this\n" 524 " When a target is being defined, it can add to or remove from this\n"
518 " list.\n" 525 " list.\n"
526 "\n"
527 "Configs on a config\n"
528 "\n"
529 " It is possible to create composite configs by specifying configs on a\n"
530 " config. One might do this to forward values, or to factor out blocks\n"
531 " of settings from very large configs into more manageable named chunks.\n"
532 "\n"
533 " In this case, the composite config is expanded to be the concatenation\n"
534 " of its own values, and in order, the values from its sub-configs\n"
535 " *before* anything else happens. This has some ramifications:\n"
536 "\n"
537 " - A target has no visibility into a config's sub-configs. Target\n"
538 " code only sees the name of the composite config. It can't remove\n"
539 " sub-configs or opt in to only parts of it. The composite config may\n"
540 " not even be defined before the target is.\n"
541 "\n"
542 " - You can get duplication of values if a config is listed twice, say,\n"
543 " on a target and in a sub-config that also applies. In other cases,\n"
544 " the configs applying to a target are de-duped. It's expected that\n"
545 " if a config is listed as a sub-config that it is only used in that\n"
546 " context. (Note that it's possible to fix this and de-dupe, but it's\n"
547 " not normally relevant and complicates the implementation.)\n"
519 COMMON_ORDERING_HELP 548 COMMON_ORDERING_HELP
520 "\n" 549 "\n"
521 "Example:\n" 550 "Example\n"
522 " static_library(\"foo\") {\n" 551 "\n"
523 " configs -= \"//build:no_rtti\" # Don't use the default RTTI config.\n" 552 " # Configs on a target.\n"
524 " configs += \":mysettings\" # Add some of our own settings.\n" 553 " source_set(\"foo\") {\n"
554 " # Don't use the default RTTI config that BUILDCONFIG applied to us.\n"
555 " configs -= [ \"//build:no_rtti\" ]\n"
556 "\n"
557 " # Add some of our own settings.\n"
558 " configs += [ \":mysettings\" ]\n"
559 " }\n"
560 "\n"
561 " # Create a default_optimization config that forwards to one of a set\n"
562 " # of more specialized configs depending on build flags. This pattern\n"
563 " # is useful because it allows a target to opt in to either a default\n"
564 " # set, or a more specific set, while avoid duplicating the settings in\n"
565 " # two places.\n"
566 " config(\"super_optimization\") {\n"
567 " cflags = [ ... ]\n"
568 " }\n"
569 " config(\"default_optimization\") {\n"
570 " if (optimize_everything) {\n"
571 " configs = [ \":super_optimization\" ]\n"
572 " } else {\n"
573 " configs = [ \":no_optimization\" ]\n"
574 " }\n"
525 " }\n"; 575 " }\n";
526 576
527 const char kData[] = "data"; 577 const char kData[] = "data";
528 const char kData_HelpShort[] = 578 const char kData_HelpShort[] =
529 "data: [file list] Runtime data file dependencies."; 579 "data: [file list] Runtime data file dependencies.";
530 const char kData_Help[] = 580 const char kData_Help[] =
531 "data: Runtime data file dependencies.\n" 581 "data: Runtime data file dependencies.\n"
532 "\n" 582 "\n"
533 " Lists files or directories required to run the given target. These are\n" 583 " Lists files or directories required to run the given target. These are\n"
534 " typically data files or directories of data files. The paths are\n" 584 " typically data files or directories of data files. The paths are\n"
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 INSERT_VARIABLE(Sources) 1272 INSERT_VARIABLE(Sources)
1223 INSERT_VARIABLE(Testonly) 1273 INSERT_VARIABLE(Testonly)
1224 INSERT_VARIABLE(Visibility) 1274 INSERT_VARIABLE(Visibility)
1225 } 1275 }
1226 return info_map; 1276 return info_map;
1227 } 1277 }
1228 1278
1229 #undef INSERT_VARIABLE 1279 #undef INSERT_VARIABLE
1230 1280
1231 } // namespace variables 1281 } // namespace variables
OLDNEW
« no previous file with comments | « tools/gn/target_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698