From b9e382835e418f2c6c926313b3c84605cf87a9e1 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 18 Sep 2022 20:53:19 -0400 Subject: wrap: Small simplification --- mesonbuild/wrap/wrap.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 9501835..86dd74e 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -368,18 +368,17 @@ class Resolver: self.dirname = self.wrap.filename rel_path = os.path.relpath(self.dirname, self.source_dir) - meson_file = os.path.join(self.dirname, 'meson.build') - cmake_file = os.path.join(self.dirname, 'CMakeLists.txt') - - if method not in ['meson', 'cmake']: + if method == 'meson': + buildfile = os.path.join(self.dirname, 'meson.build') + elif method == 'cmake': + buildfile = os.path.join(self.dirname, 'CMakeLists.txt') + else: raise WrapException('Only the methods "meson" and "cmake" are supported') # The directory is there and has meson.build? Great, use it. - if method == 'meson' and os.path.exists(meson_file): + if os.path.exists(buildfile): self.validate() return rel_path - if method == 'cmake' and os.path.exists(cmake_file): - return rel_path # Check if the subproject is a git submodule self.resolve_git_submodule() @@ -408,10 +407,8 @@ class Resolver: raise # A meson.build or CMakeLists.txt file is required in the directory - if method == 'meson' and not os.path.exists(meson_file): - raise WrapException('Subproject exists but has no meson.build file') - if method == 'cmake' and not os.path.exists(cmake_file): - raise WrapException('Subproject exists but has no CMakeLists.txt file') + if not os.path.exists(buildfile): + raise WrapException(f'Subproject exists but has no {os.path.basename(buildfile)} file') # At this point, the subproject has been successfully resolved for the # first time so save off the hash of the entire wrap file for future -- cgit v1.1