summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2020-07-08 10:25:19 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2020-07-13 10:51:15 +0200
commit8a0676d5f9b54bc3d291223c3e88e91043a81507 (patch)
treec091c02808e339361328f48a9f19e911dc273db5 /util
parent3094bcc3c5a30635289f534884965d39ac35a11a (diff)
configurejson2cmake: Generalize special case support
The SpecialCaseHandler supported only two file names: "CMakeLists.txt" and "configure.cmake". Generalize the code to allow for arbitrary file names. We will use this in a subsequent commit. Change-Id: I0adada91409a11a369fd1cf2d6ab21cc8f28ba0f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-xutil/cmake/configurejson2cmake.py1
-rw-r--r--util/cmake/special_case_helper.py26
2 files changed, 8 insertions, 19 deletions
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py
index 970b87e30e..e2e3890364 100755
--- a/util/cmake/configurejson2cmake.py
+++ b/util/cmake/configurejson2cmake.py
@@ -1398,7 +1398,6 @@ def processJson(path, ctx, data):
os.path.abspath(destination),
os.path.abspath(generated_file),
os.path.abspath(path),
- convertingProFiles=False,
debug=False,
)
if handler.handle_special_cases():
diff --git a/util/cmake/special_case_helper.py b/util/cmake/special_case_helper.py
index 3787899276..28295b3143 100644
--- a/util/cmake/special_case_helper.py
+++ b/util/cmake/special_case_helper.py
@@ -222,7 +222,6 @@ class SpecialCaseHandler(object):
base_dir: str,
keep_temporary_files=False,
debug=False,
- convertingProFiles=True,
) -> None:
self.base_dir = base_dir
self.original_file_path = original_file_path
@@ -230,40 +229,31 @@ class SpecialCaseHandler(object):
self.keep_temporary_files = keep_temporary_files
self.use_heuristic = False
self.debug = debug
- self.convertingProFiles = convertingProFiles
@property
def prev_file_path(self) -> str:
- if self.convertingProFiles:
- filename = ".prev_CMakeLists.txt"
- else:
- filename = ".prev_configure.cmake"
+ filename = ".prev_" + os.path.basename(self.original_file_path)
return os.path.join(self.base_dir, filename)
@property
def post_merge_file_path(self) -> str:
- if self.convertingProFiles:
- filename = "CMakeLists-post-merge.txt"
- else:
- filename = "configure-post-merge.cmake"
+ original_file_name = os.path.basename(self.original_file_path)
+ (original_file_basename, original_file_ext) = os.path.splitext(original_file_name)
+ filename = original_file_basename + "-post-merge" + original_file_ext
return os.path.join(self.base_dir, filename)
@property
def no_special_file_path(self) -> str:
- if self.convertingProFiles:
- filename = "CMakeLists.no-special.txt"
- else:
- filename = "configure.no-special.cmake"
+ original_file_name = os.path.basename(self.original_file_path)
+ (original_file_basename, original_file_ext) = os.path.splitext(original_file_name)
+ filename = original_file_basename + ".no-special" + original_file_ext
return os.path.join(self.base_dir, filename)
def apply_git_merge_magic(self, no_special_cases_file_path: str) -> None:
# Create new folder for temporary repo, and ch dir into it.
repo = os.path.join(self.base_dir, "tmp_repo")
repo_absolute_path = os.path.abspath(repo)
- if self.convertingProFiles:
- txt = "CMakeLists.txt"
- else:
- txt = "configure.cmake"
+ txt = os.path.basename(self.original_file_path)
try:
os.mkdir(repo)