MCPcopy Create free account
hub / github.com/doldecomp/mkdd / try_replace

Function try_replace

tools/project.py:1913–1936  ·  view source on GitHub ↗
(flag: str)

Source from the content-addressed store, hash-verified

1911
1912 # Attempts replacement for the given flag.
1913 def try_replace(flag: str) -> bool:
1914 replacement = CFLAG_REPLACE.get(flag)
1915 if replacement is not None:
1916 cflags.append(replacement)
1917 return True
1918
1919 for prefix, replacement in CFLAG_REPLACE_PREFIX:
1920 if flag.startswith(prefix):
1921 cflags.append(flag.replace(prefix, replacement, 1))
1922 return True
1923
1924 for prefix, options in CFLAG_REPLACE_OPTIONS:
1925 if not flag.startswith(prefix):
1926 continue
1927
1928 # "-lang c99" and "-lang=c99" are both generally valid option forms
1929 option = flag.removeprefix(prefix).removeprefix("=").lstrip()
1930 replacements = options.get(option)
1931 if replacements is not None:
1932 cflags.extend(replacements)
1933
1934 return True
1935
1936 return False
1937
1938 for flag in flags:
1939 # Ignore flags first

Callers 1

append_cflagsFunction · 0.85

Calls 2

getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected