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:
parent
f7bb15a11b
commit
b7adc85642
@ -147,8 +147,8 @@ def cm(ctx, *output):
|
|||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
def readJsonFromDir(dir):
|
def readJsonFromDir(path: str) -> str:
|
||||||
path = posixpath.join(dir, "configure.json")
|
path = posixpath.join(path, "configure.json")
|
||||||
|
|
||||||
print(f"Reading {path}...")
|
print(f"Reading {path}...")
|
||||||
assert posixpath.exists(path)
|
assert posixpath.exists(path)
|
||||||
@ -942,8 +942,8 @@ def processInputs(ctx, data, cm_fh):
|
|||||||
if "options" not in commandLine:
|
if "options" not in commandLine:
|
||||||
return
|
return
|
||||||
|
|
||||||
for input in commandLine["options"]:
|
for input_option in commandLine["options"]:
|
||||||
parseInput(ctx, input, commandLine["options"][input], cm_fh)
|
parseInput(ctx, input_option, commandLine["options"][input_option], cm_fh)
|
||||||
|
|
||||||
|
|
||||||
def processTests(ctx, data, 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)
|
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
|
assert ctx is not None
|
||||||
if "subconfigs" in data:
|
if "subconfigs" in data:
|
||||||
for subconf in data["subconfigs"]:
|
for subconf in data["subconfigs"]:
|
||||||
subconfDir = posixpath.join(dir, subconf)
|
subconfDir = posixpath.join(path, subconf)
|
||||||
subconfData = readJsonFromDir(subconfDir)
|
subconfData = readJsonFromDir(subconfDir)
|
||||||
subconfCtx = ctx
|
subconfCtx = ctx
|
||||||
processJson(subconfDir, subconfCtx, subconfData)
|
processJson(subconfDir, subconfCtx, subconfData)
|
||||||
|
|
||||||
|
|
||||||
def processJson(dir, ctx, data):
|
def processJson(path, ctx, data):
|
||||||
ctx["module"] = data.get("module", "global")
|
ctx["module"] = data.get("module", "global")
|
||||||
ctx["test_dir"] = data.get("testDir", "")
|
ctx["test_dir"] = data.get("testDir", "")
|
||||||
|
|
||||||
ctx = processFiles(ctx, data)
|
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")
|
cm_fh.write("\n\n#### Inputs\n\n")
|
||||||
|
|
||||||
processInputs(ctx, data, cm_fh)
|
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')
|
cm_fh.write('qt_extra_definition("QT_VERSION_PATCH" ${PROJECT_VERSION_PATCH} PUBLIC)\n')
|
||||||
|
|
||||||
# do this late:
|
# do this late:
|
||||||
processSubconfigs(dir, ctx, data)
|
processSubconfigs(path, ctx, data)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -554,11 +554,11 @@ def find_library_info_for_target(targetName: str) -> typing.Optional[LibraryMapp
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def featureName(input: str) -> str:
|
def featureName(name: str) -> str:
|
||||||
replacement_char = "_"
|
replacement_char = "_"
|
||||||
if input.startswith("c++"):
|
if name.startswith("c++"):
|
||||||
replacement_char = "x"
|
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:
|
def map_qt_library(lib: str) -> str:
|
||||||
|
@ -665,7 +665,7 @@ class Operation:
|
|||||||
self._value = [str(value)]
|
self._value = [str(value)]
|
||||||
|
|
||||||
def process(
|
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]:
|
) -> List[str]:
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
@ -1032,12 +1032,12 @@ class Scope(object):
|
|||||||
for c in self._included_children:
|
for c in self._included_children:
|
||||||
c.dump(indent=indent + 1)
|
c.dump(indent=indent + 1)
|
||||||
|
|
||||||
def dump_structure(self, *, type: str = "ROOT", indent: int = 0) -> None:
|
def dump_structure(self, *, structure_type: str = "ROOT", indent: int = 0) -> None:
|
||||||
print(f"{spaces(indent)}{type}: {self}")
|
print(f"{spaces(indent)}{structure_type}: {self}")
|
||||||
for i in self._included_children:
|
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:
|
for i in self._children:
|
||||||
i.dump_structure(type="CHLD", indent=indent + 1)
|
i.dump_structure(structure_type="CHLD", indent=indent + 1)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def keys(self):
|
def keys(self):
|
||||||
@ -1812,11 +1812,11 @@ def sort_sources(sources: List[str]) -> List[str]:
|
|||||||
if s is None:
|
if s is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
dir = os.path.dirname(s)
|
path = os.path.dirname(s)
|
||||||
base = os.path.splitext(os.path.basename(s))[0]
|
base = os.path.splitext(os.path.basename(s))[0]
|
||||||
if base.endswith("_p"):
|
if base.endswith("_p"):
|
||||||
base = base[:-2]
|
base = base[:-2]
|
||||||
sort_name = posixpath.join(dir, base)
|
sort_name = posixpath.join(path, base)
|
||||||
|
|
||||||
array = to_sort.get(sort_name, [])
|
array = to_sort.get(sort_name, [])
|
||||||
array.append(s)
|
array.append(s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user