aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Stone <kyle.stone@is4s.com>2020-01-28 17:06:02 -0500
committerKyle Stone <kyle.stone@is4s.com>2020-01-28 19:00:39 -0500
commitc89dca8c70cfa9a5abe67ef80f51f152d971526c (patch)
treea68c302f6cc677d8b10e60566e882af51094d02f
parentf9a31a25db5a9a08a5b102c6289029beddc7b07a (diff)
downloadmeson-c89dca8c70cfa9a5abe67ef80f51f152d971526c.zip
meson-c89dca8c70cfa9a5abe67ef80f51f152d971526c.tar.gz
meson-c89dca8c70cfa9a5abe67ef80f51f152d971526c.tar.bz2
Add ability to specify project branch to install
-rw-r--r--docs/markdown/fallback-wraptool.md6
-rwxr-xr-xghwt.py26
2 files changed, 26 insertions, 6 deletions
diff --git a/docs/markdown/fallback-wraptool.md b/docs/markdown/fallback-wraptool.md
index ebf8b91..9f4814b 100644
--- a/docs/markdown/fallback-wraptool.md
+++ b/docs/markdown/fallback-wraptool.md
@@ -17,11 +17,15 @@ To list all available wraps:
To install a wrap, go to your source root, make sure that the
`subprojects` directory exists and run this command:
- ghwt.py install <projectname>
+ ghwt.py install <projectname> [<branchname>]
This will stage the subproject ready to use. If you have multiple
subprojects you need to download them all manually.
+Specifying branch name is optional. If not specified, the list
+of potential branches is sorted alphabetically and the last branch is
+used.
+
*Note* The tool was added in 0.32.0, for versions older than that you
need to delete the `foo.wrap` file to work around this issue.
diff --git a/ghwt.py b/ghwt.py
index a030a11..5a71a38 100755
--- a/ghwt.py
+++ b/ghwt.py
@@ -81,7 +81,7 @@ def unpack(sproj, branch):
shutil.rmtree(os.path.join(outdir, '.git'))
os.unlink(ofilename)
-def install(sproj):
+def install(sproj, requested_branch=None):
if not os.path.isdir(spdir):
print('Run this in your source root and make sure there is a subprojects directory in it.')
return 1
@@ -90,12 +90,25 @@ def install(sproj):
blist = [b for b in blist if b != 'master']
blist.sort()
branch = blist[-1]
+ if requested_branch is not None:
+ if requested_branch in blist:
+ branch = requested_branch
+ else:
+ print('Could not find user-requested branch', requested_branch)
+ print('Available branches for', sproj, ':')
+ print(blist)
+ return 1
print('Using branch', branch)
return unpack(sproj, branch)
+def print_help():
+ print('Usage:')
+ print(sys.argv[0], 'list')
+ print(sys.argv[0], 'install', 'package_name', '[branch_name]')
+
def run(args):
if not args or args[0] == '-h' or args[0] == '--help':
- print(sys.argv[0], 'list/install', 'package_name')
+ print_help()
return 1
command = args[0]
args = args[1:]
@@ -103,10 +116,13 @@ def run(args):
list_projects()
return 0
elif command == 'install':
- if len(args) != 1:
- print('Install requires exactly one argument.')
+ if len(args) == 1:
+ return install(args[0])
+ elif len(args) == 2:
+ return install(args[0], args[1])
+ else:
+ print_help()
return 1
- return install(args[0])
else:
print('Unknown command')
return 1