aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib
AgeCommit message (Collapse)AuthorFilesLines
2022-02-04mesonlib: Fix Popen_safe_legacy() stderr assumptionOle André Vadla RavnÄs1-1/+1
It may be None. This was encountered with radare's build system on Windows, where symbolextractor.py crashes without any output displayed.
2022-02-03Remove unnecessary check during VS activationNazar Mokrynskyi1-2/+0
2022-01-26Popen_safe and wrappers can accept os.PathLike for cwdEli Schwartz1-3/+3
Do not require users to convert it to a string first. This is a waste of time and effort for exactly the same results.
2022-01-16Add a test for the --vsenv meson setup optionNirbheek Chauhan1-9/+10
The tests and the unittests both unconditionally call setup_vsenv() because all tests are run using the backend commands directly: ninja, msbuild, etc. There's no way to undo this vs env setup, so the only way to test that --vsenv works is by: 1. Removing all paths in PATH that provide ninja 2. Changing setup_vsenv(force=True) to forcibly set-up a new vsenv when MESON_FORCE_VSENV_FOR_UNITTEST is set 3. Mock-patching build_command, test_command, install_command to use `meson` instead of `ninja` 4. Asserting that 'Activating VS' is in the output for all commands 5. Ensure that compilation works because ninja is picked up from the vs env. I manually checked that this test actually does fail when the previous commit is reverted.
2022-01-13Search for Visual Studio Express when activating VS envDFOVIT1-0/+4
Visual Studio Express does not come with the 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' workload. This adds a check for the 'Microsoft.VisualStudio.Workload.WDExpress' workload. Non-express versions take precedence over express versions when activating.
2022-01-10manually clean up some python 3.6 era codeEli Schwartz1-7/+3
2021-12-30correct type annotations for File.endswithEli Schwartz1-1/+1
It should accept whatever str.endswith accepts, which means optionally a tuple of options.
2021-12-30Fix mypy 0.930 issuesTristan Partin1-2/+2
Removed errant "type: ignore". Fixed issue with "fetch" call. This issue was the following: Dict::get() and Dict::pop() have the following signature: T.Callable[[_T, _U], _U | None] OR T.Callable[[_T], _U | None] Note how the return type is _U here. When the fetch() function was actually being called, it had the following signature: T.Callable[[_T, T.List[_U]], T.Union[T.List[_U], _U]] This is incompatible with the previous definitions. The solution is simply to move where the default value is introduced if fetch() produces None.
2021-12-22Don't wipe out RPATHs specified by dependenciesNirbheek Chauhan1-0/+4
Since we scan all dependencies for build-only RPATHs now (which are removed on install), we must take care not to add build-only RPATHs pointing to directories that dependencies explicitly add -Wl,-rpath link args for, otherwise the paths will get wiped on install. Caught by LinuxlikeTests::test_usage_pkgconfig_prefixes
2021-12-17Fix mypy errorsDaniel Mensinger1-3/+1
2021-12-15mesonlib: make get_meson_command return an ImmutableListDylan Baker1-2/+2
We really don't want to be mutating global state, so let mypy yell at us when we try.
2021-11-28Add typing to msubprojects.pyTristan Partin1-1/+1
2021-11-25mesonlib: update `OptionKey.__repr__`Dylan Baker1-1/+1
Which is missing several values
2021-11-09depfixer: convert unused printing code to debugging functionsZbigniew Jędrzejewski-Szmek1-0/+9
When installing with 'meson install --quiet' I'd get the following output: This file does not have an rpath. This file does not have a runpath. (It turns out that of the couple hundred of binaries that are installed, this message was generated for /usr/lib/systemd/boot/efi/linuxx64.elf.stub.) There doesn't seem to be any good reason for this output by default. But those functions can still be used for debugging. Under a debugger, returning the string is just as useful as printing it, but more flexible. So let's suppress printing of anything by default, but keep the extractor functions. The code was somewhat inconsistent wrt. to when .decode() was done. But it seems that we'll get can expect a decodable text string in all cases, so just call .decode() everywhere, because it's nicer to print decoded strings.
2021-11-01various manual conversion of percent-formatted strings to f-stringsEli Schwartz1-1/+1
2021-10-29Fix "meson compile" not activating vsenvXavier Claessens1-2/+3
setup_vsenv() was not propagating the return value, so build.need_vsenv was always False.
2021-10-27Fix crash when getting cuda optionsXavier Claessens1-14/+5
We could have an OptionOverrideProxy of an OptionOverrideProxy, recursively. This fix is a minimal subset of the refactoring I did in https://github.com/mesonbuild/meson/pull/9394. Instead of faking UserOption we can just do a shallow copy of one and set a new value on it. Fixes: #9448
2021-10-27remove public export of private functionEli Schwartz1-1/+0
2021-10-27fix various flake8 whitespace errorsEli Schwartz1-6/+6
2021-10-20Add support for win-arm64 to MSVCGabor Kertesz1-1/+5
For Windows on Arm win-arm64 platform, the corresponding vcvars is called now.
2021-10-19Fix NamedTemporaryFile file reopen issue on Win #9412Gabor Kertesz1-2/+4
NamedTemporaryFile can't be opened by name on Windows. For Windows the created temporary bat file is now closed before passing to a subprocess, prevented from removal automatically upon close and deleted explicitly upon finish.
2021-10-16Add missing but expected as exception clauseMatthew Brett1-1/+1
The `except` line was missing its `as e` clause. As a result, when erroring out, after not finding a compiler, Meson gives an error ending: ``` File "C:\Users\Matthew\AppData\Roaming\Python\Python39\site-packages\mesonbuild\mesonlib\vsenv.py", line 100, in setup_vsenv mlog.warning('Failed to activate VS environment:', str(e)) ```
2021-10-10Add --vsenv command line option and active VS only when neededXavier Claessens2-0/+101
2021-10-10Fix typos discovered by codespellChristian Clauss2-3/+3
2021-10-08python: Add platlibdir and purelibdir optionsXavier Claessens1-1/+1
2021-10-08Add support for module optionsXavier Claessens1-20/+30
2021-10-04mesonlib: ConfigurationData can also be a `Dict[str, Tuple[Str, Optional[str]]]`Dylan Baker1-2/+2
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