Commit Graph

61 Commits

Author SHA1 Message Date
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
Elliott Sales de Andrade e58f186121 Fix subproject initialization without git installed. 2018-11-22 22:31:54 +02:00
Xavier Claessens be09acbf56 wrap: Check the directory key is a name and not a path
Closes #1413.
2018-10-27 16:36:01 +03:00
Xavier Claessens adb9fdef3a wrap: Fix crash with file based wraps
Add unit test to avoid regressions in the future.
2018-10-21 23:21:36 +03:00
Xavier Claessens 76ac4f5689 wrap: Make 'directory' key optional
wrap files can now omit the 'directory' key, in that case it will
default to the packagename.
2018-10-18 18:36:32 -04:00
Xavier Claessens d9ea7b16a8 wrap: Rename p to self.wrap 2018-10-18 18:29:35 -04:00
Xavier Claessens b26eb3d384 wrap: Disable interpolation 2018-10-18 18:25:05 -04:00
Xavier Claessens 3f98ad8eed wrap: Improve error handling and logging 2018-10-18 11:42:17 -04:00
Xavier Claessens 1889e33389 wrap: Remove dead code trying to update git/hg/svn repositories
If the directory exists we early return or raise exception in resolve()
method. It was already like that even before the recent refactoring of
the code.

It is safer like that anyway, we don't want a project reconfigure to
silently pull new code. Updating subprojects should be an explicit
action of the user. For example gst-build has a 'git-update' script that
does that. In the future we could add a 'meson subprojects update'
command.
2018-10-18 11:42:17 -04:00
Xavier Claessens d6fba7f01c wrap: Allow source and patch to be local files
It is sometimes important to be able to build projects offline, in that
case subproject tarballs and patches could be shipped directly within
the project's repository.
2018-10-17 21:56:49 -04:00
Xavier Claessens a3db9f6ae3 wrap: Some cleanups and fixes in resolver
- Use CongifParser instead of parsing ourself, this will give more
  flexibility in the future.

- Always read the .wrap file first, because if it contains the
  'directory' key we should use that value instead of packagename for
  the path where do download/lookup for the subproject.

- If we download the subproject (git/submodule/tarball/etc) we should
  still check it contains a meson.build file.
2018-10-17 21:56:49 -04:00
Andrei Alexeyev 67cc636e53 Add 'clone-recursive' option for git wraps
This causes Meson to clone the repo with the --recursive flag, pulling
all of the submodules automatically.
2018-09-16 14:57:56 +03:00
Nirbheek Chauhan e7b25018c4 wrap: Redirect git's stdin to DEVNULL
Otherwise, git fiddles with the cmd.exe console's color behaviour and
disables it, which causes it to stop interpreting ANSI color codes
outputted by meson for colored output.

Effectively, as soon as any subproject is initialized, cmd.exe goes
nice coloured output to ugly raw ANSI codes.
2018-09-03 21:12:09 +03:00
Andrei Antonov 8f7781f1d6 using urlopen() with explicit timeout 2018-08-27 00:55:45 +03:00
Mohammed Amer Khalidi 376cdd7054 Adding support to checkout from reviews in git/gerrit using commit ids. 2018-08-07 18:55:46 +03:00
Nirbheek Chauhan 0ec18a0531 wrap: Fix broken logic when initializing submodules
Also be more lenient when doing git checkout, and continue even if it
failed.

Closes https://github.com/mesonbuild/meson/issues/3088
2018-02-20 00:16:38 +02:00
Nirbheek Chauhan 15a1a317f4 wrap: Handle more submodule status cases
The '+' and 'U' cases should not happen normally because we don't run
any git commands if the subproject directory exists and contains
a meson build file. However, if the user accidentally messed up the
subproject checkout to a version that had no build files, we would
error out with an assertion.
2018-02-11 13:41:06 +02:00
Jussi Pakkanen 7d49d1d2d7 Merge pull request #2373 from leiflm/svn-wraps
introduce svn wrap support
2017-10-01 01:21:12 +03:00
Leif Middelschulte a90e47bd4f adds missing import of `Popen_safe` 2017-09-30 19:49:14 +02:00
Leif Middelschulte 078527a744 As per jpakkane's suggestion use `Popen_safe` instead of `subprocess.getoutput`
Jussi suggested to use `Popen_safe` from meson's library for portability reasons.
2017-09-30 19:45:24 +02:00
liugang c93bce7839 Don't download patch archive if already download
the behavior of download patch should
keep same as download package.
2017-09-29 21:43:28 +03:00
Leif Middelschulte 50376cca37 fixup 993a12c5: use right variable 2017-09-26 14:03:07 +02:00
Leif Middelschulte 993a12c543 avoid errornous type conversion. Compare strings instead 2017-09-26 14:01:29 +02:00
Leif Middelschulte fab15d433a fixes offline working (if desired revision is already present). 2017-09-26 13:56:58 +02:00
Leif Middelschulte aa28675ebc fixes initial checkout command independend of provided revision 2017-09-26 13:13:46 +02:00
Leif Middelschulte 667d5d2d9f introduce svn wrap support 2017-09-25 22:26:42 +02:00
liugang a93ac1a6a8 Improve download package
Using wrap mechanism in enterprise environment,
Some package is very large, example, sdk package from
BSP vendor.

so:
- open file in the output directory with a temporary name
- download a chunk, update hash calculation, write chunk to file
- when finished close file and check the hash
- if hash is incorrect, delete temp file and raise error
- if hash is correct, atomically rename temp file to final file

fix issue: #2358
2017-09-23 16:01:11 +08:00
liugang de259b6690 Fix unpack patch archive fail
fix shutil.unpack_archive() failure when the
destination files already exists and is read-only.

Example: all files in opensource package live555
is `-r--r--r--`, if some file in patch archive try to
patch original files of live555, shutil.unpack_archive
will raise `[Errno 13] Permission denied`
2017-09-23 15:59:43 +08:00
liugang 7060b15773 fix patch archive never download on some case
Fix issue #2359
2017-09-23 13:53:27 +08:00
Luke Shumaker 4dbbb4884c flake8: Clean up complained-about unused imports
This also adds a "# noqa: F401" comment on an unused "import lzma",
which we are using it in a try/except block that is being used to
check if the lzma module is importable; of course it is unused.

v2: This turned out to be a little tricky.

    mesonbuild/modules/__init__.py had the "unused" import:

        from ..interpreterbase import permittedKwargs, noKwargs

    However, that meant that the various modules could do things like:

        from . import noKwargs # "." is "mesonbuild.modules"

    Which breaks when you remove __init__.py's "unused" import.  I
    could have tagged that import with "# noqa: F401", but instead I
    chose to have each of the module import directly from
    "..interpreterbase" instead of ".".
2017-09-21 13:41:03 -04:00
Alistair Thomas a195b78c8d Whitespace tweaks to reduce Flake8 warnings 2017-05-29 19:32:47 +03:00
Goncalo Carvalho c9c3070f53 fix typo 2017-05-26 23:21:48 +03:00
Elliott Sales de Andrade 83d1c7f063 Rearrange trys to avoid possible undefined vars. 2017-05-17 05:37:02 -04:00
Elliott Sales de Andrade ea636fcd51 Remove unused variables. 2017-05-17 04:41:54 -04:00
Ernestas Kulik 8d720527b7 wrap: pass -C to git when resolving submodules
Using Meson from outside a git repo results in an error when trying to
resolve submodule subprojects. Running git from inside subproject root
should be enough to fix it.

Partially fixes #1679

Signed-off-by: Ernestas Kulik <ernestas.kulik@gmail.com>
2017-04-25 19:40:23 +03:00
Ernestas Kulik a13bde821f wrap: initialize submodules when updating
After an initial checkout, submodules aren’t initialized and thus trying
to update them fails.

Partially fixes #1679

Signed-off-by: Ernestas Kulik <ernestas.kulik@gmail.com>
2017-04-25 19:39:56 +03:00
Nirbheek Chauhan fa09b122b0 wrap: Also capture stderr while running quiet_git()
We want to return the stderr if the command failed.
2017-03-27 15:09:18 +05:30
Nirbheek Chauhan d5975cc683 wrap: Implement special wrap modes for use by packagers
Special wrap modes:
  nofallback: Don't download wraps for dependency() fallbacks
  nodownload: Don't download wraps for all subproject() calls

Subprojects are used for two purposes:
1. To download and build dependencies by using .wrap files if they
   are not provided by the system. This is usually expressed via
   dependency(..., fallback: ...).
2. To download and build 'copylibs' which are meant to be used by
   copying into your project. This is always done with an explicit
   subproject() call.

--wrap-mode=nofallback will never do (1)
--wrap-mode=nodownload will do neither (1) nor (2)

If you are building from a release tarball, you should be able to
safely use 'nodownload' since upstream is expected to ship all
required sources with the tarball.

If you are building from a git repository, you will want to use
'nofallback' so that any 'copylib' wraps will be download as
subprojects.

Note that these options do not affect subprojects that are git
submodules since those are only usable in git repositories, and you
almost always want to download them.
2017-03-25 06:57:30 +05:30
Nirbheek Chauhan a60d688973 wrap: Initialize subprojects that are git submodules
This will benefit projects such as GNOME Recipes that prefer using
submodules over wraps because it's easier to maintain since git is
aware of it, and because it integrates with their existing
workflow. Without this, these projects have to manually initialize
the submodules which is completely unnecessary.

Closes https://github.com/mesonbuild/meson/issues/1449
2017-03-25 06:47:04 +05:30
Nirbheek Chauhan fb809e79e5 wrap: Check that the package dir contains 'meson'build'
Also use a pathlib.Path object for the checks since it does I/O only
once and is much more efficient anyway. Path objects are available
since Python 3.4, so this is fine.
2017-03-25 03:47:55 +05:30
Marc Becker 92d18b9256 Fix directory context for git wrap check 2017-02-27 13:04:20 -05:00
Mike Sinkovsky 84902cb93a style: [E301] expected 1 blank line, found 0 2017-01-11 12:33:27 -05:00
Igor Gnatenko ef3cc6b3fa style: fix E127 violations
E127: continuation line over-indented for visual indent

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-02 19:16:56 +01:00
Igor Gnatenko 116da33cdd style: fix E128 violations
E128: continuation line under-indented for visual indent

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 2017d8578a style: fix E226 violations
E226: missing whitespace around arithmetic operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko d5ccd20aac fix some of pylint's undefined-variable
************* Module mesonbuild.modules.rpm
E:106,29: Unsupported format character '{' (0x7b) at index 16 (bad-format-character)
************* Module mesonbuild.modules
E: 12,14: Undefined variable 'MesonException' (undefined-variable)
************* Module mesonbuild.modules.gnome
E:699,69: Undefined variable 'sargs' (undefined-variable)
************* Module mesonbuild.wrap.wrap
E:103,25: Undefined variable 'checkoutdir' (undefined-variable)
************* Module mesonbuild.backend.backends
E: 83,16: Undefined variable 'mlog' (undefined-variable)
************* Module mesonbuild.backend.ninjabackend
E:254,105: Undefined variable 't' (undefined-variable)

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 17:09:35 +02:00
Jussi Pakkanen b389f43060 Revert "Merge pull request #1145 from AlexandreFoley/wrap-fix"
This reverts commit 541dd92ef7, reversing
changes made to 155617e539.
2016-12-15 22:33:25 +02:00
Alexandre Foley 27cd8c1e28 The “directory present and not empty” return condition was necessary for subproject to work without a wrap file. Put it back with that added condition that there mustn’t be a wrap file present for returning the package immediately. 2016-12-06 12:32:39 -05:00
Alexandre Foley 61d5934e63 Added a few missing whitespace as noted by Ignatenkobrain. Replaced a comment by the piece of code it said was needed. 2016-12-06 09:45:20 -05:00
Alexandre Foley 228adaa287 Wrap.py: Made it so using an already downloaded subproject is only for the wrap-file case. Git and Mercurial can update the repository if it the wrap is one.
Also did a bit of cleanup.
interpreter.py: There’s a catch all except clause at the line 1928, it didn’t give the user any information whatsoever about the exception it caught. Now it at least print it to the log as a warning.
2016-12-05 17:25:36 -05:00