mirror of
https://github.com/ZDoom/zdoom-macos-deps.git
synced 2025-02-16 16:41:42 +00:00
aedi: add caching for cmake target detection
it was processing the same cmake file over and over again in order to get project name
This commit is contained in:
parent
770034a4fc
commit
99f53dfd84
1 changed files with 20 additions and 12 deletions
|
@ -335,23 +335,31 @@ class ConfigureMakeTarget(BuildTarget):
|
|||
|
||||
|
||||
class CMakeTarget(BuildTarget):
|
||||
cached_project_name = None
|
||||
|
||||
def __init__(self, name=None):
|
||||
super().__init__(name)
|
||||
|
||||
def detect(self, state: BuildState) -> bool:
|
||||
cmakelists_path = state.source / self.src_root / 'CMakeLists.txt'
|
||||
|
||||
if not cmakelists_path.exists():
|
||||
return False
|
||||
|
||||
for line in open(cmakelists_path).readlines():
|
||||
project_name = CMakeTarget._extract_project_name(line)
|
||||
if project_name:
|
||||
project_name = project_name.lower()
|
||||
project_name = project_name.replace(' ', '-')
|
||||
break
|
||||
if CMakeTarget.cached_project_name:
|
||||
project_name = CMakeTarget.cached_project_name
|
||||
else:
|
||||
return False
|
||||
cmakelists_path = state.source / self.src_root / 'CMakeLists.txt'
|
||||
|
||||
if not cmakelists_path.exists():
|
||||
self.cached_project_name = '@non-existing-project@'
|
||||
return False
|
||||
|
||||
for line in open(cmakelists_path).readlines():
|
||||
project_name = CMakeTarget._extract_project_name(line)
|
||||
if project_name:
|
||||
project_name = project_name.lower()
|
||||
project_name = project_name.replace(' ', '-')
|
||||
break
|
||||
else:
|
||||
return False
|
||||
|
||||
CMakeTarget.cached_project_name = project_name
|
||||
|
||||
return project_name == self.name
|
||||
|
||||
|
|
Loading…
Reference in a new issue