diff options
author | Daniel Pirch <dpirch@gmail.com> | 2018-08-09 19:27:45 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-08-17 00:33:38 +0300 |
commit | 6ecd31af19dc537983311796929a9dd690632999 (patch) | |
tree | bef19217113e7a5f9e17bddddb047aedddad2694 /mesonbuild/wrap/wraptool.py | |
parent | b400cbe058df10bc37e628305c72c574177062e2 (diff) | |
download | meson-6ecd31af19dc537983311796929a9dd690632999.zip meson-6ecd31af19dc537983311796929a9dd690632999.tar.gz meson-6ecd31af19dc537983311796929a9dd690632999.tar.bz2 |
wraptool: fix manual selection of wrap file to promote
Fixed manually promoting wrap files with a full path, e.g.
`meson wrap promote subprojects/s1/subprojects/projname.wrap`,
which resulted in an error before (new test added:
`./run_unittests.py AllPlatformTests.test_subproject_promotion_wrap`).
Additionally, running promote with an invalid subproject path now fails
properly. Before, it just silently did nothing (added to test:
`./run_unittests.py AllPlatformTests.test_subproject_promotion`).
Diffstat (limited to 'mesonbuild/wrap/wraptool.py')
-rw-r--r-- | mesonbuild/wrap/wraptool.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/mesonbuild/wrap/wraptool.py b/mesonbuild/wrap/wraptool.py index b88f129..570e691 100644 --- a/mesonbuild/wrap/wraptool.py +++ b/mesonbuild/wrap/wraptool.py @@ -168,23 +168,26 @@ def do_promotion(from_path, spdir_name): def promote(options): argument = options.project_path - path_segment, subproject_name = os.path.split(argument) spdir_name = 'subprojects' sprojs = mesonlib.detect_subprojects(spdir_name) - if subproject_name not in sprojs: - sys.exit('Subproject %s not found in directory tree.' % subproject_name) - matches = sprojs[subproject_name] - if len(matches) == 1: - do_promotion(matches[0], spdir_name) - return - if path_segment == '': - print('There are many versions of %s in tree. Please specify which one to promote:\n' % subproject_name) + + # check if the argument is a full path to a subproject directory or wrap file + system_native_path_argument = argument.replace('/', os.sep) + for _, matches in sprojs.items(): + if system_native_path_argument in matches: + do_promotion(system_native_path_argument, spdir_name) + return + + # otherwise the argument is just a subproject basename which must be unambiguous + if argument not in sprojs: + sys.exit('Subproject %s not found in directory tree.' % argument) + matches = sprojs[argument] + if len(matches) > 1: + print('There is more than one version of %s in tree. Please specify which one to promote:\n' % argument) for s in matches: print(s) sys.exit(1) - system_native_path_argument = argument.replace('/', os.sep) - if system_native_path_argument in matches: - do_promotion(argument, spdir_name) + do_promotion(matches[0], spdir_name) def status(options): print('Subproject status') |