summaryrefslogtreecommitdiff
path: root/mesonbuild/backend
Commit message (Collapse)AuthorAgeFilesLines
* Metrowerks: move PCH args to the end of the command lineNomura2023-05-151-1/+7
|
* Fix paths of Fortran order dependenciesVolker Weißmann2023-05-131-4/+5
| | | | Fixes #11047
* Visual studio: Generate vcxproj.filters files to adds filters to imitated ↵Renan Lavarec2023-05-031-0/+62
| | | | directories to navigate more easily in the source files.
* extend install scripts to allow specific directory variable exportsEli Schwartz2023-05-021-2/+3
| | | | | | This is useful for internal scripts that want to know about something other than MESON_INSTALL_PREFIX and MESON_INSTALL_DESTDIR_PREFIX, which is very specific to the prefix.
* Don't use dyndep scanner when preprocessingVolker Weißmann2023-04-271-0/+2
| | | | Fixes #11504
* Initial support for Metrowerks C/C++ compilerNomura2023-04-241-1/+17
|
* rust: Add new `rust_dependency_map` target configurationSebastian Dröge2023-04-211-11/+9
| | | | | | This allows changing the crate name with which a library ends up being available inside the Rust code, similar to cargo's dependency renaming feature or `extern crate foo as bar` inside Rust code.
* intro: add more details to generated json filesCharles Brunet2023-04-201-18/+43
| | | | | | | | | | | | | | This will help with the writing of tools to generate VisualStudio project and solution files, and possibly for other IDEs as well. - Used compilers a about `host`, `build` and `target` machines arere listed in `intro-compilers.json` - Informations lister in `intro-machines.json` - `intro-dependencies.json` now includes internal dependencies, and relations between dependencies. - `intro-targets.json` now includes dependencies, `vs_module_defs`, `win_subsystem`, and linker parameters.
* rust: Also disallow `.` in Rust library target namesSebastian Dröge2023-04-201-2/+2
|
* rust: Don't use prefer-dynamic in case of proc-macro Rust dependenciesSebastian Dröge2023-04-191-2/+3
| | | | | They're only used at build-time and whether they exist or not should not have any effect on the final build artifact.
* rust: Use `isinstance(d, build.StaticLibrary)` instead of comparing the type ↵Sebastian Dröge2023-04-141-1/+1
| | | | name string
* rust: Link staticlib/cdylib link targets like link targets from any other ↵Sebastian Dröge2023-04-141-1/+4
| | | | | | | language staticlib/cdylib only provide a C ABI, i.e. contain no Rust metadata, and can be linked like a link target from any other language.
* rust: Don't prefer dynamic linking of Rust libraries for cdylibsSebastian Dröge2023-04-141-5/+9
| | | | | cdylibs provide a plain C ABI to its consumers and should not be treated like dylib/proc-macro shared libraries that provide a Rust ABI.
* rust: Convert dashes in crate names to underscoresSebastian Dröge2023-04-141-4/+14
| | | | | Dashes can't be used as identifiers in Rust and cargo is converting dashes in crate names to underscores for the same reason.
* backend/vs: Fix OpenMPSupportJosh Soref2023-04-111-2/+2
| | | | | | | | https://learn.microsoft.com/en-us/visualstudio/msbuild/cl-task?view=vs-2022 Found by https://www.check-spelling.dev/ Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
* fix various spelling issuesJosh Soref2023-04-112-14/+14
| | | | Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
* better algo to find DLL paths on WindowsCharles Brunet2023-04-111-6/+62
| | | | | | | | | | | Instead of using a hacky version of rpaths_for_non_system_absolute_shared_libraries, we use a custom adhoc function. The function filters out paths that do not contain dll files. It also finds paths from any kind of dependencies. This removes unneeded paths from the PATH env var, and adds paths that were missing otherwise.
* Revert "find dll path on Windows"Charles Brunet2023-04-111-34/+10
| | | | This reverts commit 3968b84696a9034233c2fd64ef7d8e078982afe3.
* Change "can not" to "cannot" throughout projectHiPhish2023-04-113-4/+4
| | | | | The word "cannot" expresses inability to do something whereas "can not" expresses the ability to refrain from doing something.
* backend/vs: ensure that build dir is preferred to src dirBarnabás Pőcze2023-03-301-1/+2
| | | | | | | | | | | | Previously, the VS backend would add the the include directories in the reverse order that the Ninja backend does it, which means that the source directories would be preferred over the build directories. For example, this would cause the compiler to choose the file from the source directory if a file with the same name is found in both. Fixes 57ec097b5 ("vs: Use CompilerArgs() for compile and link args") Fixes #11630
* Make --vsenv a readonly builtin optionXavier Claessens2023-03-291-1/+1
| | | | | | | | | 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
* backends: fix bug where meson_exe crashed if constructed with found programsEli Schwartz2023-03-281-1/+1
| | | | | | | | | | | | | | | | | | | Because we base the pickled data name on the name property of the command being run... and for built targets, `exe.name` is always just the name. However, for an ExternalProgram this is just whatever string we searched for, so, NOT just the basename. This became a bigger issue once we started using generator() with the actual program in commit 6aeec808367f05463394e30a8d40834e97c7afc0, rather than first casting it to a string, because the VS backend *always* uses the meson_exe approach for various reasons related to VS being VS. Outside of that, it's difficult to actually get an ExternalProgram object passed to meson_exe -- CustomTarget lowers it to a string, capture is handled via argparse instead of pickling, etc. Fixes #11593
* Add support for meson.options as a replacement for meson_options.txtDylan Baker2023-03-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | We will still try to load `meson_options.txt` if `meson.options` doesn't exist. Because there are some advantages to using `meson.options` even with older versions of meson (such as better text editor handling) we will not warn about the existence of a `meson.options` file if a `meson_options.txt` file or symlink also exists. The name `meson.options` was picked instead of alternative proposals, such as `meson_options.build` for a couple of reasons: 1. meson.options is shorter 2. While the syntax is the same, only the `option()` function may be called in meson.options, while, it may not be called in meson.build 3. While the two files share a syntax and elementary types (strings, arrays, etc), they have different purposes: `meson.build` declares build targets, `meson.options` declares options. This is similar to the difference between C's `.c` and `.h` extensions. As an implementation detail `Interpreter.option_file` has been removed, as it is used exactly once, in the `project()` call to read the options, and we can just calculate it there and not store it. Fixes: #11176
* find dll path on WindowsCharles Brunet2023-03-271-10/+34
| | | | | | | | | | | | | | | | | | | | When running tests on Windows (or for devenv), paths of shared libraries need to be added to the PATH envvar for Windows to be able to find them. Meson is currently using the path of the import lib, which is wrong in many cases. This fix does two things: if there is a variable bindir in the pkg-config file, those variable values are added to the list of path. This is for conan dependencies, if conan decides to export those paths. See https://github.com/conan-io/conan/issues/13532 . The fallback is to replace `lib` by `bin` in the import library path. This heuristic will work most of the time (but the bin directory could have a different name, or the dll itself could have a different name). In all cases, it cannot be worse than current implementation, and it solves many cases.
* backends: add a new "none" backendEli Schwartz2023-03-202-0/+34
| | | | | | | | | | | It can only be used for projects that don't have any rules at all, i.e. they are purely using Meson to: - configure files - run (script?) tests - install files that exist by the end of the setup stage This can be useful e.g. for Meson itself, a pure python project.
* backends: simplify class setupEli Schwartz2023-03-209-9/+25
|
* Add restat = 1 to the fortran_COMPILER ruleVolker Weißmann2023-03-201-1/+4
| | | | | | gfortran does not update the modification time of *.mod files. Fixes #11552
* rust: Fix handling of proc-macros in rust-project.jsonSebastian Dröge2023-03-011-7/+9
| | | | | | The proc-macro code was not running at all because of a missing dash in the crate type, and the proc macro dylib path was not generated as a path but including the `-o ` commandline parameter prefix.
* rust: Store absolute paths in rust-project.jsonSebastian Dröge2023-03-011-2/+6
| | | | | | | | | | | | | | | | | | | As meson requires source_dir!=build_dir and stores the rust-project.json inside the build directory, while software like rust-analyzer expects it at the root of the source directory, manual steps are needed for making them work together. One option, as described in the documentation, is per project configuration. Another option, that works correctly with compile-commands.json and clangd, is to store a symlink to the file in the build directory at the root of the source directory. As currently rust-project.json stores paths relative to the location of the file itself and rust-analyzer does not resolve symlinks, this does not work. To solve this, store absolute paths in rust-project.json as is already done in compile_commands.json for the directory.
* backends: fix source dir stripping from rpathsStefan Hajnoczi2023-03-011-2/+9
| | | | | | | | | | | | | | | | | | | | | Commit e88887be4a08 ("Only remove substring if it is part of string") removed the source dir from the rpath when the following check succeeds: if absdir.startswith(self.environment.get_source_dir()): rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] For example, absdir '/myproject/foo' starts with source dir '/myproject', so we want to generate the relative path 'foo'. This code doesn't work with absdir '/myproject-libs/foo' though, because we'll incorrectly turn it into a relative path 'libs/foo' after stripping away '/myproject-'. Use os.path.commonpath() instead of str.startswith() so path components are correctly handled. Cc: Niklas Claesson <niklas.claesson@cosylab.com> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
* Implement rustc controlled whole-archive linkingDylan Baker2023-02-221-1/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rustc as of version 1.61.0 has support for controlling when whole-archive linking takes place, previous to this it tried to make a good guess about what you wanted, which worked most of the time. This is now implemented. Additionally, rustc makes some assumptions about library names (specifically static names), that meson does not keep. This can be fixed with rustc 1.67, where a new +verbatim modifier has been added. We can then force rustc to use the name we give it. Before that, we can sneak through `/WHOELARCHIVE:` in cases of dynamic linking (into a dll or exe), but we can't force the archiver to do what we want (rustc considers the archiver to be an implementation detail). The only solution I can come up with is to copy the library to the format that rustc expects. I've run into some issues with that as well, so we warn in that case. The decisions to leave static into static broken on MSVC for 1.61–1.66 was made because: 1) The work around is non-trivial, and we would have to support that workaround for a long time 2) The number of users of Rust in Meson is small 3) The number of users of Rust in Meson on Windows, with MSVC is tiny 4) Using rustup to update rustc on windows is trivial, and solves the problem completely Fixes: #10723 Fixes: #11247 Co-authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
* backend/ninja: fix rust cfg parsingKarol Herbst2023-02-211-1/+1
|
* cython: wire up support for emitting and using depfilesEli Schwartz2023-02-101-1/+5
| | | | | | | | | | | This solves rebuild issues when e.g. importing a .pxd header from a .pyx file, just like C/C++ source headers. The transpiler needs to run again in this case. This functionality is present in the 3.0.0 alphas of cython, and is also backported to 0.29.33. Fixes #9049
* backends: handle cython ninja rules a bit more idiomaticallyEli Schwartz2023-02-101-6/+7
| | | | | | We want to use as much default ninja behavior as we can, so reuse $out instead of repeating the output file as a string in $ARGS, and raise that into the build rule so it is only listed once.
* pylint 2.16: remove pointless parens around equality assignmentsEli Schwartz2023-02-011-1/+1
| | | | | | | | | Given the construct `foo = (bar == baz)` some people like parentheses and some do not. They're pointless and don't mean anything, though. I don't feel this is particularly helpful to code clarity, tbh, and pylint now notices this and warns about it in our current pylint config. I think this is reasonable, so let's remove the odd parens.
* simplify instantiation of builtin type using builtins instead of functionsEli Schwartz2023-02-011-1/+1
|
* BUG: Fix generated sources not being included as dependencies in cython ↵Thomas Li2023-01-151-0/+14
| | | | transpilation
* backends: Stop passing generator exes to ExecutableSerialisation as stringsDylan Baker2023-01-103-7/+6
| | | | | | | | | | | | | | | | The code below this already handles being passed an Executable or ExternalProgram, and it does it correctly, since it handles host binaries that need an exe_wrapper correctly, while the code in the generator paths doesn't. The xcode backend is, like always, problematic, it doesn't handle things the same way as the ninja and vscode backends, and generates a shell script instead of using meson as a wrapper when needed (it seems likely that just forcing the meson path for xcode would be better). I don't have a working mac to develop a fix for, so I've left a todo comment there. Fixes: #11264
* avoid detecting masm as a MSVC-like compiler for detecting showincludesEli Schwartz2023-01-081-2/+2
| | | | | It's msvc-like but, just like Intel Fortran, doesn't support this argument.
* msvc: handle filename extensions for incdetect based on the compiler languageEli Schwartz2023-01-081-2/+3
| | | | | | | | | | | | | | | It is possible, albeit possibly inadvisable, for the exact combination of MSVC and "$CXX has C++ specific flags in it" to occur. When this happens, and cl.exe is given a filename ending in .c, it complains that you cannot compile a .c file with that option. Instead, pick the first filename matching that language and use that as the temporary filename. This more or less matches what we do in compiler-time checks. And it's the proper thing to do, rather than assume that cl.exe, when detected as the current C++ compiler, can *also* compile C because it's *also* a C compiler. Fixes #11257
* backends/backends: Add helpful message for getting rid of warningDylan Baker2023-01-031-1/+1
|
* add builtin option to install licensesEli Schwartz2022-12-271-6/+12
| | | | | Unless `meson.install_dependency_manifest()` is explicitly used, this will cause a default implied one to be installed.
* add license_files kwarg to projectEli Schwartz2022-12-271-0/+8
| | | | | | Hook this up to installed dependency manifests. This is often needed above and beyond just an SPDX string -- e.g. many licenses have custom copyright lines.
* Remove useless EmptyExternalProgramXavier Claessens2022-12-071-4/+1
| | | | | | It is only used by Environment.get_exe_wrapper() and every callers were handling None already. Type annotation was wrong, it already could return None for the case an exe wrapper is needed but none is provided.
* devenv: Always include env for HOST machineXavier Claessens2022-12-071-3/+1
| | | | | | | Cross compiled executables could still be run with an exe wrapper, or with proper binfmt installed. Fixes: #10999
* devenv: Add executables locations to both PATH and WINEPATHXavier Claessens2022-12-071-7/+12
| | | | | Handles the case when wine-binfmt is installed, which makes .exe files executable without without specifying an exe wrapper.
* when generating optional utility targets in ninja, skip existing aliases tooEli Schwartz2022-12-051-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | When auto-generating e.g. a `clang-format` target, we first check to see if the user has already defined one, and if so we don't bother creating our own. We check for two things: - if a ninja target already exists, skip - if a run_target was defined, skip The second check is *obviously* a duplicate of the first check. But the first check never actually worked, because all_outputs was only generated *after* generating all utility rules and actually writing out the build.ninja file. The check itself compares against nothing, and always evaluates to false no matter what. Fix this by reordering the target creation logic so we track outputs immediately, but only error about them later. Now, we no longer need to special-case run_target at all, so we can drop that whole logic from build.py and interpreter.py, and simplify the tracked state. Fixes defining an `alias_target()` for a utility, which tried to auto-generate another rule and errored out. Also fixes doing the same thing with a `custom_target()` although I cannot imagine why anyone would want to produce an output file named `clang-format` (unless clang itself decided to migrate to Meson, which would be cool but feels unlikely).
* pylint: enable the set_membership pluginDylan Baker2022-11-302-3/+3
| | | | | | | | | | | | 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 :)
* tests: Write out LD_LIBRARY_PATH for built shared librariesDaniel Stone2022-11-301-1/+14
| | | | | | | | | | | | | | | | When a test executable references a local shared library, make sure that we apply the appropriate $LD_LIBRARY_PATH so that the linker can find it at runtime. The DT_RUNPATH entry does ensure that the binary references the path to the shared library build, however the RUNPATH list is only searched after $LD_LIBRARY_PATH. So if the user has a shared library of the same name in their $LD_LIBRARY_PATH, this will be the version found and used for running the test. This is bad if you're trying to use Meson to test a shared library you're developing and have installed in a local prefix which is under $LD_LIBRARY_PATH. Fixes #1635
* pylint: enable the bad_builtin checkerDylan Baker2022-11-292-3/+3
| | | | | | | | | | | | | | 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