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

Class XcodeArchsDefault

tools/gyp/pylib/gyp/xcode_emulation.py:40–93  ·  view source on GitHub ↗

A class to resolve ARCHS variable from xcode_settings, resolving Xcode macros and implementing filtering by VALID_ARCHS. The expansion of macros depends on the SDKROOT used ("macosx", "iphoneos", "iphonesimulator") and on the version of Xcode.

Source from the content-addressed store, hash-verified

38
39
40class XcodeArchsDefault:
41 """A class to resolve ARCHS variable from xcode_settings, resolving Xcode
42 macros and implementing filtering by VALID_ARCHS. The expansion of macros
43 depends on the SDKROOT used ("macosx", "iphoneos", "iphonesimulator") and
44 on the version of Xcode.
45 """
46
47 # Match variable like $(ARCHS_STANDARD).
48 variable_pattern = re.compile(r"\$\([a-zA-Z_][a-zA-Z0-9_]*\)$")
49
50 def __init__(self, default, mac, iphonesimulator, iphoneos):
51 self._default = (default,)
52 self._archs = {"mac": mac, "ios": iphoneos, "iossim": iphonesimulator}
53
54 def _VariableMapping(self, sdkroot):
55 """Returns the dictionary of variable mapping depending on the SDKROOT."""
56 sdkroot = sdkroot.lower()
57 if "iphoneos" in sdkroot:
58 return self._archs["ios"]
59 elif "iphonesimulator" in sdkroot:
60 return self._archs["iossim"]
61 else:
62 return self._archs["mac"]
63
64 def _ExpandArchs(self, archs, sdkroot):
65 """Expands variables references in ARCHS, and remove duplicates."""
66 variable_mapping = self._VariableMapping(sdkroot)
67 expanded_archs = []
68 for arch in archs:
69 if self.variable_pattern.match(arch):
70 variable = arch
71 try:
72 variable_expansion = variable_mapping[variable]
73 for arch in variable_expansion:
74 if arch not in expanded_archs:
75 expanded_archs.append(arch)
76 except KeyError:
77 print('Warning: Ignoring unsupported variable "%s".' % variable)
78 elif arch not in expanded_archs:
79 expanded_archs.append(arch)
80 return expanded_archs
81
82 def ActiveArchs(self, archs, valid_archs, sdkroot):
83 """Expands variables references in ARCHS, and filter by VALID_ARCHS if it
84 is defined (if not set, Xcode accept any value in ARCHS, otherwise, only
85 values present in VALID_ARCHS are kept)."""
86 expanded_archs = self._ExpandArchs(archs or self._default, sdkroot or "")
87 if valid_archs:
88 filtered_archs = []
89 for arch in expanded_archs:
90 if arch in valid_archs:
91 filtered_archs.append(arch)
92 expanded_archs = filtered_archs
93 return expanded_archs
94
95
96def GetXcodeArchsDefault():

Callers 1

GetXcodeArchsDefaultFunction · 0.85

Calls 1

compileMethod · 0.45

Tested by

no test coverage detected