Commit Graph

57 Commits

Author SHA1 Message Date
Dylan Baker 4fa5292545 coredata: replace get_option with optstore.get_value_for
This is an old method, that is now just a wrapper around the OptionStore
method, that doesn't add any value. It's also an option related method
attached to the CoreData instead of the OptionStore, so useless and a
layering violation.
2025-03-10 14:14:25 -04:00
Jussi Pakkanen 0d7bb776e2 Move OptionKey in the option source file. 2024-07-11 11:53:39 +03:00
Dylan Baker e991c4d454 Use SPDX-License-Identifier consistently
This replaces all of the Apache blurbs at the start of each file with an
`# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing
uses to be consistent in capitalization, and to be placed above any
copyright notices.

This removes nearly 3000 lines of boilerplate from the project (only
python files), which no developer cares to look at.

SPDX is in common use, particularly in the Linux kernel, and is the
recommended format for Meson's own `project(license: )` field
2023-12-13 15:19:21 -05:00
Luke Elliott ce691f8c98 Add comments suggesting to keep shell completion scripts up-to-date near cmd line argument code 2023-11-01 00:06:19 +02:00
Dylan Baker 65a0cd127e templates: fix typo in function name `sameple` -> `sample` 2023-07-25 15:50:21 -04:00
Dylan Baker b0cd88ceae minit: use a Protocol for arguments
Which gives better type hinting. It also points out that we're changing
the type of sourcefiles. That's now fixed
2023-07-25 15:50:21 -04:00
Dylan Baker b082f00250 minit: put imports together 2023-07-25 15:50:21 -04:00
Dylan Baker 54295560ea minit: fix docstring
Which must come before `from __future__`
2023-07-25 15:50:21 -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 680b5ff819
treewide: add future annotations import 2023-02-01 17:01:30 -05:00
Charles Brunet eff385a315 meson init --build should call meson setup and vsenv 2023-01-22 02:25:08 -05:00
Dylan Baker 2d349eae8c
pylint: enable the set_membership plugin
Which adds the `use-set-for-membership` check. It's generally faster in
python to use a set with the `in` keyword, because it's a hash check
instead of a linear walk, this is especially true with strings, where
it's actually O(n^2), one loop over the container, and an inner loop of
the strings (as string comparison works by checking that `a[n] == b[n]`,
in a loop).

Also, I'm tired of complaining about this in reviews, let the tools do
it for me :)
2022-11-30 16:23:29 -05:00
Dylan Baker d5e899c768
pylint: enable the bad_builtin checker
This finds uses of deny-listed functions, which defaults to map and
filter. These functions should be replaced by comprehensions in
idiomatic python because:
    1. comprehensions are more heavily optimized and are often faster
    2. They avoid the need for lambdas in some cases, which make them
       faster
    3. you can do the equivalent in one statement rather than two, which
       is faster
    4. They're easier to read
    5. if you need a concrete instance (ie, a list) then you don't have
       to convert the iterator to a list afterwards
2022-11-29 23:26:05 -05:00
Eli Schwartz 09a2603285
minit: refuse to allow creating broken projects
Some executable names are invalid, and while it's unlikely anyone will
specify such a thing using the --executable argument, it's not unlikely
that people experimenting will attempt to use meson init in a directory
named "test".

This then defaults to that for both the project name and the sample
target name, and the latter produces errors when you try to build it.

Fixes #10321
2022-05-05 20:07:44 -04:00
Alberto Fanjul 05e0712f59 Add vala template 2021-11-16 22:25:14 -05:00
Eli Schwartz d06cc042eb
f-strings 2021-10-04 16:29:32 -04: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
Eli Schwartz 0c7cdb1862
minit: do not misdetect files suffixed as "" or named "." or "c" or "s" as c#
You cannot `str() in str()` and expect it to act like `str() in list()`.

Fixes regression in commit bbc2745dcc
Unbreaks #6573
Fixes #8872
2021-06-13 14:28:08 -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
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
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
Daniel Mensinger c637b913c9
typing: fully annotate mcompile, minit, and msetup 2020-09-08 20:15:57 +02: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
Michael Brockus 52a36a5521
update meson init info message. [skip ci] 2020-06-21 22:34:12 +03:00
TheQwertiest 2fe4c60ae3 Made --help options sorted 2020-06-09 13:57:44 -07:00
Michael 02e7316d31 sample factory implementation 2020-03-19 22:44:59 +02:00
Michael 79d04cebf7 fix typo 2020-03-02 13:50:58 -05:00
Michael 2f080b1f2e add -C to meson init 2020-03-02 13:50:58 -05:00
Michael Brockus 0f92e0c3fa
Update minit.py 2020-02-24 11:34:48 -08:00
Michael Brockus b12ba4b1bc
fixed issue with auto-detection failing 2020-02-24 11:26:51 -08:00
Michael Brockus c72de63b9b
use python set to tuple for checking members 2020-02-24 10:10:56 -08:00
Michael 9edbaec2f4 make use of default project const 2020-02-19 19:04:03 -08:00
Michael ea93619092 make use of enums 2020-02-19 19:02:58 -08:00
Michael 15cbc4cf0d removed hardcoded values for more add less work in the long run. 2020-02-19 18:40:15 -08:00
Michael 69b4203a85 switch Python list for set 2020-02-19 14:34:39 -08:00
Michael 46f9a2a12d remove uneeded '(' and ')' 2020-02-19 13:51:07 -08:00
Michael Brockus 3225070f8b
Update minit.py 2020-02-19 09:39:49 -08:00
Michael bbc2745dcc update the init command 2020-02-02 17:16:32 -08:00
Michael Hirsch, Ph.D 6e708208dd CI: add initial type annotation checking 2019-11-07 22:18:21 +02:00
Michael Hirsch, Ph.D bbe6db08e3 Minit templates modularization 2019-11-02 23:34:58 +02:00
Dylan Baker 5678468c2c Don't use len() to test for container emptiness
I ran the numbers once before (it's in the meson history) but it's
*much* faster to *not* use len for testing if a container is empty or
not.
2019-04-25 12:28:51 -07:00
Xavier Claessens 37067a53c4 Use a single ArgumentParser for all subcommands
This has the adventage that "meson --help" shows a list of all commands,
making them discoverable. This also reduce the manual parsing of
arguments to the strict minimum needed for backward compatibility.
2018-10-04 09:40:21 -04:00
Jussi Pakkanen fb2cdd0fe2 Call it gnu_symbol_visibility instead. 2018-08-09 19:46:49 +03:00
Jussi Pakkanen 3c62eaa9ff Updated sample projects to use visibility kwarg. 2018-08-09 19:46:49 +03:00
Niklas Claesson c6e03b9535 Use visual studio solution directories
This implements support for visual studio solution directories.
Projects will by default be put into directories that map their sub-directory
name in the source folder. No directories are created if `--layout=flat` is used.

Fixes: #2524
2018-04-17 23:41:03 +02:00
Jukka Laurila 8f340ffb8d Generate meson.build based on existing source files when meson init is run in a non-empty directory. 2018-03-06 00:05:17 +02:00
Jukka Laurila fcb95847ed Fix the C and C++ project template options, they were reversed before. 2018-03-06 00:05:17 +02:00
Jon Turney 8958529a25 Fix flake8 'variable assigned value but unused' reports
$ flake8 | grep -E 'F841'
./run_unittests.py:1987:13: F841 local variable 'objc' is assigned to but never used
./run_unittests.py:1988:13: F841 local variable 'objcpp' is assigned to but never used
./mesonbuild/minit.py:272:5: F841 local variable 'uppercase_token' is assigned to but never used
./mesonbuild/minit.py:307:5: F841 local variable 'uppercase_token' is assigned to but never used
./mesonbuild/modules/unstable_icestorm.py:36:9: F841 local variable 'result' is assigned to but never used
./mesonbuild/modules/unstable_icestorm.py:78:9: F841 local variable 'up_target' is assigned to but never used
./mesonbuild/modules/unstable_icestorm.py:81:9: F841 local variable 'time_target' is assigned to but never used
./msi/createmsi.py:226:17: F841 local variable 'file_source' is assigned to but never used
2018-03-03 21:36:37 +00:00
Jon Turney 2f6ed47077 Fix various flake8 indentation reports
$ flake8 | grep -E '(E123|E127|E128)'
./run_unittests.py:1358:37: E127 continuation line over-indented for visual indent
./run_unittests.py:1360:37: E127 continuation line over-indented for visual indent
./mesonbuild/minit.py:311:66: E128 continuation line under-indented for visual indent
./mesonbuild/minit.py:312:66: E128 continuation line under-indented for visual indent
./mesonbuild/minit.py:313:66: E128 continuation line under-indented for visual indent
./mesonbuild/compilers/cpp.py:115:63: E127 continuation line over-indented for visual indent
./msi/createmsi.py:156:13: E123 closing bracket does not match indentation of opening bracket's line
./msi/createmsi.py:188:13: E123 closing bracket does not match indentation of opening bracket's line
2018-03-03 21:35:53 +00:00