diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2018-08-23 09:28:25 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2018-09-05 12:53:56 -0400 |
commit | 8de60f907809fb2f9315f71f2cefd5a5aff6a7e7 (patch) | |
tree | adda094a32c7089b7fa1a46d5e596926c1a5180f /mesonbuild/mesonmain.py | |
parent | b3a35f92b4955120e142e34f8a4f0afd348e2bcb (diff) | |
download | meson-8de60f907809fb2f9315f71f2cefd5a5aff6a7e7.zip meson-8de60f907809fb2f9315f71f2cefd5a5aff6a7e7.tar.gz meson-8de60f907809fb2f9315f71f2cefd5a5aff6a7e7.tar.bz2 |
mesonmain: Move builddir/sourcedir handling code inside MesonApp
Diffstat (limited to 'mesonbuild/mesonmain.py')
-rw-r--r-- | mesonbuild/mesonmain.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index b150731..3e381dc 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -57,8 +57,10 @@ def wrapmodetype(string): class MesonApp: - def __init__(self, dir1, dir2, handshake, options): - (self.source_dir, self.build_dir) = self.validate_dirs(dir1, dir2, handshake) + def __init__(self, handshake, options): + (self.source_dir, self.build_dir) = self.validate_dirs(options.builddir, + options.sourcedir, + handshake) self.options = options def has_build_file(self, dirname): @@ -66,6 +68,15 @@ class MesonApp: return os.path.exists(fname) def validate_core_dirs(self, dir1, dir2): + if dir1 is None: + if dir2 is None: + if not os.path.exists('meson.build') and os.path.exists('../meson.build'): + dir2 = '..' + else: + raise MesonException('Must specify at least one directory name.') + dir1 = os.getcwd() + if dir2 is None: + dir2 = os.getcwd() ndir1 = os.path.abspath(os.path.realpath(dir1)) ndir2 = os.path.abspath(os.path.realpath(dir2)) if not os.path.exists(ndir1): @@ -335,19 +346,8 @@ def run(original_args, mainfile): args = mesonlib.expand_arguments(args) options = parser.parse_args(args) coredata.parse_cmd_line_options(options) - dir1 = options.builddir - dir2 = options.sourcedir try: - if dir1 is None: - if dir2 is None: - if not os.path.exists('meson.build') and os.path.exists('../meson.build'): - dir2 = '..' - else: - raise MesonException('Must specify at least one directory name.') - dir1 = os.getcwd() - if dir2 is None: - dir2 = os.getcwd() - app = MesonApp(dir1, dir2, handshake, options) + app = MesonApp(handshake, options) except Exception as e: # Log directory does not exist, so just print # to stdout. |