Commit Graph

47 Commits

Author SHA1 Message Date
Jussi Pakkanen 9b2e533d87 Always build parser objects anew to avoid leaking old data. 2018-03-27 00:39:45 +03:00
Jukka Laurila 52c50da6c7 Refactor: Add log.error and log.exception to reduce code duplication. 2018-03-10 18:04:52 +02:00
Sander Sweers 3a0ab6a2bc mconf: Make it pep8 compliant 2018-03-04 19:56:53 +01:00
Sander Sweers 9bafde953a mconf: make print_aligned static 2018-03-04 19:54:50 +01:00
Sander Sweers 9d31c751b6 mconf: Do not store dict keys for no reason
If a dict is empty it will evaluate to False
2018-03-04 19:54:50 +01:00
Sander Sweers 84d382f963 mconf: User newline instead of printing empty string 2018-03-04 19:54:50 +01:00
Sander Sweers f805f8e109 mconf: Replace usage of keys() on dicts with direct call by sorted
Calling sorted or list on a dictionary will return the keys.
2018-03-04 19:54:50 +01:00
Sander Sweers 41b5983823 Re-implement function print_aligned
It is now more readable, more pythonic and fixes #3149
2018-03-04 19:54:50 +01:00
Sander Sweers ae90b6586f mconf: Do not turn opt.choices into a string
It is inconsistent with other option groups. It also breaks
print_aligned as it handles lists.
2018-03-04 19:54:50 +01:00
Hemmo Nieminen 7fb8e518b2 Harmonize data pickling.
Try to be more consistent on using save() and load() methods to pickle
data.
2018-03-01 01:06:51 +02:00
Eric Engestrom da2343fb5e mconf: print choices of base options
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-11-27 20:54:03 +02:00
Josh Soref 4a572434a0 spelling: when 2017-11-26 17:28:33 +00:00
Eric Engestrom 5f7f5cdb05 Print correct command in help message
Taking mconf for instance:
before:
  $ meson configure --help
  usage: meson [-h] [-D SETS] [--clearcache] [directory [directory ...]]
after:
  $ meson configure --help
  usage: meson configure [-h] [-D SETS] [--clearcache] [directory [directory ...]]
2017-11-09 21:12:34 +02:00
Jussi Pakkanen a800c96f99 Add option to limit maximum number of concurrent link processes. 2017-08-05 00:24:59 +03:00
Elliott Sales de Andrade ea636fcd51 Remove unused variables. 2017-05-17 04:41:54 -04:00
Elliott Sales de Andrade faf114299b Remove unnecessary __init__ methods. 2017-05-17 03:54:49 -04:00
Yasushi SHOJI abd12b69ea mesonconf: reorder output columns
mesonconf prints build dir information in the order of

  'Option' 'Description' 'Current Value' and, optionally, 'Possible Value'.

The Description tends to be longer and push the following values far
right, sometimes way far than fits in the full screen size of a
terminal on a FullHD monitor.

Experienced users know which options they want to change without
looking at the description string however they need to check the
current values for sure.

This patch moves the description to the last column.  Now mesonconf
prints options in the following order:

  'Option' 'Current Value' 'Possible Value' 'Description'

To implement this, mainly print_aligned() is modified.  The second
argument of the function is changed from

 - array of array of string to
 - array of dict with 'name', 'descr', 'value', and 'choices,

which maps to 'option', 'description', 'current value' and 'possible
values', respectively.

Since the position of the possible values are moved before its
description, the presence and the length of it affects header as well
as the following description.  Thus, we cal curate it before printing
the header.

To avoid re-calculation, we keep string version of the values and
flattened version of the possible values _in the given array_, which
means that now the print_aligned() function modify the the given
array.  The current callers do not use the passing array.  So there
should be no bad effects.
2017-05-15 22:02:06 +03:00
Dylan Baker a8173630ea Don't use len() to test emptiness vs not emptiness
Meson has a common pattern of using 'if len(foo) == 0:' or
'if len(foo) != 0:', however, this is a common anti-pattern in python.
Instead tests for emptiness/non-emptiness should be done with a simple
'if foo:' or 'if not foo:'

Consider the following:
>>> import timeit
>>> timeit.timeit('if len([]) == 0: pass')
0.10730923599840025
>>> timeit.timeit('if not []: pass')
0.030033907998586074
>>> timeit.timeit('if len(['a', 'b', 'c', 'd']) == 0: pass')
0.1154778649979562
>>> timeit.timeit("if not ['a', 'b', 'c', 'd']: pass")
0.08259823200205574
>>> timeit.timeit('if len("") == 0: pass')
0.089759664999292
>>> timeit.timeit('if not "": pass')
0.02340641999762738
>>> timeit.timeit('if len("foo") == 0: pass')
0.08848102600313723
>>> timeit.timeit('if not "foo": pass')
0.04032287199879647

And for the one additional case of 'if len(foo.strip()) == 0', which can
be replaced with 'if not foo.isspace()'
>>> timeit.timeit('if len("   ".strip()) == 0: pass')
0.15294511600222904
>>> timeit.timeit('if "   ".isspace(): pass')
0.09413968399894657
>>> timeit.timeit('if len("   abc".strip()) == 0: pass')
0.2023209120015963
>>> timeit.timeit('if "   abc".isspace(): pass')
0.09571301700270851

In other words, it's always a win to not use len(), when you don't
actually want to check the length.
2017-05-02 21:57:26 +03:00
Jussi Pakkanen fa0382f1f9 Add option to mesonconf to wipe cached data. 2017-01-23 21:01:34 +02:00
Mike Sinkovsky 969be1f679 cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
Mike Sinkovsky 77515ee541 style: [E303] too many blank lines (2) 2017-01-11 12:33:27 -05:00
Igor Gnatenko dd36847c4b style: fix E202 violations
E202: whitespace before ']'

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-02 19:09:47 +01:00
Igor Gnatenko c13160034f style: fix E201 violations
E201: whitespace after '['

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-02 19:08:16 +01:00
Igor Gnatenko f0bc5568a7 style: fix E703 violations
E703: statement ends with a semicolon

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 969dc7e995 style: fix E124 violations
E124: closing bracket does not match visual indentation

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05: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 139e020ede tree-wide: use proper 'not in' notation
Let's be more pythonic and 'not is' seems really weird.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 21:48:35 +01:00
Igor Gnatenko 5bf22c5678 add support for $sharedstatedir
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-18 00:08:45 +01:00
Igor Gnatenko 2962d3a66b add support for $infodir
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-18 00:01:27 +01:00
Igor Gnatenko 380b362fa4 add support for $sbindir
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-18 00:01:23 +01:00
Igor Gnatenko c9818c02ec add builtin support for localstatedir
Reported-by: Richard Hughes <richard@hughsie.com>
Closes: https://github.com/mesonbuild/meson/issues/1142
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
2016-12-06 20:27:02 +02:00
Jussi Pakkanen e0034fd6a5 A few sysconf fixes. 2016-11-02 12:11:47 -07:00
Jussi Pakkanen 1f4cce86ad Remove shebangs on files that are not runnable and add execute bits to those that are. 2016-10-07 21:10:33 +03:00
Elliott Sales de Andrade 4c71695e41 Use context manager for file I/O.
There are a few cases where a context manager cannot be used, such as
the logger.
2016-08-27 18:29:55 -04:00
Jussi Pakkanen 7694321276 Renamed compile&link args and made them accessible from get_option. 2016-05-28 21:56:41 +03:00
Hemmo Nieminen 3f3fcace3d mconf: Include testing related options when printing build configuration. 2016-04-04 02:52:30 +03:00
Hemmo Nieminen af6f4c9b9c coredata: Centralize builtin option descriptions and definitions. 2016-04-04 02:52:30 +03:00
Hemmo Nieminen 336904b553 Move MesonException from coredata to mesonlib. 2016-04-01 00:52:45 +03:00
Jussi Pakkanen d87eb7d290 Merge branch 'base_options'. 2016-03-20 22:04:24 +02:00
Jussi Pakkanen a405f7a499 Grab base options from the command line. 2016-03-20 20:43:32 +02:00
Jussi Pakkanen 0c63f75aaf Converted coverage into a base option. 2016-03-20 19:16:49 +02:00
Nirbheek Chauhan 11f63105d0 New builtin option: libexecdir for installation of helper executables 2016-03-17 16:17:06 +05:30
Jussi Pakkanen 19046fd854 Added new base options and some sample opts for gcc. 2016-03-16 21:55:03 +02:00
Martin Ejdestig 6a90d5d587 Print value of werror in mesonconf 2016-02-22 19:45:34 +01:00
Jussi Pakkanen 3abd5305c2 Default to cwd in mesonconf. Closes #400. 2016-02-20 00:02:44 +02:00
Jussi Pakkanen 23b98cd6e6 Renamed meson package to mesonbuild so that we can have a script named meson in the same toplevel dir. 2016-01-16 17:35:29 +02:00