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>
This commit is contained in:
parent
3094bcc3c5
commit
8a0676d5f9
@ -1398,7 +1398,6 @@ def processJson(path, ctx, data):
|
|||||||
os.path.abspath(destination),
|
os.path.abspath(destination),
|
||||||
os.path.abspath(generated_file),
|
os.path.abspath(generated_file),
|
||||||
os.path.abspath(path),
|
os.path.abspath(path),
|
||||||
convertingProFiles=False,
|
|
||||||
debug=False,
|
debug=False,
|
||||||
)
|
)
|
||||||
if handler.handle_special_cases():
|
if handler.handle_special_cases():
|
||||||
|
@ -222,7 +222,6 @@ class SpecialCaseHandler(object):
|
|||||||
base_dir: str,
|
base_dir: str,
|
||||||
keep_temporary_files=False,
|
keep_temporary_files=False,
|
||||||
debug=False,
|
debug=False,
|
||||||
convertingProFiles=True,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
self.base_dir = base_dir
|
self.base_dir = base_dir
|
||||||
self.original_file_path = original_file_path
|
self.original_file_path = original_file_path
|
||||||
@ -230,40 +229,31 @@ class SpecialCaseHandler(object):
|
|||||||
self.keep_temporary_files = keep_temporary_files
|
self.keep_temporary_files = keep_temporary_files
|
||||||
self.use_heuristic = False
|
self.use_heuristic = False
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
self.convertingProFiles = convertingProFiles
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def prev_file_path(self) -> str:
|
def prev_file_path(self) -> str:
|
||||||
if self.convertingProFiles:
|
filename = ".prev_" + os.path.basename(self.original_file_path)
|
||||||
filename = ".prev_CMakeLists.txt"
|
|
||||||
else:
|
|
||||||
filename = ".prev_configure.cmake"
|
|
||||||
return os.path.join(self.base_dir, filename)
|
return os.path.join(self.base_dir, filename)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def post_merge_file_path(self) -> str:
|
def post_merge_file_path(self) -> str:
|
||||||
if self.convertingProFiles:
|
original_file_name = os.path.basename(self.original_file_path)
|
||||||
filename = "CMakeLists-post-merge.txt"
|
(original_file_basename, original_file_ext) = os.path.splitext(original_file_name)
|
||||||
else:
|
filename = original_file_basename + "-post-merge" + original_file_ext
|
||||||
filename = "configure-post-merge.cmake"
|
|
||||||
return os.path.join(self.base_dir, filename)
|
return os.path.join(self.base_dir, filename)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def no_special_file_path(self) -> str:
|
def no_special_file_path(self) -> str:
|
||||||
if self.convertingProFiles:
|
original_file_name = os.path.basename(self.original_file_path)
|
||||||
filename = "CMakeLists.no-special.txt"
|
(original_file_basename, original_file_ext) = os.path.splitext(original_file_name)
|
||||||
else:
|
filename = original_file_basename + ".no-special" + original_file_ext
|
||||||
filename = "configure.no-special.cmake"
|
|
||||||
return os.path.join(self.base_dir, filename)
|
return os.path.join(self.base_dir, filename)
|
||||||
|
|
||||||
def apply_git_merge_magic(self, no_special_cases_file_path: str) -> None:
|
def apply_git_merge_magic(self, no_special_cases_file_path: str) -> None:
|
||||||
# Create new folder for temporary repo, and ch dir into it.
|
# Create new folder for temporary repo, and ch dir into it.
|
||||||
repo = os.path.join(self.base_dir, "tmp_repo")
|
repo = os.path.join(self.base_dir, "tmp_repo")
|
||||||
repo_absolute_path = os.path.abspath(repo)
|
repo_absolute_path = os.path.abspath(repo)
|
||||||
if self.convertingProFiles:
|
txt = os.path.basename(self.original_file_path)
|
||||||
txt = "CMakeLists.txt"
|
|
||||||
else:
|
|
||||||
txt = "configure.cmake"
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.mkdir(repo)
|
os.mkdir(repo)
|
||||||
|
Loading…
Reference in New Issue
Block a user