Commit Graph

47 Commits

Author SHA1 Message Date
Eli Schwartz b411be5edc
fully type mdist.py 2023-06-25 10:08:15 -04:00
Eli Schwartz b05764b73e
mdist: consolidate facts about the current dist using a dataclass
And avoid passing variables around several functions just to finally get
where they need to be. These function signatures were kind of ugly...

Also the use of dataclasses makes a big chunk of this file now typed
properly.
2023-06-25 10:08:15 -04:00
Eli Schwartz a146ee6946
mdist: refactor lots of code into VCS-specific classes
Most of the dist handling is either git-specific or hg-specific.
Tangling it all together makes it much harder to analyze what is going
on.
2023-06-25 10:08:14 -04:00
Xavier Claessens b30cd5d2d5 Make --vsenv a readonly builtin option
We need to remember its value when reconfiguring, but the Build object
is not reused, only coredata is.

This also makes CLI more consistent by allowing `-Dvsenv=true` syntax.

Fixes: #11309
2023-03-29 09:33:41 -04:00
Eli Schwartz 3e7c08f358
fix one more missing explicit "setup" subcommand 2023-03-20 17:22:51 -04:00
Eli Schwartz 680b5ff819
treewide: add future annotations import 2023-02-01 17:01:30 -05:00
Dylan Baker a5d547e0d9
pylint: enable useless-return 2022-11-29 23:26:05 -05:00
Eli Schwartz 1eaf49c880 flake8: remove no longer used imports 2022-06-10 09:15:48 -04:00
Eli Schwartz 1420d0dace
mdist: use better approach to finding original configured options
Instead of reading intro-buildoptions.json, a giant json file containing
every option ever + its current value, use the private file that is
internally used by msetup for e.g. --wipe to restore settings.

This accurately tracks exactly the options specified on the command
line, and avoids lengthy summary messages containing all the overridden
defaults.

It also avoids passing potentially incompatible options, such as
explictly specifying -Dpython.install_env while also having a non-empty
-Dpython.{x}libdir

Fixes #10181
2022-04-11 14:10:59 -04:00
andy5995 b1e6cc5553 implement 'dist --allow-dirty' flag
closes #9824
2022-02-10 21:23:20 -05:00
Xavier Claessens 928078982c Add --vsenv command line option and active VS only when needed 2021-10-10 23:15:18 +03:00
Eli Schwartz 604088b541 mdist: use git archive with git repositories for correctness
Fixes various inconsistencies:
- gitattributes is respected
  - export-subst
  - export-ignore
- submodules with relative paths are not checked out relative to the
  local clone (which does not work anyway)
- no need to manually remove gitfiles with inaccurate heuristics

Fixes #2287
Fixes #3081
Fixes #8144
2021-09-03 14:14:15 -04:00
Dylan Baker 06fdb29daa pylint: turn on superfluous parens warning
Which is really useful for catching parens used with keywords like
assert. Don't use parens with assert, it's bad.
2021-08-31 16:28:54 -04:00
Paolo Bonzini 5215f4fa98 cleanup self.options.wd
It is never None and always an absolute path
2021-07-07 18:00:37 +02:00
Paolo Bonzini b44a51d0fd resolve symlinks passed to -C
"meson setup" is resolving symlinks for the build directory in
validate_core_dirs.  For consistency with it, do the same when
the build directory is passed via -C to devenv, dist, init, install
and test.

This ensures for example that the path to test dependencies is
computed correctly in "meson test".

Fixes: #8765
2021-07-07 18:00:37 +02:00
Andrea Pappacoda d0101cbfb7 dist: only exclude actual git files
Instead of excluding all files starting with .git, meson dist now only excludes files really used by git
2021-07-04 01:25:23 +03:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Naveen M K 7a6ad2953a Don't use `os.path.relpath` in dist command
This is problematic when we meson is installed in the different 
root(say C:) while building from another root(say D:).
This is how it is done in mesonpep517 and causes problems
because of that.
2021-05-30 00:49:43 +03:00
Tristan Partin cc54284885
Fix issue where multiple dist files were not being produced for comma separated formats value 2021-04-26 17:13:13 +01:00
Xavier Claessens 3990754bf5 Allow add_dist_script() in subprojects
Fixes: #8440.
2021-03-18 08:41:21 -04: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
Xavier Claessens 0626465ea8 Fix executable as script on Windows
On Windows this would fail because of missing DLL:
```
mylib = library(...)
exe = executable(..., link_with: mylib)
meson.add_install_script(exe)
```

The reason is on Windows we cannot rely on rpath to find libraries from
build directory, they are searched in $PATH. We already have all that
mechanism in place for custom_target() using ExecutableSerialisation
class, so reuse it for install/dist/postconf scripts too.

This has bonus side effect to also use exe_wrapper for those scripts.

Fixes: #8187
2021-01-30 09:51:06 +00:00
Xavier Claessens e6ab364a69 dist: Use windows_proof_rmtree() instead of shutil.rmtree() 2021-01-26 21:32:03 -05:00
Xavier Claessens baa9eeebe4 dist: Allow packaging subproject in same git repo as main project 2021-01-26 21:32:03 -05:00
Dylan Baker 23d3b98fc1 split mesonlib into a package
Currently mesonlib does some import tricks to figure out whether it
needs to use windows or posix specific functions. This is a little
hacky, but works fine. However, the way the typing stubs are implemented
for the msvcrt and fnctl modules will cause mypy to fail on the other
platform, since the functions are not implemented.

To aleviate this (and for slightly cleaner design), I've split mesonlib
into a pacakge with three modules. A universal module contains all of
the platform agnositc code, a win32 module contains window specific
code, a posix module contains the posix specific code, and a platform
module contains no-op implementations. Then the package's __init__ file
imports all of the universal functions and all of the functions from the
approriate platform module, or the no-op versions as fallbacks. This
makes mypy happy, and avoids `if`ing all over the code to switch between
the platform specific code.
2021-01-23 12:48:29 +01:00
Aman Verma cb10ba75d4 mdist: Print file path at the end of run() instead of in create_hash(). 2020-12-22 21:38:28 -05:00
Aman Verma 1f7c8ec7e2 mdist: Ensure correct format for sha256sum.
We conform to the format described at
<https://www.gnu.org/software/coreutils/manual/html_node/md5sum-invocation.html>.
and compatible with busybox and Perl's shasum utility.
2020-12-22 21:38:28 -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
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Dylan Baker 87248d9020 mdist: actually constrain the choices of the --formats option
Since we already have that list available.
2020-09-22 16:58:08 -07:00
Paolo Bonzini 492afe50a4 environment: use ExternalProgram to find ninja
This allows the NINJA environment variable to support all the Windows special
cases, especially allowing an absolute path without extension.

Based on a patch by Yonggang Luo.

Fixes: #7659
Suggested-by: Nirbheek Chauhan <nirbheek@centricular.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-09-04 15:38:12 +02:00
Xavier Claessens 13316f99fe wrap: Refactor to split wraps dictionary into 3 separate dicts
It makes the code cleaner to have 3 separate dictionaries for
packagename, dependency and programs.
2020-07-01 09:51:57 -04:00
Nirbheek Chauhan ec1bd22b15 mdist: Filter out buildtype to avoid warning
Since we parse buildoptions.json to pass options, we end up passing
-Dbuildtype and also -Doptimization and -Ddebug which triggers the
warning:

WARNING: Recommend using either -Dbuildtype or -Doptimization + -Ddebug [...]

Filter out buildtype. It is redundant.
2020-06-13 11:02:19 +00:00
Xavier Claessens f4d98a3e72 dist: Print location of generated tarballs
Otherwise the location is not discoverable without reading online
documentation.
2020-03-29 21:12:34 +03:00
Xavier Claessens 8603c3b445 dist: Add --no-tests option
It is not always needed to test generated tarballs, for example when
they are generated by CI that already does its own testing.
2020-03-29 21:12:34 +03:00
Michael Brockus 98ddd52ced
Cherry-picking - (rm python2 % add python3 .format) (#6725) 2020-03-03 21:45:43 +02:00
Nirbheek Chauhan b7c70c47a6 mdist: Use windows_proof_rmtree when deleting 2020-02-17 18:36:14 +02:00
Nirbheek Chauhan 8650c763d9 mdist: Don't delete builddir on dist failure
Closes https://github.com/mesonbuild/meson/issues/1976
2020-02-17 18:36:14 +02:00
Richard Laager 5118cf914d Exclude .hg* from dist tarballs
Debian's lintian checker complaints when upstream tarballs contain an
.hgtags file.

This excludes ".hg[a-z]*".  This is mostly consistent with the git
handling in del_gitfiles() which deletes .git*.  hg archive --help shows
an example of -X ".hg*".  However, instead of ".hg*", I have used
".hg[a-z]*" to keep the automatically added hg_archival.txt.  This file
may be useful to link the tarball to the Mercurial revision for either
manual inspection or in case any code interprets it for a --version or
similar.

This also excludes .hgignore and other things like .hgflow, which seems
desirable.

Fixes #6575
2020-02-10 22:53:42 +02:00
Jussi Pakkanen 254cb3209d Set source and build dir envvars when running dist. 2020-01-23 02:25:52 +02:00
Xavier Claessens 5031f4981d dist: Fix --include-subprojects when .wrap file has directory value 2019-12-10 22:19:00 +02:00
Xavier Claessens 1298f71b1c dist: Add --include-subprojects option 2019-12-08 20:21:43 +02:00
Thomas Petazzoni 998a1f5fa3 mdist.py: import lzma only when needed
Source of patch:
http://lists.busybox.net/pipermail/buildroot/2019-October/262990.html
http://code.bulix.org/gdxcu4-914360

Fixes https://github.com/mesonbuild/meson/issues/6012
2019-10-19 14:28:34 +03:00
Xavier Claessens 7cc112df0d dist: Add '-C' option and print better error message
It was not obvious that 'meson dist' must be run from build directory.
2019-08-07 22:57:02 +03:00
Thibault Saunier 645a8584fe dist: Pass right build options when configuring dist directory
Fixes https://github.com/mesonbuild/meson/issues/5732
2019-07-30 18:04:45 +03:00
Jussi Pakkanen f2e018c7f3 Create multiple different archive types with dist. 2019-07-23 23:26:46 +03:00
Jussi Pakkanen 7ce2a24f42 Made dist a top level command. 2019-07-23 23:26:46 +03:00