Commit Graph

42 Commits

Author SHA1 Message Date
Xavier Claessens 27970b1d85 msubprojects: Add message at the end of purge 2021-06-25 15:16:55 -04:00
Xavier Claessens 2b6fe00e3d msubprojects: Run action on all subprojects in parallel
This moves all the code into a class and call its run() method in a
thread. The class queues all logs to print them at the end to avoid
mixing output of multiple actions.
2021-06-25 15:16:55 -04:00
Xavier Claessens 62c53b834d wrap: Port to v2 protocol
Fixes: #8754.
2021-06-04 15:35:29 -04:00
Tristan Partin bb12587e0b Add subprojects purge wrap-git coverage 2021-04-26 12:06:12 -04:00
Tristan Partin b6d277c140 Add 'subprojects purge' command
This will help facilitate cache busting in certain situations, and
replaces hand-rolled solutions of writing a length command to remove
various files/folders within the subprojects directory.
2021-04-26 16:42:29 +03:00
Xavier Claessens 1ad469342b msubprojects: wrap-file should be re-extracted with --reset
When using --reset we should guarantee that next reconfigure will pick
the latest code. For wrap-file we have no way to know if the revision
changed, so we have to delete the source tree and extract again.

It is unlikely that user has local changes in non-git subprojects, and
--reset is known to be dangerous.
2021-03-28 23:24:01 +03:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Nirbheek Chauhan 1c631ec8ab msubprojects: Ignore worktrees when checking out
Otherwise it's not possible to share git subprojects via worktrees
when creating a worktree of a git repository that uses meson
subprojects.

The downside is that the user needs to be careful while adding commits
to each tree's index.
2020-12-07 09:02:44 -05:00
Dylan Baker f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
Xavier Claessens 6333ee88c1 Merge wraps from subprojects into wraps from main project
wraps from subprojects are now merged into the list of wraps from main
project, so they can be used to download dependencies of dependencies
instead of having to promote wraps manually. If multiple projects
provides the same wrap file, the first one to be configured wins.

This also fix usage of sub-subproject that don't have wrap files. We can
now configure B when its source tree is at
`subprojects/A/subprojects/B/`. This has the implication that we cannot
assume that subproject "foo" is at `self.subproject_dir / 'foo'` any
more.
2020-10-13 17:55:16 -04:00
Xavier Claessens dccff1f2bc msubprojects: Handle wrap-file to wrap-git case 2020-10-13 11:12:49 +00:00
Xavier Claessens 3ade5bbd92 msubprojects: Handle change of URL in wrap-git 2020-10-13 11:12:49 +00:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Xavier Claessens 17f07a53d0 msubprojects: Fix unit tests on Windows 2020-09-18 03:01:15 +00:00
Xavier Claessens da72e6284e msubprojects: Revert back to rev-parse instead of --show-current
It is undocumented in manpage, but --show-current is new in git 2.22
which is too recent for distros we want to support like Ubuntu 18.04.
2020-09-18 03:01:15 +00:00
Xavier Claessens e0cd54a322 msubprojects: Stop trying to guess subproject type
It was done to include them in `meson subprojects foreach` without
--types argument, but it's better to special case missing --types and
include wraps that have type=None too. It was a bad idea because that
was messing them in `meson subprojects update`, now they are ignored by
that command.
2020-09-18 03:01:15 +00:00
Xavier Claessens 6fbf368fde msubprojects: Avoid useless "no local changes to save" message 2020-09-18 03:01:15 +00:00
Xavier Claessens ce347f2f8c msubprojects: Fix checkout of new tag/branch
If revision is a tag that does not exist locally, `git fetch origin
<revision>` won't create it and checkout will fail. Using --refmap
ensures that references exists locally.
2020-09-18 03:01:15 +00:00
Xavier Claessens 49b61e476f msubprojects: Fix --types default value 2020-09-18 03:01:15 +00:00
Xavier Claessens 14c1a6983d msubprojects: Allow comma separated list of types 2020-09-10 11:39:30 -04:00
Xavier Claessens a3ac25b0c3 msubprojects: Fix review comments 2020-09-10 11:39:30 -04:00
Xavier Claessens 552432e507 git: Use Popen_safe to avoid encoding issues 2020-09-10 11:39:30 -04:00
Xavier Claessens d3c06bb023 msubprojects: Rework update command
Besides refactoring code into smaller functions:
- Makes the --rebase behaviour the default for consistency: it was
  already rebasing when current branch and revision are the same, it is
  less confusing to rebase when they are different too.
- Add --reset mode that checkout the new branch and hard reset that
  branch to remote commit. This new mode guarantees that every
  subproject are exactly at the wrap's revision.
- Local changes are always stashed first to avoid any data loss. In the
  worst case scenario the user can always check reflog and stash list to
  rollback.

Fixes: #7526
2020-09-10 11:39:30 -04:00
Xavier Claessens 8cb5e3d7d2 msubprojects: Return failure if some commands failed
If the command fails on some subprojects continue with the rest but
return non-0 code. This is useful for CI scripts to ensure it tests
latest code instead of old cached code in case of network error or
something.
2020-09-10 11:39:30 -04:00
Xavier Claessens 064f7241d8 msubprojects: Stash changes before checkout 2020-09-10 11:39:30 -04:00
Xavier Claessens 98d445a070 msubprojects: Support git subprojects with no wrap file
User could have cloned manually a subproject.
2020-09-10 11:39:30 -04:00
Xavier Claessens 3d443d84bd msubprojects: Use less cryptic "git branch --show-current" command
It describes well what it does, compared to obscure "rev-parse".
2020-09-10 11:39:30 -04:00
Xavier Claessens 400a35e9ea msubprojects: Add --type argument
It is often desired to only update git repositories and not pull
files from wrapdb.
2020-09-10 11:39:30 -04:00
Xavier Claessens 7ba0035db7 msubprojects: Use wrap.Resolver() to load all PackageDefinition
Besides being simpler, it has the advantage of picking directories that
don't have a .wrap file assotiated.
2020-09-10 11:39:30 -04:00
Michael Brockus 98ddd52ced
Cherry-picking - (rm python2 % add python3 .format) (#6725) 2020-03-03 21:45:43 +02:00
Nirbheek Chauhan 4597235f92 msubprojects: We return a string from git() now
Fixes https://github.com/mesonbuild/meson/issues/6651
2020-02-20 12:20:29 -05:00
Nirbheek Chauhan 712b2f08c7 Move git helper out into mesonlib for reuse
Reuse the git helper for `meson wrap` and `meson subprojects` so we
don't need to maintain the same git-colors-on-windows workarounds in
multiple places.
2020-01-22 17:29:38 -05:00
Nirbheek Chauhan da486bfddc msubprojects: Rename 'git' to 'git_output'
No functional changes. Split out from the next commit for ease of
reading.
2020-01-22 17:29:38 -05:00
Antonio Ospite c616686d5d Fix 'meson subprojects foreach' when command returns non-zero exit code
The 'output' field of the subprocess.CalledProcessError exception is
valid only when subprocess.check_output() is called, trying to access it
after calling subprocess.check_call() results in an unwanted exception
when commands return non-zero exit code, e.g.:

-----------------------------------------------------------------------
$ meson subprojects foreach false
Executing command in ./subprojects/sqlite-amalgamation-3250100
  -> Not downloaded yet
Executing command in ./subprojects/gstreamer
Traceback (most recent call last):
  File "/home/ao2/meson/meson/mesonbuild/msubprojects.py", line 177, in foreach
    subprocess.check_call([options.command] + options.args, cwd=repo_dir)
  File "/usr/lib/python3.7/subprocess.py", line 363, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['false']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ao2/meson/meson/mesonbuild/mesonmain.py", line 129, in run
    return options.run_func(options)
  File "/home/ao2/meson/meson/mesonbuild/msubprojects.py", line 248, in run
    options.subprojects_func(wrap, repo_dir, options)
  File "/home/ao2/meson/meson/mesonbuild/msubprojects.py", line 180, in foreach
    out = e.output.decode().strip()
AttributeError: 'NoneType' object has no attribute 'decode'
-----------------------------------------------------------------------

Use subprocess.check_output() instead and behave more like git commands
in handling stderr.

This makes it possible to actually run commands on all subprojects
allowing them to fail on some subprojects and succeed on others.

Also catch the case of missing commands and print an error message in
this case as well.
2019-12-05 21:18:36 +02:00
Nirbheek Chauhan 1cb680388d wrap: Redirect stdin to DEVNULL (again)
Same fix as e7b25018c4, was accidentally
missed when this code was rewritten.
2019-11-28 19:00:53 +05:30
Daniel Mensinger e02c101575
cmake: moved subprojects into the CMake module 2019-06-06 18:27:05 +02:00
Markus Theil 93f04033c1 subproject: fix update_svn
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
2019-06-03 20:32:55 +03:00
Antonio Ospite e680dbe065 Add 'meson subprojects foreach' command
Sometimes it is convenient to run an arbitrary command (e.g. 'git diff')
on all subprojects.

Add a 'meson subprojects foreach' command to take care of that.

For this command the common argument 'subprojects' does not make sense,
so only add '--sourcedir' and cover the case of a missing
options.subprojects in run().
2019-04-01 11:51:02 +02:00
Andrei Alexeyev faf3581df6 Fix git wraps with submodules
* If clone-recursive is specified, populate submodules only after
    the specified revision/branch has been checked out. Fixes #4996

    * Update submodules recursively on `meson subprojects update`
2019-03-11 20:31:52 +02:00
Xavier Claessens d655515a6b Add 'meson subprojects download' command 2018-12-02 08:37:32 -05:00
Xavier Claessens b5eac54c9e Add 'meson subprojects checkout' command 2018-12-02 08:37:32 -05:00
Xavier Claessens 60b58e056f Add 'meson subprojects update' command
This is inspired by gst-build's git-update script.
2018-12-02 08:37:32 -05:00