aboutsummaryrefslogtreecommitdiff
path: root/mesonlib.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-04-21 16:27:58 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2015-04-21 16:27:58 +0300
commitbf9b5d7b726c9388e5204fb44969fd11730944c6 (patch)
tree9391fbac79ad1e5dfd9059c9a8bcfce5e00e6db5 /mesonlib.py
parenta92fcb711b5b56ee6858d73dc90eda0e1e5d91a4 (diff)
downloadmeson-bf9b5d7b726c9388e5204fb44969fd11730944c6.zip
meson-bf9b5d7b726c9388e5204fb44969fd11730944c6.tar.gz
meson-bf9b5d7b726c9388e5204fb44969fd11730944c6.tar.bz2
The first step in a major refactoring starts by adding a new layer of abstraction.
Diffstat (limited to 'mesonlib.py')
-rw-r--r--mesonlib.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/mesonlib.py b/mesonlib.py
index af29421..f547379 100644
--- a/mesonlib.py
+++ b/mesonlib.py
@@ -1,4 +1,4 @@
-# Copyright 2012-2014 The Meson development team
+# Copyright 2012-2015 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,6 +20,34 @@ from glob import glob
from coredata import MesonException
+class File:
+ def __init__(self, is_built, subdir, fname):
+ self.is_built = is_built
+ self.subdir = subdir
+ self.fname = fname
+
+ @staticmethod
+ def from_source_file(source_root, subdir, fname):
+ if not os.path.isfile(os.path.join(source_root, subdir, fname)):
+ raise MesonException('File %s does not exist.' % fname)
+ return File(False, subdir, fname)
+
+ @staticmethod
+ def from_built_file(subdir, fname):
+ return File(True, subdir, fname)
+
+ def rel_to_builddir(self, build_to_src):
+ if self.is_built:
+ return os.path.join(self.subdir, self.fname)
+ else:
+ return os.path.join(build_to_src, self.subdir, self.fname)
+
+ def endswith(self, ending):
+ return self.fname.endswith(ending)
+
+ def split(self, s):
+ return self.fname.split(s)
+
def is_osx():
return platform.system().lower() == 'darwin'