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.
8 years ago
Jussi Pakkanen
fa0382f1f9
Add option to mesonconf to wipe cached data.
8 years ago
Mike Sinkovsky
969be1f679
cleanup: Remove redundant parentheses
8 years ago
Mike Sinkovsky
77515ee541
style: [E303] too many blank lines (2)
8 years ago
Igor Gnatenko
dd36847c4b
style: fix E202 violations
...
E202: whitespace before ']'
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
8 years ago
Igor Gnatenko
c13160034f
style: fix E201 violations
...
E201: whitespace after '['
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
8 years ago
Igor Gnatenko
f0bc5568a7
style: fix E703 violations
...
E703: statement ends with a semicolon
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
8 years ago
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>
8 years ago
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>
8 years ago
Igor Gnatenko
2017d8578a
style: fix E226 violations
...
E226: missing whitespace around arithmetic operator
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
8 years ago
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>
8 years ago
Igor Gnatenko
5bf22c5678
add support for $sharedstatedir
...
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
8 years ago
Igor Gnatenko
2962d3a66b
add support for $infodir
...
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
8 years ago
Igor Gnatenko
380b362fa4
add support for $sbindir
...
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
8 years ago
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>
8 years ago
Jussi Pakkanen
e0034fd6a5
A few sysconf fixes.
8 years ago
Jussi Pakkanen
1f4cce86ad
Remove shebangs on files that are not runnable and add execute bits to those that are.
8 years ago
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.
8 years ago
Jussi Pakkanen
7694321276
Renamed compile&link args and made them accessible from get_option.
9 years ago
Hemmo Nieminen
3f3fcace3d
mconf: Include testing related options when printing build configuration.
9 years ago
Hemmo Nieminen
af6f4c9b9c
coredata: Centralize builtin option descriptions and definitions.
9 years ago
Hemmo Nieminen
336904b553
Move MesonException from coredata to mesonlib.
9 years ago
Jussi Pakkanen
a405f7a499
Grab base options from the command line.
9 years ago
Jussi Pakkanen
0c63f75aaf
Converted coverage into a base option.
9 years ago
Nirbheek Chauhan
11f63105d0
New builtin option: libexecdir for installation of helper executables
9 years ago
Jussi Pakkanen
19046fd854
Added new base options and some sample opts for gcc.
9 years ago
Martin Ejdestig
6a90d5d587
Print value of werror in mesonconf
9 years ago
Jussi Pakkanen
3abd5305c2
Default to cwd in mesonconf. Closes #400 .
9 years ago
Jussi Pakkanen
23b98cd6e6
Renamed meson package to mesonbuild so that we can have a script named meson in the same toplevel dir.
9 years ago
Jussi Pakkanen
2ee27504a8
Moved mesonconf implementation in the module.
9 years ago
Jussi Pakkanen
66c01401de
Moved scripts in the module and started work to run them via the main meson command.
9 years ago
Jussi Pakkanen
a5508d3fd3
Can run most of test suite (with hacks).
9 years ago
Jussi Pakkanen
8b1039fa30
Organise files into a module structure.
9 years ago
Yoav Alon
a4809cf632
Added support for extended command line to overcome OS command line length limitation
9 years ago
Jussi Pakkanen
56f11cf89b
Print lib type list properly.
9 years ago
Wink Saville
c49da5aa00
Enhance mesonconfig.py help
...
Added code to output the 'Possible values' and
also titles for the columns.
Added code to so 'choices' is allowed for all
UserOption's.
9 years ago
Jussi Pakkanen
cc19bf0f45
Move option validation in objects rather than doing it only in the conf script.
9 years ago
Jussi Pakkanen
e2313b85d7
Refactored builtin options to a dictionary and created a new default library target type.
9 years ago
Jussi Pakkanen
b197d9e279
Can set compiler options with mesonconf.
9 years ago
Jussi Pakkanen
4dff3f9fb3
Refactored option classes to mesonlib.
9 years ago
Jussi Pakkanen
067935ce76
Added conf option for build tree layout.
9 years ago
Jussi Pakkanen
6cca79b052
Added multiple selectable warning levels.
9 years ago
Jussi Pakkanen
0da1fbcb98
Flipped one character.
10 years ago
Igor Gnatenko
c74a72a6a1
mesonconf: fix bad-continuation
...
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
10 years ago
Igor Gnatenko
f1bc1e2757
mesonconf: fix tb and parsing options
...
Traceback (most recent call last):
File "./mesonconf.py", line 202, in <module>
print(args)
NameError: name 'args' is not defined
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
10 years ago
Jussi Pakkanen
11a9f61e51
Renamed buildtype from "type" to "buildtype" for consistency.
10 years ago
Jussi Pakkanen
ea4b9c590e
Fix mesonconf when running in the build directory without a path argument.
10 years ago
Jussi Pakkanen
ba77e0dbbd
Use argparse in mesonconf.py.
10 years ago
Jussi Pakkanen
525f0ae6d2
Harmonised copyright declarations.
10 years ago
Jussi Pakkanen
d61529caf0
One more off by one error.
10 years ago