Commit Graph

537 Commits

Author SHA1 Message Date
Pablo Correa Gómez 4f882ff8ec add install_symlink function
Allows installing symlinks directly from meson, which can
become useful in multiple scenarios. Current main use is to
help moving forward #9557
2021-12-01 13:59:54 -05:00
Eli Schwartz 99d809b59d
fix BSD ldconfig handling (#9631)
For libraries installed to libdir, it's not expected to have rpath
hooked up. But for non-default libdirs, the path might not get searched
by default. `ldconfig -m <libdir>` is convenient here, as it will
programmatically add a new directory to search for shared libraries, so
the resulting installed programs work out of the box.

Include the dragonfly BSD platform name, which doesn't match the 'bsd'
catch-all pattern.
2021-11-28 18:32:10 +02:00
Dylan Baker 73bac14c8f backends/backends: recurse when looking for paths in bundled shared libraries
This previously worked because we were accidentally doing this via
mutation. However, doing this via mutation is not a good way to do it,
we should be explicit.

Fixes #9542
2021-11-24 02:23:57 +05:30
Dylan Baker f29b54dfe4 build|backend: Fix some type annotations
These currently say the take `Target`, but the really take
`BuildTarget | CustomTarget | CustomTargetIndex`.
2021-11-24 02:23:57 +05:30
Dylan Baker 2eafe9a25f backends/backends: fix typo in comment 2021-11-24 02:23:57 +05:30
Crend King 809792c223 Support Visual Studio 2022 backend 2021-11-21 08:08:11 -05:00
Jussi Pakkanen c1b686e395 Make environment objects hash deterministically. 2021-10-29 22:47:06 +03:00
Eli Schwartz 108bd996ee
add install_emptydir function
This replaces the absolute hack of using

```
install_subdir('nonexisting', install_dir: 'share')
```

which requires you to make sure you don't accidentally or deliberately
have a completely different directory with the same name in your source
tree that is full of files you don't want installed. It also avoids
splitting the name in two and listing them in the wrong order.

You can also set the install mode of each directory component by listing
them one at a time in order, and in fact create nested structures at
all.

Fixes #1604
Properly fixes #2904
2021-10-08 14:35:00 -04:00
Eli Schwartz 4ab70c5512
fix extra whitespace
discovered via flake8 --select E303
2021-10-04 16:29:31 -04:00
Dylan Baker d661a0cd96 build: use an object rather than a dict for the dep_manifest
This really is more of a struct than a dict, as the types are disjoint
and they are internally handled, (ie, not from user input). This cleans
some things up, in addition I spotted a bug in the ModuleState where the
dict with the version and license is passed to a field that expects just
the version string.
2021-09-24 10:36:05 -07:00
Xavier Claessens e006e2ee99 Fix ignored install_tag kwarg in install_subdir()
Fixes: #9263
2021-09-16 07:53:18 -04:00
Filipe Laíns af8b55d49b mintro: add installed_plan
Signed-off-by: Filipe Laíns <lains@riseup.net>
2021-09-06 18:10:55 +02:00
Eli Schwartz 0b63dff3ba
run_target: do not yield broken names with subdirs
A run_target object created in a subdir/meson.build always has a ninja
rule name of "name", not "subdir/name".

Fixes #9175
2021-09-01 15:42:39 -04:00
Dylan Baker 4d7031437c pylint: turn on superflous-parens
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-31 16:28:54 -04:00
Jussi Pakkanen 267d5385d4 Path special casing for the Xcode backend. 2021-08-21 22:33:47 +03:00
Dylan Baker dffa93b853 backend/backends: use a TypedDict for introspection data
Which is easier to reason about as a human, and narrower, allowing for
more accurate type checking.
2021-08-20 18:57:19 +02:00
Dylan Baker f6f35aa906 backend/backends: Add type annotations to Backend 2021-08-20 18:57:19 +02:00
Dylan Baker 24284fd9d5 backend/backends: Add verbose to ExecutableSerialisiation initializer
There are cases in the backend like this:
```python
e = ExecutableSerialisation(...)
e.verbose = v
```
setting it from the initializer is cleaner.
2021-08-20 18:57:19 +02:00
Dylan Baker a5b6b35edb backend/backends: Add type annotations to ExecutableSerilalisation 2021-08-20 18:57:19 +02:00
Dylan Baker 6785504b53 backend/backends: Add type annotations to SubdirInstallData 2021-08-20 18:57:19 +02:00
Dylan Baker ccab6d9c84 backend/backends: Add type annotations to TargetInstallData 2021-08-20 18:57:19 +02:00
Dylan Baker 9fb19ed923 backend/backends: Add type annotations to CleanTrees 2021-08-20 18:57:19 +02:00
Dylan Baker 2664153d24 backend/backends: add type annotations to RegenInfo 2021-08-20 18:57:19 +02:00
Dylan Baker 0ca0e6116c backends: remove unused name parameter from as_meson_exe_cmdline
This parameter isn't used, at all, so just remove it
2021-08-20 18:57:19 +02:00
Dylan Baker 0bc77c604f backends: move method from ninjabackend to base class
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-20 18:57:19 +02:00
Xavier Claessens 8c5aa031b5 Add install tags
Fixes: #7007.
2021-08-17 15:19:18 -04:00
Simon Ser 1f3adc4dbe Add feed arg to custom_target() 2021-06-29 20:54:13 +03:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Denis Fortin 7bc57d03a5 build: fix object path for vs backend 2021-06-28 23:15:30 +03:00
Daniel Mensinger 3f889606c7 Split compiler detection from Environment
This moves all the compiler detection logic into the new
compilers.detect module. This dramatically reduces the size
and complexity of Environment.
2021-06-25 19:34:48 +02:00
Jussi Pakkanen 6e0a0fd1da
Merge pull request #8884 from dcbaker/submit/type-and-annotate-install-functions
Add annotations for the various install_* functions
2021-06-23 01:00:59 +03:00
fanc999 edfe24178d
Add Visual Studio 2012/2013 backends (#8803)
* backends: Add a Visual Studio 2013 backend

This is more-or-less a quick port from the VS2015 backend, except that
we update the Visual Studio version strings and toolset versions
accordingly.  Also correct the generator string for Visual Studio 2015
in mesonbuild/cmake/common.py.

* backend: Add VS2012 backend

Similar to what we did for Visual Studio 2013, add a Visual Studio 2012
backend.

* vs2010backend.py: Implement `link_whole:` if needed

We actually need Visual Studio 2015 Update 2 to use `/WHOLEARCHIVE:`,
which is what we are currently using for `link_whole:` on Visual Studio.
For Visual Studio versions before that, we need to expand from the
static targets that were indicated by `link_whole:`, and any of the
sub-dependent targets that were pulled in via the dependent target's
`link_whole:`.  This wil ensure `link_whole:` would actually work in
such cases.

* vs2010backend.py: Handle objects from generated sources

Unforunately, we can't use backends.determine_ext_objs() reliably, as
the Visual Studio backends handle this differently.

* vs2010backend.py: Fix generating VS2010 projects

Visual Studio 2010 (at least the Express Edition) does not set the envvar
%VisualStudioVersion% in its command prompt, so fix generating VS2010
projects by taking account into this, so that we can determine the location
of vcvarsall.bat correctly.

* whole archive test: Disable on vs2012/2013 backends too

The Visual Studio 2012/2013 IDE has problems handling the items that would be
generated from this test case, so skip this test when using
--backend=vs[2012|2013].  This test does work for the Ninja backend when
VS2012 or VS2013 is used, though.

Consolidate this error message with XCode along with the vs2010 backend.

* docs: Add the new vs2012 and vs2013 backends

Let people know that we have backends for vs2012 and 2013.  Also let
people know that generating Visual Studio 2010 projects have been fixed
and the pre-vs2015 backends now handle the `link_whole:` project option.
2021-06-22 21:00:23 +03:00
Dylan Baker d636b92c1a install_*: FileMode doesn't need to be None
There's no reason to allow None into the backend, it already has code to
check that all of the values of the FileMode object are None, so let's
use that, which is much simpler all the way down.
2021-06-22 09:13:41 -07:00
Dylan Baker f2ad5e377e backend: Headers.install_subdir is allowed to be None
But we don't properly handle that.
2021-06-22 09:12:54 -07:00
Daniel Mensinger 34c28dc92c holders: remove unholder 2021-06-18 23:48:33 +02:00
Dylan Baker 9851c25895 backends: fix TestSerialisation.suite annotations
It's a `str[]` not `str`
2021-06-14 12:30:02 -07:00
Eli Schwartz 3eb1da1fa2
condense lines 2021-06-07 16:51:47 -04:00
Eli Schwartz 2c71b63e77
more f-strings everywhere
pyupgrade didn't catch many .format() methods which were too complex
(e.g. multiline or applied to templates rather than string literals)
2021-06-07 16:51:47 -04:00
Dylan Baker 113a159514 use an immutable list for an lru_cached functions
When mutable items are stored in an lru cache, changing the returned
items changes the cached items as well. Therefore we want to ensure that
we're not mutating them. Using the ImmutableListProtocol allows mypy to
find mutations and reject them. This doesn't solve the problem of
mutable values inside the values, so you could have to do things like:

```python
ImmutableListProtocol[ImmutableListProtocol[str]]
```

or equally hacky. It can also be used for input types and acts a bit
like C's const:

```python
def foo(arg: ImmutableListProtocol[str]) -> T.List[str]:
    arg[1] = 'foo'  # works while running, but mypy errors
```
2021-06-02 15:53:17 -07:00
Jussi Pakkanen 43f0aa17b7 Add swift executable support in Xcode. 2021-05-23 17:59:14 +01:00
Dylan Baker bfd06783bd backends: use a set for processed targets instead of a dict
We're only interested in the keys, not in the value (which was always
set to True), so a set is a better data structure anyway.
2021-05-19 23:28:17 +03:00
Jason Francis 39c751b94c introspection: export all sources for custom targets
Also adds some test cases for source files in target_sources.
2021-04-26 17:08:26 +01:00
Jussi Pakkanen 1a31882f59 Xcode: make Swift projects work. 2021-04-25 15:35:13 +03:00
Jussi Pakkanen 674538d8c9 Xcode: put all include dirs via a property rather than a cmd line arg. 2021-04-21 17:16:01 +03:00
Jussi Pakkanen 6f76fce904 Xcode: regenerato project file when build conf changes. 2021-04-19 17:59:40 +03:00
Jussi Pakkanen 126db6de12 Xcode: fix running commands that lie in the build root dir. 2021-04-18 19:19:29 +03:00
Jussi Pakkanen 09d89dfaeb Xcode: fix custom target chaining. 2021-04-18 19:19:29 +03:00
Jussi Pakkanen 48e38fbaeb Xcode: fix custom targets that produce objs and libs. 2021-04-16 18:14:01 +03:00
Jussi Pakkanen 9dfd53dc40 Xcode: fix setting up inlude args for source and build dirs. 2021-04-11 23:59:22 +03:00
Jussi Pakkanen 86fb916d33 Xcode: Fix source generation. 2021-04-10 20:33:51 +03:00
Jussi Pakkanen 9fb0abb754 Write include dirs with absolute paths in the Xcode backend, relative ones do not seem to work. 2021-04-09 16:51:42 +03:00
Xavier Claessens df4314c7b8 backends: Remove @PRIVATE_OUTDIR_(ABS)@ substitution
It is not documented and does not seems to be used anywhere.
2021-03-26 23:39:01 +02:00
Xavier Claessens a9e9b7c750
devenv: Set GI_TYPELIB_PATH and LD_LIBRARY_PATH (#8548) 2021-03-23 23:35:05 +02:00
Dylan Baker 40e3577a65 split program related classes and functions out of dependencies
Dependencies is already a large and complicated package without adding
programs to the list. This also allows us to untangle a bit of spaghetti
that we have.
2021-03-19 08:47:10 -04:00
Xavier Claessens 598e968993 Add `meson devenv` command and meson.add_devenv() 2021-03-16 09:00:50 -04:00
Xavier Claessens e0fcccc6e2 EnvironmentVariables: Simplify and annotate 2021-03-16 09:00:50 -04:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Eli Schwartz 4340bf34fa
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only --keep-percent-format"

and committing the results. I have not touched string formatting for
now.

- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
2021-03-04 17:11:26 -05:00
Xavier Claessens c8abede403 Windows Subsystem for Linux can run .exe without mono interpreter
Fixes: #8445
2021-03-03 08:05:00 -05:00
Jason Woodward 50af09de03 install_man locale support
Rather than having to manually build the locale aware man paths with

`install_data('foo.fr.1', install_dir: join_paths(get_option('mandir'), 'fr', 'man1'), rename: 'foo.1')`

Support doing

`install_man('foo.fr.1', locale: 'fr')`
2021-02-27 14:35:23 +02:00
Xavier Claessens 2fabd4c7dc minstall: Add --skip-subprojects option
By default all subprojects are installed. If --skip-subprojects is given
with no value only the main project is installed. If --skip-subprojects
is given with a value, it should be a coma separated list of subprojects
to skip and all others will be installed.

Fixes: #2550.
2021-02-22 23:03:55 +02:00
Miro Hrončok 756ea32e06 Don't access other enum members from self
This is deprecated in Python 3.10.
Instead, acces them from the class.

Fixes https://github.com/mesonbuild/meson/issues/8318
2021-02-18 00:08:44 +02:00
Xavier Claessens b6804bf49c Substitute @CURRENT_SOURCE_DIR@ in run_target() and custom_target()
run_target() does some variable substitutions since 0.57.0. This is a
new behavior, and undocumented, caused by sharing more code with
custom_target(). More consistency is better, so document it now.

custom_target() was doing variable substitution in the past, because it
shared some code with generator(), but that was undocumented. Some
refactoring in 0.57.0 caused it to not replace @CURRENT_SOURCE_DIR@,
@SOURCE_DIR@, and @BUILD_DIR@ anymore. This patch adds back
@CURRENT_SOURCE_DIR@ and document it. It does not add back @SOURCE_DIR@
because it is duplicate with @SOURCE_ROOT@ that has a better name. Also
do not add back @BUILD_DIR@ which is duplicate of @PRIVATE_DIR@, and
not @BUILD_ROOT@ surprisingly, adding to the confusion.
2021-02-17 14:48:04 +02:00
Xavier Claessens 2a8d6690f7 backends: Fix custom_target() with configure_file() exe 2021-02-09 19:32:20 +02:00
Xavier Claessens a155935d24 backends: Always use the command returned by as_meson_exe_cmdline()
Even if the command is not wrapped by meson, it could have been modified
to add java/mono interpreters. This fix potential inconsistency between
wrapped and unwrapped commands.
2021-02-09 19:32:20 +02:00
Jussi Pakkanen 71784e1002 Fix exe wrapper detection for run targets. 2021-02-08 23:19:41 +02:00
Jussi Pakkanen 8b82ffa9e4
Merge pull request #8305 from xclaesse/run-target-env
run_target: Add env kwarg
2021-02-07 11:46:41 +00:00
Dylan Baker 456844a4f3 vala: Disable unity builds
Our approach to unity builds with vala is broken, you cannot unify the
generated C files, as they contain duplicate symbols. We would need to
instead combine the files while they are still in their vala form, then
convert that to C and compile the unified C file.

This does not fix the linked issue, as this removed the ability to do
vala unity builds, but it does allow running vala with `--unity=on`.

Related: #5280
2021-02-05 16:31:33 -08:00
Xavier Claessens f63e168685 ninjabackend: Remove useless call to replace_paths()
Replacements are already done by eval_custom_target_command() and must
be done BEFORE calling as_meson_exe_cmdline() anyway. replace_paths() is
still used by generators.

Make eval_custom_target_command() more readable by handling error in the
final else case instead of in the middle of elif.
2021-02-05 18:17:08 -05:00
Xavier Claessens b52794b24b backend: Do not check for exe wrapper twice
It is already checked by as_meson_exe_cmdline().
2021-02-05 18:17:08 -05:00
Xavier Claessens 522392e755 run_target: Add env kwarg
Re-implement it in backend using the same code path as for
custom_target(). This for example handle setting PATH on Windows when
command is an executable.
2021-02-05 17:53:09 -05:00
Jeff Moguillansky 9226a92fe0 xcode-backend: add implicit includes
Move helper functions get_source_dir_include_args and
get_build_dir_include_args to backend base class
2021-02-04 13:05:17 -08:00
Xavier Claessens 6c6b5d77d6 add_install_script: add skip_if_destdir kwarg
It is common, at least in GNOME projects, to have scripts that must be
run only in the final destination, to update system icon cache, etc.
Skipping them from Meson ensures we can properly log that they have not
been run instead of relying on such scripts to to it (they don't
always).
2021-01-30 21:28:21 +00:00
Xavier Claessens 0626465ea8 Fix executable as script on Windows
On Windows this would fail because of missing DLL:
```
mylib = library(...)
exe = executable(..., link_with: mylib)
meson.add_install_script(exe)
```

The reason is on Windows we cannot rely on rpath to find libraries from
build directory, they are searched in $PATH. We already have all that
mechanism in place for custom_target() using ExecutableSerialisation
class, so reuse it for install/dist/postconf scripts too.

This has bonus side effect to also use exe_wrapper for those scripts.

Fixes: #8187
2021-01-30 09:51:06 +00:00
Xavier Claessens 633264984b custom_target: Add env kwarg 2021-01-27 09:00:54 -05:00
Jonas Lundholm Bertelsen 2636eebd64 Unity build reverts to normal for fortran fix
The `determine_ext_objs` function did not take into account that fortran
(and d) does not support unity builds. This caused failures in some
cases.
2021-01-21 14:46:20 +01:00
Jonas Lundholm Bertelsen ea34a92632 When iterating link_targets, include link_whole_targets too (fortran)
This fixes fortran includes and fortran orderdeps for libraries that
were under link_whole_targets.
2021-01-20 18:18:54 +01:00
Marios Staikopoulos a3d8dc546c Removal of /ZI on MSVC Debug
The /ZI flag adds in "Edit and Continue" debug information, which will
cause massive slowdown. It is not a flag that we should be adding by
default to debug builds.

/Zi will still be added.
2021-01-17 21:03:35 +00:00
Dylan Baker 96d7f6c7cd backends/backends: Add type annotations for InstallData
This adds enough type annotations for InstallData and friends to make
minstall happy. There is also a small change in that I've replaced the
List[List] with List[Tuple], as tuples are more appropraite data types
for the information (fixed length, position matters, different types at
different indexes)
2021-01-13 13:32:48 -08:00
Dylan Baker f202da0689 use PEP8 style naming for LANGUAGES_USING_* as well 2021-01-11 11:15:06 -08:00
Dylan Baker d89ec98b47 mtest: Add support for rust unit tests
Rust has it's own built in unit test format, which is invoked by
compiling a rust executable with the `--test` flag to rustc. The tests
are then run by simply invoking that binary. They output a custom test
format, which this patch adds parsing support for. This means that we
can report each subtest in the junit we generate correctly, which should
be helpful for orchestration systems like gitlab and jenkins which can
parse junit XML.
2021-01-05 10:23:41 -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 fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Dylan Baker f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08: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
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Jussi Pakkanen 400ec2d685
Merge pull request #7762 from jon-turney/meson-exe-output-improve
Improve the output for meson wrapped commands
2020-09-29 19:28:51 +03:00
Vili Väinölä d1638a4fde compilers/VS: fix build to use optimization and debug flags
- Fixed using debug and optimization built-in options in MSVC.
- Fixed that VS backend does not create pdb files in release mode.
VS implicitly adds the debug fields if left out.
- Fix that it is possible to add debug info with ninja backend with
optimizations.
2020-09-29 19:25:50 +03:00
Jon Turney 194dcdef03
Make meson_exe report pickled command when it fails
Make 'meson --internal exe --unpickle' report the actual command
executed when it fails, which is otherwise invisible.
2020-09-20 12:57:50 +01:00
Jon Turney c72625c2a7
Improve description of meson wrapped custom commands
I've always found ninja reporting 'a meson_exe.py custom command'
unclear and confusing. Instead say we are invoking a custom command,
wrapped by meson, and why.
2020-09-20 12:57:44 +01:00
Nirbheek Chauhan faba48d853 backends: Treat build target as generator only when it's the first arg
Otherwise it might be an argument to a script that just inspects the
binary itself.
2020-09-17 22:25:37 +00:00
Xavier Claessens 19696c3dcd Allow installing dir from build dir 2020-09-13 13:54:47 -04:00
Eli Schwartz d880f995ea Revert "Do not automatically set warning flags if buildtype is 'plain'"
This reverts commit 8ee1c9a07a.

No rationale was given for this change prior to merging. After the fact
it was described as desired by distro packagers, however as a distro
packager I believe this commit hurts me.

From a distro packaging perspective, we primarily care about one thing:
previously building code should still build. Hence, -Werror is bad for
our use case. meson handles this via -D werror which is different from
-D warning_level and as long as the former is disabled, warnings in the
build do not cause harm (but may attract review attention for upstream
to fix).

buildtype is a completely unrelated concern, and the intention for
=plain is to disable debug or optimization settings that result in
codegen differences and thus different built artifacts. This must not
happen in distro builds because the *distributed programs* should
conform to policy settings.

Unfortunately, completely disabling warnings happens silently, and
cannot be overridden even if you really, really believe you know what
you're doing. It is thematically broken, since use of
add_project_arguments() to add more -W flags is not likewise ignored.
But if you try to add -Wall in that manner, meson will lecture you to
use warning_level which you cannot do. And if you have custom warning
flags which depend on options enabled by judicious use of -Wall via
default_options: 'warning_level=1', then you end up with generated
warnings complaining about your command line rather than your code, such
as:

cc1: warning: ‘-Wformat-y2k’ ignored without ‘-Wformat’ [-Wformat-y2k]
cc1: warning: ‘-Wformat-extra-args’ ignored without ‘-Wformat’ [-Wformat-extra-args]
cc1: warning: ‘-Wformat-zero-length’ ignored without ‘-Wformat’ [-Wformat-zero-length]
cc1: warning: ‘-Wformat-contains-nul’ ignored without ‘-Wformat’ [-Wformat-contains-nul]
cc1: warning: ‘-Wformat-security’ ignored without ‘-Wformat’ [-Wformat-security]

which then break the build with -Werror.

Throughout all this, a buildtype of "plain" does *not* disable -D
werror=true, which is the part where distro builds actually break down!

Users who both wish to disable debug/optimization codegen, *and* disable
warning commentary, are encouraged to do so by doing both, not by doing
one and having the other be assumed.

Fixes #7399
2020-09-11 18:22:57 +00:00
Nirbheek Chauhan 9fb839687b minstall: Add version field to install data
And check the install data in the same way that mtest checks
serialisation data.

Fixes https://github.com/mesonbuild/meson/issues/2354
2020-09-10 12:38:05 +00:00
Nirbheek Chauhan fb7099c6cf mtest: Check version in the test data after loading
Same as coredata.dat and build.dat loading. Also, do not assert if
things change. Raise the appropriate exception.

Fixes https://github.com/mesonbuild/meson/issues/7613
2020-09-10 08:18:16 +00:00
Daniel Mensinger 23818fc5a3
typing: more fixes 2020-09-08 20:15:58 +02:00
James Hilliard 646ae846be backends: check external rpaths for all languages using ldflags
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2020-09-06 21:07:14 +03:00
Paolo Bonzini fa5c2363eb introspect: add test dependencies info to test/benchmark JSON
Add the ids of any target that needs to be rebuilt before running the
tests as computed by the backend, to the introspection data for tests and benchmarks.
This also includes anything that appears on the test's command line.

Without this information, IDEs must update the entire build before running
any test.  They can now instead selectively build the test executable
itself and anything that is needed to run it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-09-04 14:45:20 +02:00
Paolo Bonzini 71d33a5721 backends: do not look for extra paths unnecessarily
extra_paths only matter for the host machine if using an exe_wrapper.
However, because CustomTarget.for_machine is always MachineChoice.HOST,
they were computed unnecessarily in as_meson_exe_cmdline.

Defer computation of extra_paths until after we have found out if the
custom target executable is really for the host or the build machine,
so that we can use exe_for_machine; for_machine then becomes unused
and can be removed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-08-31 23:01:05 +03:00
Xavier Claessens 1c403e20e7 Interpreter: Fix c_stdlib usage
- Exceptions raised during subproject setup were ignored.
- Allow c_stdlib in native file, was already half supported.
- Eliminate usage of subproject variable name by overriding
  '<lang>_stdlib' dependency name.
2020-08-18 14:47:38 -04:00
Jussi Pakkanen bbf8533a97
Merge pull request #7494 from keszybz/fix-two-warnings
Fix two warnings
2020-07-30 16:39:04 +03:00
James Hilliard 1ce4258c21 backends: fix rpath match pattern
Since -Wl,-rpath= is not the only valid rpath ldflags syntax we
need to try and match all valid rpath ldflags.

In addition we should prevent -Wl,--just-symbols from being used to
set rpath due to inconsistent compiler support.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2020-07-30 16:36:11 +03:00
Zbigniew Jędrzejewski-Szmek 1123f4f311 Avoid warning about multiple outputs when building private directory name
Fixup for b4b1a2c5a1.

A warning would be printed for any rule with multiple outputs, for
example:
WARNING: custom_target 'coredump.conf.5' has more than one output! Using the first one.
WARNING: custom_target 'dnssec-trust-anchors.d.5' has more than one output! Using the first one.
WARNING: custom_target 'halt.8' has more than one output! Using the first one.

Fixes https://github.com/systemd/systemd/issues/16461.
2020-07-28 19:51:58 +02:00
Dylan Baker 93c3ec7e2d compilers: Return CompilerArgs from compiler instance
Since the CompileArgs class already needs to know about the compiler,
and we really need at least per-lanaguage if not per-compiler
CompilerArgs classes, let's get the CompilerArgs instance from the
compiler using a method.
2020-06-22 12:06:10 -07:00
Dylan Baker 9d0ad66c29 compilers: Split CompilerArgs into a separate module
I've also moved this out of the compilers pacakge because we're soon
going to need it in linkers, and that creates some serious spagetti
2020-06-22 12:06:10 -07:00
Nirbheek Chauhan eab0e5a8b3 windows: Canonicalize `:` in filenames
Fixes https://github.com/mesonbuild/meson/issues/7265
2020-06-14 14:55:49 +00:00
Jon Turney b91355a29b Include the dep itself in extra_paths for Windows
This is needed in the case where a custom_target directly depends on a
shared library, and somehow loads it.

(Specifically this can be the case with gtkdoc, when it invokes
gtkdoc-scangobj, which will build and run it's own code to load a shared
library, to introspect it)
2020-06-13 18:48:35 +00:00
Jon Turney 1b7855c36d Handle multiple substitutions in eval_custom_target_command()
Handle command arguments which contain multiple substitutions correctly
in Backend.eval_custom_target_command()

In particular, gnome.gtkdoc() makes arguments of the form '--cflags
-I@SOURCE_ROOT@ -I@BUILD_ROOT' (where these arguments are then passed
down to a compiler invocation)

Normally, these are subsequently made right by
NinjaBackend.replace_paths(), but if Backend.as_meson_exe_cmdline()
decides that the command needs to be pickled, that doesn't happen.

(Although having two places where this substitution might happen smells
really bad)
2020-06-13 18:48:35 +00:00
Jon Turney aca93df184 backend: There is no need for 'compiler-specific escaping' anymore
Now that all command-line escaping for ninja is dealt with in the ninja
backend, escape_extra_args() shouldn't need to do anything.

But tests of existing behaviour rely on all backslashes in defines being
C escaped: This means that Windows-style paths including backslashes can
be safely used, but makes it impossible to have a define containing a C
escape.
2020-06-05 14:15:32 -07:00
Jussi Pakkanen 589a6249f0
Merge pull request #5986 from dcbaker/fix-tests-with-cross-binary-arguments
Fix tests with cross binary arguments
2020-05-19 00:23:19 +03:00
Jussi Pakkanen b4b1a2c5a1 Build private directory name from output file name. 2020-05-19 00:22:45 +03:00
Dylan Baker 0ec94ca062 backends: Consider arguments passed to a test when cross compiling
Otherwise a wrapper script which takes an executable as an argument will
mistakenly run when that executable is cross compiled. This does not
wrap said executable in an exe_wrapper, just skip it.

Fixes #5982
2020-05-18 13:53:58 -07:00
Dylan Baker cb6662b572 backends: ensure that test executables can be run when passed as arguments
If an executable is passed as an argument to a script in the build
directory that it resides in then it will not execute (on *nix) due to a
lack of ./. Ie, `foo` must be called as `./foo`. If it is called from a
different directory it will work. Ie `../foo` or `bar/foo`.

Fixes #5984
2020-05-18 13:53:58 -07: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 f8cfb74e9b Let LDFLAGS specify rpath.
Fixes #2567
2020-05-16 20:26:03 +00:00
Dan Kegel d7235c5905 Let .pc files specify rpath.
Fixes #4027
2020-05-16 20:25:58 +00:00
Ole André Vadla Ravnås 859dc4255a Fix outdated cross-compilation checks 2020-05-13 15:51:54 +00: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 083c5f6357 Add native support for gtest tests
Gtest can output junit results with a command line switch. We can parse
this to get more detailed results than the returncode, and put those in
our own Junit output. We basically just throw away the top level
'testsuites' object, then fixup the names of the tests, and shove that
into our junit.
2020-05-04 11:33:19 -07:00
Michael Brockus 3ac437cecf
rm python2 %s from backends.py and ninjabackend.py 2020-05-03 14:00:15 +03:00
Dylan Baker 0c51762463 backend/backends: Fix type annotation 2020-04-30 13:59:49 -07:00
Dylan Baker 28e3ce67ae Convert test protocol into an enum
This gives us better type safety, and will be important as we add more
test methods
2020-04-30 13:54:46 -07:00
Dylan Baker 793c3d706e backends/backends: sort and cleanup imports 2020-04-30 13:35: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
Daniel Mensinger d4449ed613 backend: Fix file name confilcts by using the complete path 2020-04-16 17:54:27 +00:00
Marc-André Lureau a54506fe46 Handle BuildTarget as custom_target() argument #6914 2020-04-11 23:18:43 +03:00
Xavier Claessens 4d7ccd1399 Make werror per subproject option 2020-03-24 22:48:55 +02:00
John Ericson 3a4388e51d Fix legacy env var support with cross
Fix #3969
2020-03-23 17:51:36 +02:00
Dylan Baker 06b1a317d2 Make use of unholder
We have a lot of cases of code like:
```python
if hasattr(var, 'held_object'):
    var = var.held_object`
```

replace that with the unholder function.
2020-03-05 09:58:52 -08:00
Jussi Pakkanen 47759550e5 Add unity block size option. 2020-02-12 22:31:08 +02:00
Xavier Claessens 0bf3c4ac4d backends: Remove unused method 2020-02-06 14:11:24 -05:00
Daniel Mensinger d0c7b51693 mintro: use interpreter data for buildsystem-files (fixes #6390) 2020-01-28 21:18:25 +02:00
Daniel Mensinger 668610c0d2 backend: refactor: set self.interpreter in the constructor 2020-01-28 21:18:25 +02:00
Jussi Pakkanen 9e07f8d8e6 Check for bad timestamps that cause eternal configure loops. 2020-01-27 18:27:20 +02:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Xavier Claessens 212a05b87e Remove duplicated object files in static libraries
When a static library link_whole to a bunch of other static libraries,
we have to extract all their objects recursively. But that could
introduce duplicated objects. ar is dumb enough to allow this without
error, but once the resulting static library is linked into an
executable or shared library, the linker will complain about duplicated
symbols.
2019-10-21 01:08:05 +03:00
Jakub Adam 1bf1782476 Fix *.pdb files missing in meson introspect --installed output
On Windows, make sure the introspect command lists all Program database
(PDB) files containing debugging information that Meson will install.
2019-10-09 15:50:20 +02:00
Dylan Baker f724cc2042 backends: Add needs_exe_wrapper to test serialization
We need to know if the test actually needs an exe wrapper to run or not.
2019-09-28 18:11:06 +03:00
Aleksey Gurtovoy 6ac5db50c9 CUDA support on Windows 2019-09-24 14:22:20 -07:00
David Seifert e19a49b895 Fix static archives stripping (#5905)
* Do not strip static archives

Stripping static archives without more fine-grained options (e.g. `-g`)
leads to failures such as

    ld: libfoo.a: error adding symbols: archive has no index; run ranlib to add one

because GNU strip removes *every* symbol in a static archive by default.
Given that static archives are not final build artifacts (unlike
executables and shared libraries), stripping them gains little and only
causes more edge case failures.

* Gentoo's portage only strips debug information:
  86f211e3a5/bin/estrip (L322)
* Fedora also only strips debug information:
  e9c13c6565/scripts/brp-strip-static-archive (L18)
* Debian also only does some very light stripping:
  72ed1d3261/dh_strip (L374)

Fixes #4138

* Add test case for static archive stripping
2019-09-08 19:48:57 -04:00
Peter Hutterer 4ebce2c3f2 Add test priorities to force test start order 2019-08-24 21:26:41 +03:00
Dylan Baker 110b562930 Vs backend compiler selection (#5448)
* backends/vs: Only set platform_toolset if it isn't already set

* interpreter: set backend up after the compiler

Otherwise we won't be able to check which VS toolchain to use.

* docs/using-visual-studio: wrap lines

* docs: recommend the py launcher instead of python3 for windows

* set backend.environment when building a dummy version

* backends/vs: Add support for clang-cl with vs2017 and vs2019 backends

* backends/vs: Add support for ICL (19.x) with vs2015 and vs2017 backends
2019-08-24 02:32:56 +03:00
Rachel Mant f431cff809 Make .extract_objects() work correctly as an input to custom_target 2019-08-17 21:12:56 +03:00
Paolo Bonzini d34e532020 backends: do not split command and arguments in ExecutableSerialisation
This is not needed anymore, just make a single field with the whole
command line.
2019-07-19 00:17:29 +02:00
Paolo Bonzini b4d313b058 backends: remove unnecessary fields from ExecutableSerialisation
"exe.is_cross and exe.needs_exe_wrapper" is the same condition under which
meson chooses whether to include the exe_wrapper.  meson_exe has an assertion
for that, but now that meson_exe does not need anymore exe.is_cross,
we can simplify the code if we just "trust" meson to do the right thing.

Remove both fields from ExecutableSerialisation and just test the presence
of the wrapper, and also remove the executable basename which is only
used to "beautify" an assertion failure.
2019-07-19 00:17:29 +02:00
Paolo Bonzini ed348b7da8 backends: discover java/mono wrapper at generation time
Move the magic to execute jar and .exe files from "meson --internal exe"
to the backend, so that "ninja -v" shows more clearly what is happening.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-07-19 00:17:29 +02:00
Paolo Bonzini 8239d71025 backends: create ExecutableSerialisation in meson_exe if possible
If meson_exe is only being used to capture the output of the command,
we can skip going through a pickled ExecutableSerialization object.
This makes "ninja -v" output more useful.
2019-07-19 00:17:29 +02:00
Paolo Bonzini 2912f44e9c backends: always serialize custom targets if they need a wrapper 2019-07-19 00:17:29 +02:00