Commit Graph

424 Commits

Author SHA1 Message Date
Dylan Baker bff0b41525 rust: Accept generated sources for main.rs
There are still caveats here. Rust/cargo handles generated sources by
writing out all targets of a single repo into a single output directory,
setting a path to that via a build-time environment variable, and then
include those files via a set of functions and macros. Meson's build
layout is naturally different, and ninja makes working with environment
variables at compile time difficult.

Fixes #8157
2021-01-19 10:14:10 -08:00
Dylan Baker 3ae115b57a Replace NinjaBackend is_rust_target with build.uses_rust
we have two functions to do the exact same thing, and they're basically
implemented the same way. Instead, let's just use the BuildTarget one,
as it's more generally available.
2021-01-19 10:12:38 -08:00
Dylan Baker e36aca42d0 build/interpreter: Split InstallDir to fix layering violation
Currently InstallDir is part of the interpreter, and is an Interpreter
object, which is then put in the Build object. This is a layering
violation, the interperter should have a Holder for build data. This
patch fixes that.
2021-01-13 13:32:48 -08:00
Dylan Baker 59328aba29 build: Add some type annotations 2021-01-13 13:32:48 -08:00
Dylan Baker 022632c91b build/interperter: Add annotations and move input validation to interpreter
This moves the user input validation to the interpreter, instead of
being in the build module, and adds type annotations.
2021-01-13 13:32:48 -08:00
Dylan Baker a539fda0cf fix LGTM warnings 2021-01-04 12:20:59 -08:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -08:00
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
I would have prefered to do these seperatately, but they are combined in
some cases, so it was much easier to convert them together.

this eliminates the builtins_per_machine dict, as it's duplicated with
the OptionKey's machine parameter.
2021-01-04 12:20:40 -08:00
Dylan Baker f9b19e73a5 move OptionKey to mesonlib
There's starting to be a lot of things including coredata that coredata
needs to itself include. putting it in mesonlib makes more sense
2021-01-04 12:20:40 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Dylan Baker 7ddb7a48f5 build/interpreter: Add some type annotations 2020-12-16 12:29:49 -08:00
Dylan Baker 47c560f3f7 build: Use python 3.6 annotation syntax for Build initializer 2020-12-16 12:29:49 -08:00
Dylan Baker 2f66d9f2eb build: Add annotation for Build.data 2020-12-16 12:23:23 -08:00
Dylan Baker 94b9e7b04e build/interpreter: fix layering violations for ManPages
Like `install_headers`, `install_man` used the same objects for both the
interpreter and the build, this is bad. Let's have two separate objects.
2020-12-16 12:23:23 -08:00
Dylan Baker 7ffc678514 build/interpreter: split representation of Headers
This was all layering violations before. Now we have Headers in the
build module, and a holder in the interpreter. All of the type
validation is done in interpreter method for `install_headers`.
2020-12-16 12:23:23 -08:00
Jussi Pakkanen c21b04ba08 Add prelinking support for static libraries. 2020-12-03 22:58:07 +02:00
Dylan Baker 5c74cccbb9 run_unittests: use textwrap.dedent
So that editors that can fold code (vim, vscode, etc) can correctly fold
functions, instead of getting confused by code that doesn't follow the
current indention. Also, it makes the code easier to read.
2020-11-13 09:00:35 -08:00
Paolo Bonzini df29f760dd switch gui_app deprecation to FeatureDeprecatedKwargs
The deprecation message for "gui_app" is appearing for every target
rather than just once, and even if the required version is older
than 0.56.0.  Use @FeatureDeprecatedKwargs to fix both issues.
2020-10-19 09:40:31 -07:00
Paolo Bonzini 021d242f9c build: use PIE objects for static libraries if b_staticpic=false but b_pie=true
If static_library is used as a convenience library (e.g. for link_whole)
it should in principle not need position independent code.
However, if the executables that the libraries is linked to are PIE,
the non-PIC objects in the static library will cause linker errors.
To avoid this, obey b_pie for static libraries if either b_staticpic=false
or they use "pic: false".

Without this patch, QEMU cannot use b_staticpic, which causes a slowdown
on some QEMU benchmarks up to 20%.
2020-10-18 18:56:35 +03:00
Daniel Mensinger 7c377e5a5d intro: Add extra_files key to intro output (fixes #7310) 2020-10-15 01:56:59 +03:00
Sahnvour 206e9e5097 Properly handle the case of linking static library with custom targets 2020-10-10 04:28:16 +00:00
Jussi Pakkanen 1a0603835e Add win_subsystem kwarg. Closes #7765. 2020-10-07 18:55:25 +03:00
Dylan Baker f342efd080 pylint: turn on bad-indentation error
and fix all of the bad indentation
2020-09-22 17:57:03 -07:00
Dylan Baker cb0265a6b2 pylint: Catch cases of `if len(container)` which should be replaced by `if container`
Unfortunately this doesn't catch other abuses of len(continauer) like,
`len(container) <comparator> 0`, see: https://github.com/PyCQA/pylint/issues/3751
2020-09-18 14:49:58 -07:00
Marco Mastropaolo 93b1d31af9 Fixed MacOS dylib custom targets not marked as linkable 2020-09-17 11:22:41 +00:00
Daniel Mensinger 4253bf6281
typing: Fix code review 2020-09-08 20:15:59 +02:00
Daniel Mensinger e681235e5f
typing: fix code review 2020-09-08 20:15:58 +02:00
Daniel Mensinger 23818fc5a3
typing: more fixes 2020-09-08 20:15:58 +02:00
Paolo Bonzini fcf9746232 build: optimize extract_objects
extract_objects is repeatedly looking up files in self.sources, which is a list.
Convert it to a set beforehand so that the lookup is O(1).

On a QEMU build, the time spent in extract_objects goes from 3.292s to 0.431s.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-08-18 08:11:25 +02:00
Xavier Claessens 40c197d524 pkgconfig: Fix various corner cases
See unit tests for the exact scenarios this PR fixes.
2020-07-30 18:59:10 +03:00
Jussi Pakkanen 804a71e8f2 Do not add rpaths for static libs. Closes #5191. 2020-07-20 14:14:49 +00:00
Jussi Pakkanen 2b1ca518cf
Merge pull request #7123 from dcbaker/use-feature-deprecated
Use FeatureDeprecated (and other cleanups)
2020-05-22 17:08:44 +03:00
Jussi Pakkanen 751ea3df72
Merge pull request #7103 from dankegel/bug4027-rpath-remember
Let .pc files and LDFLAGS provide rpaths.
2020-05-18 23:17:34 +03:00
Dan Kegel d7235c5905 Let .pc files specify rpath.
Fixes #4027
2020-05-16 20:25:58 +00:00
Dylan Baker d51551231f use FeatureNew.single_use
This is just slightly cleaner looking
2020-05-14 12:15:03 -07:00
Dylan Baker 06481666f4 interpreter: Replace some uses of mlog.deprecation with FeatureDeprecated
This gives the version that the feature was deprecated in, and doesn't
print the warning if the project supports versions of meson in which the
project wasn't deprecated.
2020-05-14 11:28:04 -07:00
Dylan Baker 85708facae
Merge pull request #6620 from jon-turney/test-output-check
Add a mechanism for validating meson output in tests
2020-05-13 11:32:28 -07:00
Marcel Hollerbach d526af89ca interpretor: Do not add dependencies if we already have them
in tree like dep structures with a lot of source: declarations, this can
result in a lot of presure on the source list. this saves ~3s out of 7s
in the interpretor stage in efl build.
2020-05-13 15:58:26 +00:00
Szabi Tolnai d87925dc3a Allow indexed custom target to be used in executable's depends.
Change-Id: I7f3e0e0dd9c413d7f6e3267de9664b89f2294e27
2020-05-08 22:56:23 +03:00
Jussi Pakkanen 4ea7c6ee12
Merge pull request #7064 from dcbaker/gtest-protocol
Add support for Gtest as a test protocol
2020-05-06 23:57:44 +03:00
Dylan Baker c2a4474b58 build: cleanup and sort imports 2020-04-30 13:39:36 -07:00
Jon Turney 6a5c6fb439
Be more careful about the use of repr() in error messages
Generally, we'd want to use str() rather than repr() in error messages
anyhow, as that explicitly gives something designed to be read by
humans.

Sometimes {!r} is being used as a shortcut to avoid writing the quotes
in '{!s}'.

Unfortunately, these things aren't quite the same, as the repr of a
string containing '\' (the path separator on Windows) will have those
escaped.

We don't have a good string representation to use for the arbitrary
internal object used as an argument for install_data() when it's neither
a string nor file (which doesn't lead to a good error message), so drop
that for the moment.
2020-04-30 20:11:32 +01:00
Dylan Baker fdd6022530 interpreter: Add link_language to all build targets
If the feature hadn't been broken in the first place it would have
worked on them anyway, so we might as well expose it. I'm loathe to do
it because one of the best features of meson in a mixed C/C++ code base
is that meson figures out the right linker every time, but there are
cases people have where they want to force a linker. We'll let them keep
the pieces.
2020-04-30 10:38:55 -07:00
Dylan Baker d8a3c777a6 build: Fix link_language selection
Currently it does nothing, as the field is read too late, and additional
languages have already been considered. As such if the language
requested is closer to C (for example you want C but have a C++ source
with only extern C functions) then link_langauge is ignored.

Fixes #6453
2020-04-30 10:38:55 -07:00
Dylan Baker 7d4af2ab7c build: add missing type annotation 2020-04-30 10:38:55 -07:00
John Ericson 278c294aa4 Compiler options per lang
A current rather untyped storage of options is one of the things that
contributes to the options code being so complex. This takes a small
step in synching down by storing the compiler options in dicts per
language.

Future work might be replacing the langauge strings with an enum, and
defaultdict with a custom struct, just like `PerMachine` and
`MachineChoice`.
2020-04-20 23:23:15 +03:00
Jon Turney 27d498de6d
Fix handling of library(name_prefix: [])
Adjust the handling of a name_prefix: [] kwarg to be the same as
name_suffix: [] kwarg, i.e. identically to the case where it's omitted,
so BuildTarget.prefix doesn't get set (so the default is used).

Also clarify the error reported when a non-empty list is used.
2020-04-11 19:57:38 +01:00
alanNz 7460292810 -Add xc16 and c2000 C,Cpp toolchain support 2020-03-21 00:47:24 +02:00
Jussi Pakkanen aff7fc89c3 Generators can depend on custom targets as well as build targets. 2020-03-19 22:03:14 +02:00
Jussi Pakkanen 5c51d4521a
Merge pull request #6532 from jon-turney/languages-native-kwarg
Add add_languages(native:)
2020-03-09 01:20:57 +02:00