aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-07-16 14:22:47 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2019-07-18 23:37:33 +0300
commita3481743134048ed0c6130457a79ce36bed896f7 (patch)
tree25de7ec7cad174f717fde7a19cc5da6969e467d4
parentd9eac2544c65429e2981c55c07a3235454e3eae0 (diff)
downloadmeson-a3481743134048ed0c6130457a79ce36bed896f7.zip
meson-a3481743134048ed0c6130457a79ce36bed896f7.tar.gz
meson-a3481743134048ed0c6130457a79ce36bed896f7.tar.bz2
str => pathlib for cmakelists
Use pathlib.Path to simplify and condense the generation of CMakeLists.txt
-rw-r--r--mesonbuild/dependencies/base.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 4781fcd..0e6a601 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -1397,18 +1397,14 @@ class CMakeDependency(ExternalDependency):
def _setup_cmake_dir(self, cmake_file: str) -> str:
# Setup the CMake build environment and return the "build" directory
- build_dir = '{}/cmake_{}'.format(self.cmake_root_dir, self.name)
- os.makedirs(build_dir, exist_ok=True)
+ build_dir = Path(self.cmake_root_dir) / 'cmake_{}'.format(self.name)
+ build_dir.mkdir(parents=True, exist_ok=True)
# Copy the CMakeLists.txt
- cmake_lists = '{}/CMakeLists.txt'.format(build_dir)
- dir_path = os.path.dirname(os.path.realpath(__file__))
- src_cmake = '{}/data/{}'.format(dir_path, cmake_file)
- if os.path.exists(cmake_lists):
- os.remove(cmake_lists)
- shutil.copyfile(src_cmake, cmake_lists)
+ src_cmake = Path(__file__).parent / 'data' / cmake_file
+ shutil.copyfile(str(src_cmake), str(build_dir / 'CMakeLists.txt')) # str() is for Python 3.5
- return build_dir
+ return str(build_dir)
def _call_cmake(self, args, cmake_file: str, env=None):
build_dir = self._setup_cmake_dir(cmake_file)
@@ -1543,7 +1539,7 @@ class DubDependency(ExternalDependency):
for lib in target['buildSettings'][field_name]:
if lib not in libs:
libs.append(lib)
- if os.name is not 'nt':
+ if os.name != 'nt':
pkgdep = PkgConfigDependency(lib, environment, {'required': 'true', 'silent': 'true'})
for arg in pkgdep.get_compile_args():
self.compile_args.append(arg)