MCPcopy Index your code
hub / github.com/nodejs/node / ProcessVariablesAndConditionsInDict

Function ProcessVariablesAndConditionsInDict

tools/gyp/pylib/gyp/input.py:1284–1398  ·  view source on GitHub ↗

Handle all variable and command expansion and conditional evaluation. This function is the public entry point for all variable expansions and conditional evaluations. The variables_in dictionary will not be modified by this function.

(
    the_dict, phase, variables_in, build_file, the_dict_key=None
)

Source from the content-addressed store, hash-verified

1282
1283
1284def ProcessVariablesAndConditionsInDict(
1285 the_dict, phase, variables_in, build_file, the_dict_key=None
1286):
1287 """Handle all variable and command expansion and conditional evaluation.
1288
1289 This function is the public entry point for all variable expansions and
1290 conditional evaluations. The variables_in dictionary will not be modified
1291 by this function.
1292 """
1293
1294 # Make a copy of the variables_in dict that can be modified during the
1295 # loading of automatics and the loading of the variables dict.
1296 variables = variables_in.copy()
1297 LoadAutomaticVariablesFromDict(variables, the_dict)
1298
1299 if "variables" in the_dict:
1300 # Make sure all the local variables are added to the variables
1301 # list before we process them so that you can reference one
1302 # variable from another. They will be fully expanded by recursion
1303 # in ExpandVariables.
1304 for key, value in the_dict["variables"].items():
1305 variables[key] = value
1306
1307 # Handle the associated variables dict first, so that any variable
1308 # references within can be resolved prior to using them as variables.
1309 # Pass a copy of the variables dict to avoid having it be tainted.
1310 # Otherwise, it would have extra automatics added for everything that
1311 # should just be an ordinary variable in this scope.
1312 ProcessVariablesAndConditionsInDict(
1313 the_dict["variables"], phase, variables, build_file, "variables"
1314 )
1315
1316 LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key)
1317
1318 for key, value in the_dict.items():
1319 # Skip "variables", which was already processed if present.
1320 if key != "variables" and isinstance(value, str):
1321 expanded = ExpandVariables(value, phase, variables, build_file)
1322 if type(expanded) not in (str, int):
1323 raise ValueError(
1324 "Variable expansion in this context permits str and int "
1325 + "only, found "
1326 + expanded.__class__.__name__
1327 + " for "
1328 + key
1329 )
1330 the_dict[key] = expanded
1331
1332 # Variable expansion may have resulted in changes to automatics. Reload.
1333 # TODO(mark): Optimization: only reload if no changes were made.
1334 variables = variables_in.copy()
1335 LoadAutomaticVariablesFromDict(variables, the_dict)
1336 LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key)
1337
1338 # Process conditions in this dict. This is done after variable expansion
1339 # so that conditions may take advantage of expanded variables. For example,
1340 # if the_dict contains:
1341 # {'type': '<(library_type)',

Callers 4

LoadTargetBuildFileFunction · 0.85
ProcessConditionsInDictFunction · 0.85
LoadFunction · 0.85

Calls 8

ExpandVariablesFunction · 0.85
ProcessConditionsInDictFunction · 0.85
copyMethod · 0.65
typeFunction · 0.50
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…