MCPcopy Create free account
hub / github.com/numpy/numpy / _cc_normalize_unix

Method _cc_normalize_unix

numpy/distutils/ccompiler_opt.py:1161–1208  ·  view source on GitHub ↗
(self, flags)

Source from the content-addressed store, hash-verified

1159 r"[0-9.]"
1160 )
1161 def _cc_normalize_unix(self, flags):
1162 def ver_flags(f):
1163 # arch ver subflag
1164 # -march=armv8.2-a+fp16fml
1165 tokens = f.split('+')
1166 ver = float('0' + ''.join(
1167 re.findall(self._cc_normalize_arch_ver, tokens[0])
1168 ))
1169 return ver, tokens[0], tokens[1:]
1170
1171 if len(flags) <= 1:
1172 return flags
1173 # get the highest matched flag
1174 for i, cur_flag in enumerate(reversed(flags)):
1175 if not re.match(self._cc_normalize_unix_mrgx, cur_flag):
1176 continue
1177 lower_flags = flags[:-(i+1)]
1178 upper_flags = flags[-i:]
1179 filtered = list(filter(
1180 self._cc_normalize_unix_frgx.search, lower_flags
1181 ))
1182 # gather subflags
1183 ver, arch, subflags = ver_flags(cur_flag)
1184 if ver > 0 and len(subflags) > 0:
1185 for xflag in lower_flags:
1186 xver, _, xsubflags = ver_flags(xflag)
1187 if ver == xver:
1188 subflags = xsubflags + subflags
1189 cur_flag = arch + '+' + '+'.join(subflags)
1190
1191 flags = filtered + [cur_flag]
1192 if i > 0:
1193 flags += upper_flags
1194 break
1195
1196 # to remove overridable flags
1197 final_flags = []
1198 matched = set()
1199 for f in reversed(flags):
1200 match = re.match(self._cc_normalize_unix_krgx, f)
1201 if not match:
1202 pass
1203 elif match[0] in matched:
1204 continue
1205 else:
1206 matched.add(match[0])
1207 final_flags.insert(0, f)
1208 return final_flags
1209
1210 _cc_normalize_win_frgx = re.compile(
1211 r"^(?!(/arch\:|/Qx\:))"

Callers 1

cc_normalize_flagsMethod · 0.95

Calls 2

joinMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected