aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
AgeCommit message (Collapse)AuthorFilesLines
2022-09-19fix odd mypy issue in unreachable codeEli Schwartz1-0/+1
This used to be fine, until imports were removed from this file. Now a function annotated as T.NoReturn doesn't actually tell mypy that it cannot return, though, so we manually do it.
2022-09-19simplify type annotationEli Schwartz1-1/+1
2022-09-19compilers: avoid importing compilers upfront for detectEli Schwartz1-114/+2
We no longer need these upfront at all, since we now import the ones we need for the language we are detecting, at the time of actual detection. This avoids importing 28 files, consisting of just under 9,000 lines of code, at interpreter startup. Now, it is only imported depending on which languages are invoked by add_languages, which may not even be anything. And even if we do end up importing a fair chunk of it for C/C++ projects, spreading the import cost around the interpreter runtime helps responsiveness.
2022-09-19compilers: perform targeted imports for detectEli Schwartz4-90/+107
Only import the ones we need for the language we are detecting, once we actually detect that language. This will allow finally dropping the main imports of these files in a followup commit.
2022-09-19compilers: use more direct checks for what kind of compiler we haveEli Schwartz1-7/+7
Instead of comparing against specific compiler classes, check the logical compiler id or language etc. In a couple cases, we seem to be missing a couple things by being a bit too strict about the exact class type.
2022-09-19compilers/detect: rename potentially conflicting nameEli Schwartz1-12/+12
Preparation for future commit.
2022-09-19compilers: use consistent function signature for objcEli Schwartz1-7/+7
e.g. for detect_c_or_cpp we just take the language itself as an argument.
2022-09-19compilers: remove dead codeEli Schwartz1-1/+1
It doesn't matter whether the language is c or cpp, xc16 only has a C compiler so that's what this has to be.
2022-09-19compilers: single-source compiler class as cls, consistentlyEli Schwartz1-18/+26
It's the style for most, but not all, of this file.
2022-09-19avoid importing the entire codebase at first startupEli Schwartz2-7/+12
We want to optimize out some internal codepaths used at build time by avoiding work such as argparse. This doesn't work particularly well when the argparse arguments are imported before then. Between them, they indirectly import pretty much all code anywhere, and msetup alone imports most of it. Also make sure the regenerate internal script goes directly to msetup.
2022-09-19compilers: don't export every compiler as a top-level propertyEli Schwartz1-161/+0
This is wasteful and generally unneeded, since code can just use the compiler they detected instead of manually poking at the internals of this subpackage. It also avoids importing an absolute ton of code the instant one runs `from . import compilers`
2022-09-19compilers: directly import from subpackagesEli Schwartz4-8/+9
It turns out we don't generally need to proxy every compiler ever through the top-level package. The number of times we directly poke at one is negligible and direct imports are pretty clean.
2022-09-19compilers: don't use instance checks to determine propertiesEli Schwartz3-20/+15
In various situations we want to figure out what type of compiler we have, because we want to know stuff like "is it the pgi one", or "does it use msvc style". The compiler object has this property already, via an API specifically designed to communicate this info, but instead we performed isinstance checks on a compiler class. This is confusing and indirect, and has the side effect of requiring more imports everywhere. We should do away with it.
2022-09-19declare_dependency: fix regression in printing the correct errorEli Schwartz1-1/+1
In commit 47426f3663f795ae9af59075297bf8215ae81f40 we migrated to typed_kwargs, but the validator accepted a list and checked to see if it was a single Dependency object. Fixes #10813
2022-09-18Warn if wrap file changesDaniel Carson2-6/+45
Save off the hash of the wrap file when first configuring a subproject. When reconfiguring a subproject, check the hash of the wrap file against the stored hash. If they don't match then warn the user.
2022-09-18Move up dangling commentDaniel Carson1-1/+1
The comment and some settings that appear to be related to the comment were introduced in f21685a83330a4bbe1e59c3641a0d24f1efe8825 and appears to be documenting some of the fields added in that commit. This commit moves the comment back to the field it appears to be documenting.
2022-09-18gnome: Add some missing install_tagXavier Claessens1-0/+6
2022-09-15devenv: Resolve executable in devenv's PATHXavier Claessens1-0/+4
Fixes: #10815
2022-09-13Use os.path.realpath for default include paths testing in -isystem.Yang Bo1-3/+4
This ensures correct removal of default include paths in -isystem options when symbolic links are involved. A test for this is also added.
2022-09-12dependencies: log the real reason for a dependency lookup failingEli Schwartz2-3/+6
In the debug logs, always log if a dependency lookup raises a DependencyException. In the `required: false` case, this information would otherwise disappear forever, and we would just not even log that we tried it -- it doesn't appear in "(tried x, y and z)". In the `required: true` case, we would re-raise the first exception if it failed to be detected. Update the raise message with the same information we print to the debug logs, indicating which dependency and which method was used in the failing attempt.
2022-09-12dependencies: use better internal representation of factory methodsEli Schwartz2-8/+7
functools.partial preserves information about how the method was created, lambdas do not. Also, we just want to freeze the first argument and forward the rest anyway. This also lets us get rid of a mypy error that was being ignored.
2022-09-12dependencies: simplify log_tried into a staticmethodEli Schwartz7-12/+21
It doesn't really need class instantiation to just know what type it is, and this way we can get the information early if a dependency fails to init.
2022-09-12dependencies: simplify logging methodsEli Schwartz3-15/+0
A bunch of SystemDependency subclasses overrode log_tried() even though they used the same function anyway. Delete them -- they still print the same thing either way.
2022-09-12rust: Generate a rust-project.json file when rust targets are presentDylan Baker1-1/+111
When at least one Rust target is present, we now generate a rust-project.json file, which can be consumed by rust-analyzer. This is placed in the build directory, and the editor must be configured to look for this (as it is not a default search path).
2022-09-12mesonlib: Add a function to find the first element in an iterable which ↵Dylan Baker1-0/+15
matches a predicate
2022-09-12arglist: use typing.MutableSequence instead of collectionsDylan Baker1-1/+1
In the long run collections is the right thing to use, but until we can require 3.9.x as the minimum we cannot annotate the collections.abc version, only the typing version. This allows correct type annotations in users of `CompilerArgs`, as mypy (and friends) can determine that `CompilerArgs` is ~= `T.Sequence[str]`
2022-09-12mcompile: Remove useless sleepXavier Claessens1-2/+0
There is no reason to wait 2s before starting the compilation command. Fixes: #10698.
2022-09-12modules: Fix paths to (sub)project source/build directoriesDavid Ward2-5/+4
The subproject directory name (i.e. 'subprojects') was being added to the path even for the main project.
2022-09-12i18n: Fix source root in Gettext targets for subprojectsDavid Ward2-6/+10
Gettext should search for input files relative to the (sub)project source root, not the global source root. This change exposes a root_subdir member in ModuleState.
2022-09-11backends: limit maximum path of generated filenamesEli Schwartz1-1/+9
When calculating the output filename for a compiled object, we sanitize the whole input path, more or less. In cases where the input path is very long, this can overflow the max length of an individual filename component. At the same time, we do want unique names so people can recognize what these outputs actually are. Compromise: - for filepaths with >5 components (which are a lot more likely to cause problems, and simultanously less likely to have crucial information that far back in the filepath) - if an sha1 hash of the full path, replacing all *but* those last 5 components, produces a path that is *shorter* than the original path ... then use that modified path canonicalization via a hash. Due to the use of hashes, it's unique enough to guarantee correct builds. Because we keep the last 5 components intact, it's easy to tell what the output file is compiled from. Fixes building in ecosystems such as spack, where the build environment is a very long path containing repetitions of `__spack_path_placeholder__/` for... reasons of making the path long.
2022-09-09vs: Fix CustomBuild contents.Andres Freund1-9/+9
%% survived into the output since 038b31e72bc02f0a9b. That failed to fail, at least in the common cases, because the whole command sequence is unnecessary / redundant - it appears to come from cmake, which executes multiple commands within a single CustomBuild element.
2022-09-09compilers: drop some useless info from CompileResultEli Schwartz1-5/+2
text_mode was never set, nor used, and pid was set but never used.
2022-09-09compilers: fix regression in logging cached compile commandsEli Schwartz1-4/+3
In commit d326c87fe22507b8c25078a7cd7ed88499ba7dc1 we added a special holder object for cached compilation results, with some broken attributes: - "command", that was never set, but used to print the log - "args", that was set to some, but not all, of the information a fresh compilation would log, but never used Remove the useless args attribute, call it command, and use it properly.
2022-09-07compilers: correct the MSVC version comparison for turning on __cplusplusEli Schwartz1-1/+1
We compared a Visual Studio (the IDE) version, but we wanted a MSVC (the compiler) version. This caused the option to be passed for a few too many versions of MSVC, and emit a "D9002 : ignoring unknown option" on those systems. Compare the correct version using the version mapping from https://walbourn.github.io/vs-2017-15-7-update/ Fixes #10787 Co-authored-by: CorrodedCoder <38778644+CorrodedCoder@users.noreply.github.com>
2022-09-07wrap: correctly override dependency names with capital lettersEli Schwartz1-3/+5
When we do wrap resolution, we do a case-insensitive lookup because keys, i.e. `dep_name = variable_name`, are case insensitive. In order to check whether we should process a subproject, we need to know if the lowercased dependency name matches. We do this by looking up the lowercase name, and assuming that the stored name is also lowercase. But for dependency_names, this isn't "case insensitive and stored in lowercase" so we need to manually force it to be consistent. Likewise, when looking up the wrap name (which works like dependency_names and doesn't need a provide section at all) the disk filename of the wrap file is case sensitive, but needs to be manually forced for consistency.
2022-09-07Fixed string escaping in AstPrinterVolker Weißmann1-1/+5
2022-09-07minstall: handle extra error for selinuxenabledRosen Penev1-1/+1
Microsoft's WSL2 uses a Plan 9 filesystem, which returns IOError when file is missing.
2022-09-07modules/wayland: Change default value of include_core_only to trueMark Bolhuis1-1/+1
The use of wayland-<client|server>.h is discouraged, therefore change the default value of include_core_only to true.
2022-09-07modules/wayland: Rename core_only to include_core_onlyMark Bolhuis1-3/+3
Rename the core_only option in scan_xml to include_core_only to match the flag used by wayland-scanner.
2022-09-06modules/wayland: Support --include-core-onlyMark Bolhuis1-1/+7
wayland-scanner can generate header files that only include wayland-client-core.h using a flag. Add a core_only option to scan_xml to support this use case.
2022-09-06Fix install_subdirs not showing up in intro-install_plan.jsonThomas Li5-2/+13
2022-09-05interpreter: name typing-only kwargs import with an underscoreEli Schwartz1-41/+41
To differentiate it from the function parameter itself. Annotating a function as ``` def func_foo(kwargs: kwargs.FooKwargs): ``` is confusing, both visually and to static linters.
2022-09-05interpreter: add a few small func annotationsEli Schwartz1-4/+4
2022-09-04mtest: Run ninja build.ninja before loading testsAndres Freund1-0/+10
When the build definition has changed since the last ninja invocation meson test operated on an outdated list of tests and their dependencies. That could lead to some tests not being run / not all dependencies being built. This was particularly confusing because the user would see the output of reconfiguration and rebuilding, and the next mtest invocation would have the updated configuration. One issue with this is that that we will now output more useless ninja output when nothing needs to be done (the "Entering directory" part is not repeated, as we happen to be in the build directory already). It likely is worth removing that output, perhaps by testing if anything needs to be done with ninja -n, but that seems better addressed separately. Fixes: #9852
2022-09-04mtest: pull detection of ninja into TestHarnessAndres Freund1-10/+24
A later commit will add a second invocation of ninja, no point in having the detection code twice. This changes the exit code in case ninja isn't found from 125 to 127, which seems more appropriate given the justification for returning 125 (to make git bisect run skip that commit). If we can't find ninja we'll not succeed in other commits either.
2022-09-04mtest: Move loading of test data into its own functionAndres Freund1-10/+13
A subsequent commit will do a bit more during test data loading, making a dedicated function seem advisable. The diff looks a bit odd, using git show --diff-algorithm=patience will make it clearer.
2022-09-02backend/ninja: omit --backend when regenerating build dirKonstantin Kharlamov1-3/+1
Currently a cosmetic bug is present: once a build dir was regenerated, meson would start showing: User defined options backend: ninja This is not true as user have not defined the option, it is default. Fix this by omitting the `--backend ninja` parameter from "regenerate" In my tests this does not affect the situation when one specifies `--backend ninja` explicitly, it still shows the backend as user-defined after reconfiguration. Fixes: https://github.com/mesonbuild/meson/issues/10632
2022-08-31Fix 2 typos in a single string which can be shown in error messages.Jehan1-1/+1
2022-09-01env2mfile: reuse logical lists of interesting facts from meson itselfEli Schwartz3-46/+19
Meson internally knows about many languages and tools, and *FLAGS variables, and which languages to use them for. Instead of duplicating this logic, import it from mesonbuild.* This logic was originally standalone, but now that it is merged into the Meson tree we can have a single source of truth.
2022-08-31modules/cmake: Fix typoaleksander1-1/+1