diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2016-01-15 15:33:46 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2016-01-19 00:02:28 +0000 |
commit | f5d63cd47ec4306b4425c079a2a61148b4d589be (patch) | |
tree | 6664ad82b9a5fdc1152d062f73c8398d1ba885c3 /mesonbuild/mesonmain.py | |
parent | 6d2b227dc1139067b7d1c9d0e067f384e766fa62 (diff) | |
download | meson-f5d63cd47ec4306b4425c079a2a61148b4d589be.zip meson-f5d63cd47ec4306b4425c079a2a61148b4d589be.tar.gz meson-f5d63cd47ec4306b4425c079a2a61148b4d589be.tar.bz2 |
meson: try harder to infer build and source directories if called without arguments
If there's no meson.build file in the current directory
and there is one in the parent directory, assume that
we are in the build directory.
Diffstat (limited to 'mesonbuild/mesonmain.py')
-rw-r--r-- | mesonbuild/mesonmain.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 6317c95..dfeb06e 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -223,15 +223,22 @@ def run(mainfile, args): return 0 args = options.directories if len(args) == 0 or len(args) > 2: - print('{} <source directory> <build directory>'.format(sys.argv[0])) - print('If you omit either directory, the current directory is substituted.') - print('Run {} --help for more information.'.format(sys.argv[0])) - return 1 - dir1 = args[0] - if len(args) > 1: - dir2 = args[1] + # if there's a meson.build in the dir above, and not in the current + # directory, assume we're in the build directory + if len(args) == 0 and not os.path.exists('meson.build') and os.path.exists('../meson.build'): + dir1 = '..' + dir2 = '.' + else: + print('{} <source directory> <build directory>'.format(sys.argv[0])) + print('If you omit either directory, the current directory is substituted.') + print('Run {} --help for more information.'.format(sys.argv[0])) + return 1 else: - dir2 = '.' + dir1 = args[0] + if len(args) > 1: + dir2 = args[1] + else: + dir2 = '.' while os.path.islink(mainfile): resolved = os.readlink(mainfile) if resolved[0] != '/': |