MCPcopy Create free account
hub / github.com/nodejs/node / SetUpConfigurations

Function SetUpConfigurations

tools/gyp/pylib/gyp/input.py:2414–2488  ·  view source on GitHub ↗
(target, target_dict)

Source from the content-addressed store, hash-verified

2412
2413
2414def SetUpConfigurations(target, target_dict):
2415 # key_suffixes is a list of key suffixes that might appear on key names.
2416 # These suffixes are handled in conditional evaluations (for =, +, and ?)
2417 # and rules/exclude processing (for ! and /). Keys with these suffixes
2418 # should be treated the same as keys without.
2419 key_suffixes = ["=", "+", "?", "!", "/"]
2420
2421 build_file = gyp.common.BuildFile(target)
2422
2423 # Provide a single configuration by default if none exists.
2424 # TODO(mark): Signal an error if default_configurations exists but
2425 # configurations does not.
2426 if "configurations" not in target_dict:
2427 target_dict["configurations"] = {"Default": {}}
2428 if "default_configuration" not in target_dict:
2429 concrete = [
2430 i
2431 for (i, config) in target_dict["configurations"].items()
2432 if not config.get("abstract")
2433 ]
2434 target_dict["default_configuration"] = sorted(concrete)[0]
2435
2436 merged_configurations = {}
2437 configs = target_dict["configurations"]
2438 for configuration, old_configuration_dict in configs.items():
2439 # Skip abstract configurations (saves work only).
2440 if old_configuration_dict.get("abstract"):
2441 continue
2442 # Configurations inherit (most) settings from the enclosing target scope.
2443 # Get the inheritance relationship right by making a copy of the target
2444 # dict.
2445 new_configuration_dict = {}
2446 for key, target_val in target_dict.items():
2447 key_ext = key[-1:]
2448 key_base = key[:-1] if key_ext in key_suffixes else key
2449 if key_base not in non_configuration_keys:
2450 new_configuration_dict[key] = gyp.simple_copy.deepcopy(target_val)
2451
2452 # Merge in configuration (with all its parents first).
2453 MergeConfigWithInheritance(
2454 new_configuration_dict, build_file, target_dict, configuration, []
2455 )
2456
2457 merged_configurations[configuration] = new_configuration_dict
2458
2459 # Put the new configurations back into the target dict as a configuration.
2460 for configuration, value in merged_configurations.items():
2461 target_dict["configurations"][configuration] = value
2462 # Now drop all the abstract ones.
2463 configs = target_dict["configurations"]
2464 target_dict["configurations"] = {
2465 k: v for k, v in configs.items() if not v.get("abstract")
2466 }
2467
2468 # Now that all of the target's configurations have been built, go through
2469 # the target dict's keys and remove everything that's been moved into a
2470 # "configurations" section.
2471 delete_keys = []

Callers 1

LoadFunction · 0.85

Calls 6

GypErrorClass · 0.90
sortedFunction · 0.85
getMethod · 0.65
itemsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected