diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-02-24 22:45:14 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-02-24 22:45:14 +0200 |
commit | 6f907dd4abc0d2b2afb8e3a588cd994e8dc1492f (patch) | |
tree | bbfcb880a93bf8b22c9898eb98006d029ef511ae | |
parent | 7d516ee9b155cf682116a3906695bc765e9e4894 (diff) | |
parent | f5d63cd47ec4306b4425c079a2a61148b4d589be (diff) | |
download | meson-6f907dd4abc0d2b2afb8e3a588cd994e8dc1492f.zip meson-6f907dd4abc0d2b2afb8e3a588cd994e8dc1492f.tar.gz meson-6f907dd4abc0d2b2afb8e3a588cd994e8dc1492f.tar.bz2 |
Merge pull request #358 from tp-m/no-args
Try harder to infer build and source directories if called without arguments.
-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 0317651..1a7b084 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -231,15 +231,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] != '/': |