aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/ninjabackend.py
AgeCommit message (Collapse)AuthorFilesLines
2022-04-14Fix typo in commentBen Brown1-1/+1
2022-03-31allow RunTarget to skip wrapping due to envEli Schwartz1-3/+4
Forcing serialization on when writing out the build rule makes very little sense. It was always "forced" on because we mandated a couple of environment variables due to legacy reasons. Add an attribute to RunTarget to say that a given target doesn't *need* those environment variables, and let ninja optimize them away and run the command directly if set.
2022-03-29Replace backend.get_option_for_target() with target.get_option()Xavier Claessens1-20/+18
That method had nothing specific to the backend, it's purely a Target method. This allows to cache the OptionOverrideProxy object on the Target instance instead of creating a new one for each option lookup.
2022-03-23Add support for cython_argsTristan Partin1-0/+1
cython_args was previoously ignored by Meson.
2022-03-23ninja backend: do not fatally error on compdb failureEli Schwartz1-1/+1
We print a warning if a compilation database isn't successfully generated, which is good, because that gives some visibility in case the user really wanted to use the compdb. But warnings default to being fatal with --fatal-meson-warnings, which is not so good, because this isn't a very important warning at all, and we'd rather not error out in such cases when building works fine and a random bonus IDE feature doesn't work. Mark this particular warning as non-fatal. Fixes side issue in https://github.com/mesonbuild/wrapdb/pull/343#issuecomment-1074545609
2022-03-22backends: Stop separating base and compiler optionsXavier Claessens1-6/+6
Since OptionKey is used we can mix all options together in a single dictionary. That's already what we do in coredata.options.
2022-03-22Add ability to add resources to jarsTristan Partin1-5/+9
Previously Meson lacked the ability to add resources to jar files. Fixes #9945
2022-03-21ninja: fix handling of rust structured_sources in rare caseDylan Baker1-4/+11
In the even that all of the inputs are generated, and they're all generated into the same folder, and there are no subfolders, we would fail to correctly handle all of the files after the main file. Let's fix that.t
2022-03-18structured_sources: fix subdir handlingDylan Baker1-6/+2
We currently don't handle subdirectories correctly in structured_sources, which is problematic. To make this easier to handle correctly, I've simply changed `structured_sources` to only use Files and not strings as an implementation detail.
2022-03-07backends/ninja: Add support for structured sources with rustDylan Baker1-0/+43
2022-03-07backend/ninja: add rules to copy files to the build dirDylan Baker1-0/+12
2022-03-07Fix default install tag for shared lib symlinksXavier Claessens1-2/+1
Versioned shared libraries should have .so file in devel, .so.1 and .so.1.2.3 in runtime. Fixes: #9811
2022-02-14shared module: Allow linking on AndroidNirbheek Chauhan1-1/+1
Android requires shared modules that use symbols from other shared modules to be linked before they can be dlopen()ed in the correct order. Not doing so leads to a missing symbol error: https://github.com/android/ndk/issues/201 We need to always allow linking for this. Also add a soname, although it's not confirmed that it's needed, and it doesn't really hurt if it isn't needed.
2022-02-10ninjabackend: fix rust program names with dashesAlyssa Ross1-1/+2
This substitution matches the behaviour of rustc[1] when inferring crate name based on file name. [1]: https://github.com/rust-lang/rust/tree/4e8fb743ccbec27344b2dd42de7057f41d4ebfdd/compiler/rustc_session/src/output.rs#L88
2022-02-02ninjabackend: treat link_whole_targets like link_targets for Rust targetsZach Reizner1-2/+5
For static library crates that depend on other internal static library crates, all link_with targets get promoted to link_whole targets. Due to a bug, only link_with targets are considered when generating a Rust target for the ninja backend. This made it impossible to link a Rust static library with another internal Rust static library. This change fixes that issue by chaining link_whole_targets with link_targets, just like many other languages within the ninja backend.
2022-02-01backends/ninja: generate symlink aliases for rust/cs/swift libraries tooEli Schwartz1-1/+3
Basically the last thing we did during target processing was to generate shlib symlinks for e.g. libfoo.so -> libfoo.so.1. In some cases we would dispatch to another function and return early, though, which meant we never got far enough to generate the symlinks. This then led to breakage when people tried to compile against libfoo.so This surely breaks -uninstalled.pc usage, and also caused problems in https://github.com/rust-lang/rust/pull/90260
2022-01-12ninja backend: Fix custom_target() console: kwarg when using envDeclan Qian1-1/+2
When a custom_target() uses an env, meson uses a wrapper script to run the executable. This breaks the console: kwarg because the wrapper script buffers the output. Fix it by setting the verbose flag which will not buffer output.
2021-11-24shared_module: Add soname when used as a link targetNirbheek Chauhan1-1/+1
Emit a detailed deprecation warning that explains what to do instead. Also add a unittest. ``` DEPRECATION: target prog links against shared module mymod, which is incorrect. This will be an error in the future, so please use shared_library() for mymod instead. If shared_module() was used for mymod because it has references to undefined symbols, use shared_libary() with `override_options: ['b_lundef=false']` instead. ``` Fixes https://github.com/mesonbuild/meson/issues/9492
2021-11-15valac dependencies: use the canonical list of vala source namesEli Schwartz1-1/+1
Don't hardcode one of the three possible source types, thus ignoring the needed vapis for dependencies using .gs or .vapi sources. Fixes #9544
2021-11-01various manual conversion of percent-formatted strings to f-stringsEli Schwartz1-1/+1
2021-11-01coverage generator: obey the documentation and only generate supported outputsEli Schwartz1-26/+34
We say: > If version 4.2 or higher of the first is found, targets coverage-text, > coverage-xml, coverage-sonarqube and coverage-html are generated. But this is totally untrue. Make it true, by actually checking (and not generating broken coverage commands when older versions of gcovr are found). Fixes #9505
2021-10-29Fix version requirement on Ninja feature.Jussi Pakkanen1-1/+1
2021-10-27fix various flake8 whitespace errorsEli Schwartz1-6/+6
2021-10-10Add --vsenv command line option and active VS only when neededXavier Claessens1-2/+1
2021-10-10ar linker: generate thin archives for uninstalled static librariesEli Schwartz1-1/+1
Since they will never be used outside of the build directory, they do not need to literally contain the .o files, and references will be sufficient. This covers a major use of object libraries, which is that the static library would potentially take up a lot of space by including another copy of every .o file. Fixes #9292 Fixes #8057 Fixes #2129
2021-10-04fix extra whitespaceEli Schwartz1-2/+0
discovered via flake8 --select E303
2021-10-01rust: dependencies need to cause a rebuild/relink not just reorderDylan Baker1-1/+6
Otherwise changes to a dependency don't propogate
2021-09-30Make custom_target() name argument optionalXavier Claessens1-1/+2
2021-09-24ninjabackend: Rust use Backend.generate_basic_compiler_argsDylan Baker1-9/+1
Instead of open coding it. This simplifies things, and fixes some missing functionality
2021-09-24Add option to to transpile Cython to C++Dylan Baker1-2/+4
This patch adds a new meson built-in option for cython, allowing it to target C++ instead of C as the intermediate language. This can, of course, be done on a per-target basis using the `override_options` keyword argument, or for the entire project in the project function. There are some things in this patch that are less than ideal. One of them is that we have to add compilers in the build layer, but there isn't a better place to do it because of per target override_options. There's also some design differences between Meson and setuptools, in that Meson only allows options on a per-target rather than a per-file granularity. Fixes #9015
2021-09-20ninjabackend/vs: handle builddir on different drive from cwdRyan Kuester1-1/+7
When setup creates a Visual Studio environment, a message is logged which contains a path to the build directory. Typically, this path is converted to a relative path prior to printing. If the path cannot be converted to a relative path (e.g., because buildpath is on a different drive from the cwd), print out the full path instead of failing with an unhandled exception.
2021-09-20backend/ninja: add generated sources to depscan order depsDylan Baker1-2/+6
Since we changed to using a json file to avoid over long command lines we created a situation where the generated files may not be ready when the depscan happens. To avoid that, we need to add all of the generated sources as order deps. Fixes: #9258
2021-09-14apply flake8 fixes for unused imports and missing importsEli Schwartz1-1/+1
2021-08-31pyllint: enable consider-user-enumerateDylan Baker1-2/+1
This caught a couple of cases of us doing: ```python for i in range(len(x)): v = x[i] ``` which are places to use enumerate instead. It also caught a couple of cases of: ```python assert len(x) == len(y) for i in range(len(x)): xv = x[i] yv = y[i] ``` Which should instead be using zip() ```python for xv, yv in zip(x, y): ... ```
2021-08-31pylint: turn on superflous-parensDylan Baker1-5/+5
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-28Delete old outputs that are no longer in the Ninja file.Jussi Pakkanen1-0/+1
2021-08-20backends/xcode: remove unused compiler parameter from escape_extra_argsDylan Baker1-2/+1
2021-08-20backends: remove unused name parameter from as_meson_exe_cmdlineDylan Baker1-4/+3
This parameter isn't used, at all, so just remove it
2021-08-20ninjabackend: add missing type annotationDylan Baker1-1/+1
I needed to figure this out for the purposes of annotating CleanTrees anyway.
2021-08-20backends: move method from ninjabackend to base classDylan Baker1-5/+0
The baseclass has code that assumes said method exists, and it really doesn't seem to do anything ninja specific, so move it to the generic backend.
2021-08-18backends/ninja: write depscan input files to jsonDylan Baker1-9/+18
Currently, we write each file to the command line, but this can result in situations where the number of files passed exceeds OS imposed command line limits. For compilers, we solve this with response files. For depscan I've chosen to use a JSON list instead. JSON has several advantages in that it's standardized, there's a built-in python module for it, and it's familiar. I've also chosen to always use the JSON file instead of having a heuristic to decide between JSON and not JSON, while there may be a small performance trade off here, keeping the implementation simple with only one path is wort it. Fixes #9129
2021-08-17rust targets: lld-link is the same as link for static libsNirbheek Chauhan1-3/+3
Without this, rustc will fail to find libfoo.a; same as with MSVC.
2021-08-17Add install tagsXavier Claessens1-0/+2
Fixes: #7007.
2021-08-15Refresh Ninja cache files on regeneration.Jussi Pakkanen1-0/+3
2021-08-11Always generate Java rule, it is platform agnostic.Jussi Pakkanen1-2/+1
2021-08-03ninjabackend: use get_subdir() instead of subdir attribute for cythonDylan Baker1-1/+1
As this works correctly for CustomTarget, CustomTargetIndex, and GeneratedList, but .subdir doesn't work for CustomTargetIndex.
2021-07-23Add support for gcovr --sonarqube reportWeston Schmidt1-0/+7
Sonarcloud.io only can read the sonarqube based report that gcovr can produce. This change enables support for this output in meson and ninja. Signed-off-by: Weston Schmidt <Weston_Schmidt@alumni.purdue.edu>
2021-07-14linkers: remove is_shared_module argument to get_soname_argsPaolo Bonzini1-2/+1
The argument is now unused, drop it.
2021-07-14do not add SONAME to shared modulesPaolo Bonzini1-5/+6
For an ELF targets, shared_module() builds a module with SONAME field (using -Wl,-soname argument). This is wrong: only the shared_library() needs SONAME, while shared_module() does not. Moreover, tools such as debian's dpkg-shlibdeps use presence of SONAME field as an indicator that this is shared library as opposed to shared module (e.g., for the module it is okay to have unresolved symbols which are imported from the executable which loads the module, while a library should have all symbols resolved). This was in fact already the behavior on Darwin; extend it to ELF targets as well. Fixes: #8746 Reported-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-07-02backends/ninja: only pass project specific arguments to scan-buildDylan Baker1-1/+2
Currently all arguments are being passed to scan-build as part of the refactoring of how Meson internally handles arguments, but that's wrong, only project specific arguments are supposed to be passed. Fixes: #8818