aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/msubprojects.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-10-04 22:12:45 -0400
committerXavier Claessens <xclaesse@gmail.com>2021-10-10 10:17:55 -0400
commit8e50ba732e2294d047daa31c79c48727075cf0fa (patch)
tree9ff82da1af24f2dbe6091ba589f08d3218657c15 /mesonbuild/msubprojects.py
parent352380f6598b0472e852d2f50669aa13874d2ac9 (diff)
downloadmeson-8e50ba732e2294d047daa31c79c48727075cf0fa.zip
meson-8e50ba732e2294d047daa31c79c48727075cf0fa.tar.gz
meson-8e50ba732e2294d047daa31c79c48727075cf0fa.tar.bz2
msubprojects: add new subcommand "packagefiles"
This will re-apply the meson.build patch overlay, ensuring it is up to date. Also take the opportunity offered by this infrastructure to repatch when performing `update --reset` since internally this will run `git stash` and thus cause the (possibly locally modified) meson.build files to disappear.
Diffstat (limited to 'mesonbuild/msubprojects.py')
-rwxr-xr-xmesonbuild/msubprojects.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/mesonbuild/msubprojects.py b/mesonbuild/msubprojects.py
index 293d43d..97154bf 100755
--- a/mesonbuild/msubprojects.py
+++ b/mesonbuild/msubprojects.py
@@ -58,7 +58,9 @@ class Runner:
# FIXME: Do a copy because Resolver.resolve() is stateful method that
# cannot be called from multiple threads.
self.wrap_resolver = copy.copy(r)
- self.wrap = wrap
+ self.wrap_resolver.current_subproject = 'meson'
+ self.wrap_resolver.dirname = os.path.join(r.subdir_root, wrap.directory)
+ self.wrap = self.wrap_resolver.wrap = wrap
self.repo_dir = repo_dir
self.options = options
self.run_method = options.subprojects_func.__get__(self)
@@ -154,6 +156,7 @@ class Runner:
# avoid any data lost by mistake.
self.git_stash()
self.git_output(['reset', '--hard', 'FETCH_HEAD'])
+ self.wrap_resolver.apply_patch()
except GitException as e:
self.log(' -> Could not reset', mlog.bold(self.repo_dir), 'to', mlog.bold(revision))
self.log(mlog.red(e.output))
@@ -468,6 +471,23 @@ class Runner:
mlog.log('')
mlog.log('Nothing has been deleted, run again with --confirm to apply.')
+ def packagefiles(self) -> bool:
+ if self.options.apply and self.options.save:
+ # not quite so nice as argparse failure
+ print('error: --apply and --save are mutually exclusive')
+ return False
+ if self.options.apply:
+ self.log(f'Re-applying patchfiles overlay for {self.wrap.name}...')
+ if not os.path.isdir(self.repo_dir):
+ self.log(' -> Not downloaded yet')
+ return True
+ self.wrap_resolver.apply_patch()
+ return True
+ if self.options.save:
+ mlog.error('not implemented yet')
+ return False
+
+
def add_common_arguments(p):
p.add_argument('--sourcedir', default='.',
help='Path to source directory')
@@ -527,6 +547,13 @@ def add_arguments(parser):
p.set_defaults(subprojects_func=Runner.purge)
p.set_defaults(post_func=Runner.post_purge)
+ p = subparsers.add_parser('packagefiles', help='Manage the packagefiles overlay')
+ add_common_arguments(p)
+ add_subprojects_argument(p)
+ p.add_argument('--apply', action='store_true', default=False, help='Apply packagefiles to the subproject')
+ p.add_argument('--save', action='store_true', default=False, help='Save packagefiles from the subproject')
+ p.set_defaults(subprojects_func=Runner.packagefiles)
+
def run(options):
src_dir = os.path.relpath(os.path.realpath(options.sourcedir))
if not os.path.isfile(os.path.join(src_dir, 'meson.build')):