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

Function _GetMSBuildPropertyGroup

tools/gyp/pylib/gyp/generator/msvs.py:3258–3311  ·  view source on GitHub ↗

Returns a PropertyGroup definition for the specified properties. Arguments: spec: The target project dict. label: An optional label for the PropertyGroup. properties: The dictionary to be converted. The key is the name of the property. The value is itself a diction

(spec, label, properties)

Source from the content-addressed store, hash-verified

3256
3257
3258def _GetMSBuildPropertyGroup(spec, label, properties):
3259 """Returns a PropertyGroup definition for the specified properties.
3260
3261 Arguments:
3262 spec: The target project dict.
3263 label: An optional label for the PropertyGroup.
3264 properties: The dictionary to be converted. The key is the name of the
3265 property. The value is itself a dictionary; its key is the value and
3266 the value a list of condition for which this value is true.
3267 """
3268 group = ["PropertyGroup"]
3269 if label:
3270 group.append({"Label": label})
3271 num_configurations = len(spec["configurations"])
3272
3273 def GetEdges(node):
3274 # Use a definition of edges such that user_of_variable -> used_variable.
3275 # This happens to be easier in this case, since a variable's
3276 # definition contains all variables it references in a single string.
3277 edges = set()
3278 for value in sorted(properties[node].keys()):
3279 # Add to edges all $(...) references to variables.
3280 #
3281 # Variable references that refer to names not in properties are excluded
3282 # These can exist for instance to refer built in definitions like
3283 # $(SolutionDir).
3284 #
3285 # Self references are ignored. Self reference is used in a few places to
3286 # append to the default value. I.e. PATH=$(PATH);other_path
3287 edges.update(
3288 {
3289 v
3290 for v in MSVS_VARIABLE_REFERENCE.findall(value)
3291 if v in properties and v != node
3292 }
3293 )
3294 return edges
3295
3296 properties_ordered = gyp.common.TopologicallySorted(properties.keys(), GetEdges)
3297 # Walk properties in the reverse of a topological sort on
3298 # user_of_variable -> used_variable as this ensures variables are
3299 # defined before they are used.
3300 # NOTE: reverse(topsort(DAG)) = topsort(reverse_edges(DAG))
3301 for name in reversed(properties_ordered):
3302 values = properties[name]
3303 for value, conditions in sorted(values.items()):
3304 if len(conditions) == num_configurations:
3305 # If the value is the same all configurations,
3306 # just add one unconditional entry.
3307 group.append([name, value])
3308 else:
3309 for condition in conditions:
3310 group.append([name, {"Condition": condition}, value])
3311 return [group]
3312
3313
3314def _GetMSBuildToolSettingsSections(spec, configurations):

Calls 4

sortedFunction · 0.85
keysMethod · 0.65
appendMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected