aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2022-09-18 20:53:19 -0400
committerEli Schwartz <eschwartz93@gmail.com>2022-09-28 00:17:42 -0400
commitb9e382835e418f2c6c926313b3c84605cf87a9e1 (patch)
tree4a2c32a88142cb7a00f02a1a780dc12f575f259f
parentb314d1f7c1c9c42cf3a52b99a2f09dec443b62bd (diff)
downloadmeson-b9e382835e418f2c6c926313b3c84605cf87a9e1.zip
meson-b9e382835e418f2c6c926313b3c84605cf87a9e1.tar.gz
meson-b9e382835e418f2c6c926313b3c84605cf87a9e1.tar.bz2
wrap: Small simplification
-rw-r--r--mesonbuild/wrap/wrap.py19
1 files 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