cmake scripts: do not redefine built-ins

Try not to override built-ins, the code becomes confusing to editors and people.

Change-Id: I9e9421e1506a206551ccfc550f882a075e208181
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
This commit is contained in:
Frederik Gladhorn 2019-10-08 15:07:41 +02:00
parent f7bb15a11b
commit b7adc85642
3 changed files with 19 additions and 19 deletions

View File

@ -147,8 +147,8 @@ def cm(ctx, *output):
return ctx
def readJsonFromDir(dir):
path = posixpath.join(dir, "configure.json")
def readJsonFromDir(path: str) -> str:
path = posixpath.join(path, "configure.json")
print(f"Reading {path}...")
assert posixpath.exists(path)
@ -942,8 +942,8 @@ def processInputs(ctx, data, cm_fh):
if "options" not in commandLine:
return
for input in commandLine["options"]:
parseInput(ctx, input, commandLine["options"][input], cm_fh)
for input_option in commandLine["options"]:
parseInput(ctx, input_option, commandLine["options"][input_option], cm_fh)
def processTests(ctx, data, cm_fh):
@ -974,23 +974,23 @@ def processLibraries(ctx, data, cm_fh):
parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set)
def processSubconfigs(dir, ctx, data):
def processSubconfigs(path, ctx, data):
assert ctx is not None
if "subconfigs" in data:
for subconf in data["subconfigs"]:
subconfDir = posixpath.join(dir, subconf)
subconfDir = posixpath.join(path, subconf)
subconfData = readJsonFromDir(subconfDir)
subconfCtx = ctx
processJson(subconfDir, subconfCtx, subconfData)
def processJson(dir, ctx, data):
def processJson(path, ctx, data):
ctx["module"] = data.get("module", "global")
ctx["test_dir"] = data.get("testDir", "")
ctx = processFiles(ctx, data)
with open(posixpath.join(dir, "configure.cmake"), "w") as cm_fh:
with open(posixpath.join(path, "configure.cmake"), "w") as cm_fh:
cm_fh.write("\n\n#### Inputs\n\n")
processInputs(ctx, data, cm_fh)
@ -1016,7 +1016,7 @@ def processJson(dir, ctx, data):
cm_fh.write('qt_extra_definition("QT_VERSION_PATCH" ${PROJECT_VERSION_PATCH} PUBLIC)\n')
# do this late:
processSubconfigs(dir, ctx, data)
processSubconfigs(path, ctx, data)
def main():

View File

@ -554,11 +554,11 @@ def find_library_info_for_target(targetName: str) -> typing.Optional[LibraryMapp
return None
def featureName(input: str) -> str:
def featureName(name: str) -> str:
replacement_char = "_"
if input.startswith("c++"):
if name.startswith("c++"):
replacement_char = "x"
return re.sub(r"[^a-zA-Z0-9_]", replacement_char, input)
return re.sub(r"[^a-zA-Z0-9_]", replacement_char, name)
def map_qt_library(lib: str) -> str:

View File

@ -665,7 +665,7 @@ class Operation:
self._value = [str(value)]
def process(
self, key: str, input: List[str], transformer: Callable[[List[str]], List[str]]
self, key: str, sinput: List[str], transformer: Callable[[List[str]], List[str]]
) -> List[str]:
assert False
@ -1032,12 +1032,12 @@ class Scope(object):
for c in self._included_children:
c.dump(indent=indent + 1)
def dump_structure(self, *, type: str = "ROOT", indent: int = 0) -> None:
print(f"{spaces(indent)}{type}: {self}")
def dump_structure(self, *, structure_type: str = "ROOT", indent: int = 0) -> None:
print(f"{spaces(indent)}{structure_type}: {self}")
for i in self._included_children:
i.dump_structure(type="INCL", indent=indent + 1)
i.dump_structure(structure_type="INCL", indent=indent + 1)
for i in self._children:
i.dump_structure(type="CHLD", indent=indent + 1)
i.dump_structure(structure_type="CHLD", indent=indent + 1)
@property
def keys(self):
@ -1812,11 +1812,11 @@ def sort_sources(sources: List[str]) -> List[str]:
if s is None:
continue
dir = os.path.dirname(s)
path = os.path.dirname(s)
base = os.path.splitext(os.path.basename(s))[0]
if base.endswith("_p"):
base = base[:-2]
sort_name = posixpath.join(dir, base)
sort_name = posixpath.join(path, base)
array = to_sort.get(sort_name, [])
array.append(s)