Add 'update' and git-update targets to update git repos

This commit is contained in:
Thibault Saunier 2016-11-07 18:17:39 -03:00
parent ac383f6b68
commit c843f48740
5 changed files with 65 additions and 20 deletions

View file

@ -28,18 +28,40 @@ NOTE: on fedora (and maybe other distributions) replace `ninja` with `ninja-buil
# Development environment # Development environment
## Uninstalled environment
gst-build also contains a special `uninstalled` target that lets you enter an gst-build also contains a special `uninstalled` target that lets you enter an
uninstalled development environment where you will be able to work on GStreamer easily. uninstalled development environment where you will be able to work on GStreamer
You can get into that environment running: easily. You can get into that environment running:
``` ```
ninja -C build/ uninstalled ninja -C build/ uninstalled
``` ```
If your operating system handles symlinks, built modules source code will be available If your operating system handles symlinks, built modules source code will be
at the root of `gst-build/` for example GStreamer core will be in `gstreamer/`. Otherwise available at the root of `gst-build/` for example GStreamer core will be in
they will be present in `subprojects/`. You can simply hack in there and to rebuild you `gstreamer/`. Otherwise they will be present in `subprojects/`. You can simply
just need to rerun `ninja -C build/`. hack in there and to rebuild you just need to rerun `ninja -C build/`.
## Update git subprojects
We added a special `update` target to update subprojects (it uses `git pull
--rebase` meaning you should always make sure the branches you work on are
following the right upstream branch, you can set it with `git branch
--set-upstream-to origin/master` if you are working on `gst-build` master
branch).
Update all GStreamer modules and rebuild:
```
ninja -C build/ update
```
Update all GStreamer modules without rebuilding:
```
ninja -C build/ git-update
```
## Add information about GStreamer development environment in your prompt line ## Add information about GStreamer development environment in your prompt line

View file

@ -1,4 +1,5 @@
import argparse import argparse
import shutil
import subprocess import subprocess
class Colors: class Colors:
@ -37,3 +38,12 @@ class Colors:
def git(*args, repository_path='.'): def git(*args, repository_path='.'):
return subprocess.check_output(["git"] + list(args), cwd=repository_path, return subprocess.check_output(["git"] + list(args), cwd=repository_path,
stderr=subprocess.STDOUT).decode() stderr=subprocess.STDOUT).decode()
def accept_command(commands):
"""Search @commands and returns the first found absolute path."""
for command in commands:
command = shutil.which(command)
if command:
return command
return None

View file

@ -6,6 +6,7 @@ import xml.etree.ElementTree as ET
from common import git from common import git
from common import Colors from common import Colors
from common import accept_command
SCRIPTDIR = os.path.dirname(__file__) SCRIPTDIR = os.path.dirname(__file__)
@ -51,8 +52,8 @@ def update_repo(repo_name, repo_dir, revision, no_interaction, recurse_i=0):
out = getattr(e, "output", b"").decode() out = getattr(e, "output", b"").decode()
if not no_interaction: if not no_interaction:
print("=====================================" print("====================================="
"\n%sEntering a shell in %s to fix that" "\n%s\nEntering a shell in %s to fix that"
" just `exit 0` once done` or `exit 255`" " just `exit 0` once done, or `exit 255`"
" to skip update for that repository" " to skip update for that repository"
"\n=====================================" % ( "\n=====================================" % (
out, repo_dir)) out, repo_dir))
@ -95,6 +96,10 @@ if __name__ == "__main__":
default=False, default=False,
action='store_true', action='store_true',
help="Do not output ansi colors.") help="Do not output ansi colors.")
parser.add_argument("--builddir",
default=None,
help="Specifies the build directory where to"
" invoke ninja after updating.")
parser.add_argument("--no-interaction", parser.add_argument("--no-interaction",
default=False, default=False,
action='store_true', action='store_true',
@ -109,5 +114,17 @@ if __name__ == "__main__":
if not update_repo('gst-build', SCRIPTDIR, None, options.no_interaction): if not update_repo('gst-build', SCRIPTDIR, None, options.no_interaction):
exit(1) exit(1)
exit(not update_subprojects(options.manifest, if not update_subprojects(options.manifest, options.no_interaction):
options.no_interaction)) exit(1)
if options.builddir:
ninja = accept_command(["ninja", "ninja-build"])
if not ninja:
print("Can't find ninja, other backends are not supported for rebuilding")
exit(1)
if not os.path.exists(os.path.join (options.builddir, 'build.ninja')):
print("Can't rebuild in %s as no build.ninja file found." % options.builddir)
print("Rebuilding all GStreamer modules.")
exit(subprocess.call([ninja, '-C', options.builddir]))

View file

@ -84,3 +84,8 @@ endforeach
setenv = find_program('gst-uninstalled.py') setenv = find_program('gst-uninstalled.py')
run_target('uninstalled', command : [setenv, '--builddir=@0@'.format(meson.current_build_dir()), run_target('uninstalled', command : [setenv, '--builddir=@0@'.format(meson.current_build_dir()),
'--gst-version=@0@'.format(gst_branch)]) '--gst-version=@0@'.format(gst_branch)])
update = find_program('git-update')
run_target('git-update', command : [update])
run_target('update', command : [update,
'--builddir=@0@'.format(meson.current_build_dir())])

11
setup
View file

@ -9,6 +9,7 @@ import subprocess
from common import git from common import git
from common import Colors from common import Colors
from common import accept_command
PROJECTNAME = "GStreamer build" PROJECTNAME = "GStreamer build"
@ -25,16 +26,6 @@ def get_meson():
return accept_command(["meson.py", "meson"]), accept_command(["mesonconf.py", "mesonconf"]) return accept_command(["meson.py", "meson"]), accept_command(["mesonconf.py", "mesonconf"])
def accept_command(commands):
"""Search @commands and returns the first found absolute path."""
for command in commands:
command = shutil.which(command)
if command:
return command
return None
def get_configs(meson): def get_configs(meson):
return ['-D', 'werror=true'] return ['-D', 'werror=true']