diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2022-02-28 16:01:11 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2022-03-03 10:29:14 -0800 |
commit | 3e90f277032d8ce91d99ed1fe62567701ce62622 (patch) | |
tree | 9358c2411405549a0e9eb075ae2023edf616da4a /mesonbuild | |
parent | b07d4bb2068f90bfbb0aa6e6ea91412db29388ea (diff) | |
download | meson-3e90f277032d8ce91d99ed1fe62567701ce62622.zip meson-3e90f277032d8ce91d99ed1fe62567701ce62622.tar.gz meson-3e90f277032d8ce91d99ed1fe62567701ce62622.tar.bz2 |
interpreter: replace build_def_files with OrderedSet
We do a bunch of backbending to make sure we don't have duplicates,
let's just use the right datastructure to begin with.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 14 | ||||
-rw-r--r-- | mesonbuild/mintro.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/cmake.py | 3 | ||||
-rw-r--r-- | mesonbuild/modules/keyval.py | 4 |
4 files changed, 11 insertions, 12 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 5e8240e..5d2e476 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -308,10 +308,10 @@ class Interpreter(InterpreterBase, HoldableObject): # For non-meson subprojects, we'll be using the ast. Even if it does # exist we don't want to add a dependency on it, it's autogenerated # from the actual build files, and is just for reference. - self.build_def_files = [] + self.build_def_files: mesonlib.OrderedSet[str] = mesonlib.OrderedSet() build_filename = os.path.join(self.subdir, environment.build_filename) if not is_translated: - self.build_def_files.append(build_filename) + self.build_def_files.add(build_filename) if not mock: self.parse_project() self._redetect_machines() @@ -503,7 +503,7 @@ class Interpreter(InterpreterBase, HoldableObject): else: raise InterpreterException(f'Module returned a value of unknown type {v!r}.') - def get_build_def_files(self) -> T.List[str]: + def get_build_def_files(self) -> mesonlib.OrderedSet[str]: return self.build_def_files def add_build_def_file(self, f: mesonlib.FileOrString) -> None: @@ -539,7 +539,7 @@ class Interpreter(InterpreterBase, HoldableObject): else: return if f not in self.build_def_files: - self.build_def_files.append(f) + self.build_def_files.add(f) def get_variables(self): return self.variables @@ -938,9 +938,9 @@ external dependencies (including libraries) must go to "dependencies".''') self.subprojects[subp_name] = SubprojectHolder(subi, subdir, warnings=subi_warnings) # Duplicates are possible when subproject uses files from project root if build_def_files: - self.build_def_files = list(set(self.build_def_files + build_def_files)) + self.build_def_files.update(build_def_files) # We always need the subi.build_def_files, to propgate sub-sub-projects - self.build_def_files = list(set(self.build_def_files + subi.build_def_files)) + self.build_def_files.update(subi.build_def_files) self.build.merge(subi.build) self.build.subprojects[subp_name] = subi.project_version self.coredata.initialized_subprojects.add(subp_name) @@ -2135,7 +2135,7 @@ external dependencies (including libraries) must go to "dependencies".''') self.subdir = subdir os.makedirs(os.path.join(self.environment.build_dir, subdir), exist_ok=True) buildfilename = os.path.join(self.subdir, environment.build_filename) - self.build_def_files.append(buildfilename) + self.build_def_files.add(buildfilename) absname = os.path.join(self.environment.get_source_dir(), buildfilename) if not os.path.isfile(absname): self.subdir = prev_subdir diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 130cf93..2ec7274 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -318,7 +318,7 @@ def find_buildsystem_files_list(src_dir: str) -> T.List[str]: def list_buildsystem_files(builddata: build.Build, interpreter: Interpreter) -> T.List[str]: src_dir = builddata.environment.get_source_dir() - filelist = interpreter.get_build_def_files() # type: T.List[str] + filelist = list(interpreter.get_build_def_files()) filelist = [PurePath(src_dir, x).as_posix() for x in filelist] return filelist diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py index 0f54d30..a263e52 100644 --- a/mesonbuild/modules/cmake.py +++ b/mesonbuild/modules/cmake.py @@ -403,8 +403,7 @@ class CmakeModule(ExtensionModule): conf.used = True conffile = os.path.normpath(inputfile.relative_name()) - if conffile not in self.interpreter.build_def_files: - self.interpreter.build_def_files.append(conffile) + self.interpreter.build_def_files.add(conffile) res = build.Data([mesonlib.File(True, ofile_path, ofile_fname)], install_dir, install_dir, None, state.subproject) self.interpreter.build.data.append(res) diff --git a/mesonbuild/modules/keyval.py b/mesonbuild/modules/keyval.py index 7cebc91..36daea8 100644 --- a/mesonbuild/modules/keyval.py +++ b/mesonbuild/modules/keyval.py @@ -63,8 +63,8 @@ class KeyvalModule(ExtensionModule): else: s = os.path.join(self.interpreter.environment.source_dir, s) - if s not in self.interpreter.build_def_files and not is_built: - self.interpreter.build_def_files.append(s) + if not is_built: + self.interpreter.build_def_files.add(s) return self._load_file(s) |