aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib
AgeCommit message (Collapse)AuthorFilesLines
2021-10-04condense linesEli Schwartz1-2/+1
2021-10-04f-stringsEli Schwartz1-2/+2
2021-10-04fix extra whitespaceEli Schwartz1-2/+0
discovered via flake8 --select E303
2021-09-07interpreter: detect and pass compiler to be used for linker testsPaolo Bonzini1-0/+4
Allow using the links method to test that the C++ driver (e.g. g++) can be used to link C objects. One usecase is that the C compiler's libsanitizer might not be compatible with the one included by the C++ driver. This is theoretically backwards-incompatible, but it should be treated as a bugfix in my opinion. There is no way in Meson to compile a .c file with the C++ driver as part of a build target, therefore there would be no reason to do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')). Fixes: #7703
2021-09-03Improve WSL detectionWill1-1/+1
WSL 2 removes the "Microsoft" from `platform.version` but leaves it inside `platform.release`. This lets us detect both types of WSL without issue.
2021-09-02OptionKey: Fix orderingXavier Claessens1-10/+8
When sorting options we want the same order as they are presented in "meson configure" command.
2021-08-31interpreter: use python dunders instead of lock for unpicklabilityDylan Baker1-7/+0
This simplifies things for us, as we don't have to have threading imported for no other reason, and we can remove the `an_unpicklable_object` from the Interpreter and mesonlib, since there was only one user of this.
2021-08-31pylint: turn on superflous-parensDylan Baker1-1/+1
We have a lot of these. Some of them are harmless, if unidiomatic, such as `if (condition)`, others are potentially dangerous `assert(...)`, as `assert(condtion)` works as expected, but `assert(condition, message)` will result in an assertion that never triggers, as what you're actually asserting is `bool(tuple[2])`, which will always be true.
2021-08-22Add subscript to subprocess.PopenTristan Partin1-2/+2
2021-08-20mesonlib: Fix typing of substitute_valuesDylan Baker1-5/+27
This is really, really, annoying. What we really want is (psuedocode): ```python class SubValues(TypedDict[str, str], total=False): @INPUT@: T.List[str] @OUTPUT@: T.List[str] ``` Which would specifiy that `@INPUT@` and `@OUTPUT@` *may* be present and if they are, then they are lists. There may be additional keys, which have a single string as a value. Of course there is currently no way to do that with typing, so we have to instead take a union type and then use asserts to help the type checker unerstand this. More info: https://github.com/python/mypy/issues/4617
2021-08-20mesonlib: Add an exception for what should be unreachable codeDylan Baker1-0/+2
It gives us a little more saftey, and makes pylance happy.
2021-08-20mesonlib: Fix type annotationsDylan Baker1-5/+4
get_compiler_for_source and classify_unity_sources are both wrong, in that they expect to be given a seqence of strings, but they really should take a `Sequence[str | File]`. Additionally, they're using `CompilerType`, which we don't need anymore, and should stop using, most methods for the Compiler are actually defined in the base compiler class.
2021-07-07resolve symlinks passed to -CPaolo Bonzini1-0/+13
"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-05condense linesEli Schwartz1-6/+3
2021-07-05more f-strings too complex to be caught by pyupgradeEli Schwartz1-17/+17
2021-06-29fix: Always explicitly set encoding for text files (fixes #8263)Daniel Mensinger3-5/+5
2021-06-26refactor: Refactor BothLibraries logicDaniel Mensinger1-0/+9
This commit introduces a new type of `HoldableObject`: The `SecondLevelHolder`. The primary purpose of this class is to handle cases where two (or more) `HoldableObject`s are stored at the same time (with one default object). The best (and currently only) example here is the `BothLibraries` class.
2021-06-25Split compiler detection from EnvironmentDaniel Mensinger1-0/+44
This moves all the compiler detection logic into the new compilers.detect module. This dramatically reduces the size and complexity of Environment.
2021-06-22mesonlib: add rsplit and and maxsplitDylan Baker1-2/+5
Since string has a maxsplit as well, we should implement that for polymorphism
2021-06-22mesonlib: Fix FileMode type annotationsDylan Baker1-2/+2
2021-06-18holders: remove unholderDaniel Mensinger1-21/+0
2021-06-18holders: Introduce HoldableObjectDaniel Mensinger1-1/+7
2021-06-18mesonlib: Add MesonBugExceptionDaniel Mensinger1-0/+9
2021-06-05typing: Fully annotate dependencies.cudaDaniel Mensinger1-1/+1
2021-06-02use an immutable list for an lru_cached functionsDylan Baker1-1/+2
When mutable items are stored in an lru cache, changing the returned items changes the cached items as well. Therefore we want to ensure that we're not mutating them. Using the ImmutableListProtocol allows mypy to find mutations and reject them. This doesn't solve the problem of mutable values inside the values, so you could have to do things like: ```python ImmutableListProtocol[ImmutableListProtocol[str]] ``` or equally hacky. It can also be used for input types and acts a bit like C's const: ```python def foo(arg: ImmutableListProtocol[str]) -> T.List[str]: arg[1] = 'foo' # works while running, but mypy errors ```
2021-05-28Add a helper to simplify the usage of PerMachineDefaultableDylan Baker1-0/+15
2021-05-28mesonlib: Allow PerMachineDefaultable to take arguments at initializationDylan Baker1-2/+2
2021-05-28mesonlib: Fix return type of PerMachineDefaultable.default_missing()Dylan Baker1-1/+1
2021-05-19.C files are now treated as C++ codeVolker-Weissmann1-4/+6
2021-05-03Clarify incorrect configuration format messageNellie Zhang1-3/+3
Print the path and line where the problem occurred to make it more clear what the error message means.
2021-03-26windows_proof_rmtree: Also retry os.chmod() partXavier Claessens1-2/+9
It looks like when Windows media scanner holds files we can't change their permission neither.
2021-03-16Update VS module version check.Jussi Pakkanen1-0/+6
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz1-21/+21
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-03Windows Subsystem for Linux can run .exe without mono interpreterXavier Claessens1-0/+3
Fixes: #8445
2021-02-18allow build.b_* optionsDylan Baker1-2/+1
These continue to be ignored as they always have, but no longer raise an error. Fixes: #8354
2021-02-17Environment: Fix passing envrionment variables CPPFLAGS and CFLAGSDylan Baker1-1/+0
Or other language flags that use CPPFLAGS (like CXXFLAGS). The problem here is actually rather simple, `dict.setdefault()` doesn't work like I thought it did, I thought it created a weak entry, but it actually is equivalent to: ```python if k not in dict: dict[k] = v ``` Instead we'll use an intermediate dictionary (a default dictionary actually, since that makes things a little cleaner) and then add the keys from that dict to self.options as applicable. Test case written by Jussi, Fix by Dylan Co-authored-by: Jussi Pakkanen Fixes: #8361 Fixes: #8345
2021-02-06mesonlib: Add better errormessage to typelistifyDylan Baker1-2/+2
2021-01-29Popen_safe: Fix stdout/stderr annotationXavier Claessens1-4/+4
2021-01-26Warn about .C and .H files (#8249)Volker-Weissmann1-0/+7
2021-01-23split mesonlib into a packageDylan Baker5-0/+2236
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.