Commit Graph

1250 Commits

Author SHA1 Message Date
Xavier Claessens d2fa6d5080 Make custom_target() name argument optional 2021-09-30 12:26:19 -04:00
Dylan Baker 4f45b5937d ninjabackend: Rust use Backend.generate_basic_compiler_args
Instead of open coding it. This simplifies things, and fixes some
missing functionality
2021-09-24 18:48:48 -07:00
Jussi Pakkanen fee5cb697c
Merge pull request #9167 from dcbaker/submit/meson-main-type-checking
Add type annotations and type checking to meson main
2021-09-24 23:40:52 +03:00
Dylan Baker 68c23a6120 Add option to to transpile Cython to C++
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-24 22:56:46 +03: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
Jussi Pakkanen 524a95fa62
Merge pull request #9274 from anarazel/fix-vs-static-generated
backends/vs: Set ObjectFileName for generated sources.
2021-09-22 20:40:27 +03:00
Ryan Kuester 945f185146 ninjabackend/vs: handle builddir on different drive from cwd
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-20 12:14:06 -07:00
Andres Freund a8370e6d3f backends/vs: Set ObjectFileName for generated sources.
When a static library B to a static library A with generated sources, B
directly references the object file corresponding to the generated source in
A. For that reference in B object_filename_from_source() is used.  But A did
not specify the object file name, ending up with cl.exe's default.

Fixes: #9235
2021-09-20 09:53:49 -07:00
Dylan Baker 40ff02268c backend/ninja: add generated sources to depscan order deps
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-20 01:25:21 -04:00
Xavier Claessens e006e2ee99 Fix ignored install_tag kwarg in install_subdir()
Fixes: #9263
2021-09-16 07:53:18 -04:00
Eli Schwartz 87e13af1c8
apply flake8 fixes for unused imports and missing imports 2021-09-14 15:55:07 -04:00
Eli Schwartz c43bad2369
fix untested codepath? add:item() is surely a typo, not a real function 2021-09-14 15:50:29 -04:00
Andres Freund fddf88ba08 backends/vs: Do not emit dummy command for alias_command().
Alias commands did not work with the vs backend, due to trying to access
target.command[0] with an empty command. Fix this by just not emitting a
CustomBuild node for alias targets - the project references are enough to
trigger the necessary actions.

Fixes: #9247
2021-09-14 13:38:04 -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 b60bd0e299 pyllint: enable consider-user-enumerate
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-31 16:28:54 -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
Dylan Baker 278942a447 pylint: enable consider-iterating-dictionary
This didn't actually catch what it's supposed to, which is cases of:
```python
for x in dict.keys():
    y = dict[x]
```
But it did catch one unnecessary use of keys(), and one case where we
were doing something in an inefficient way. I've rewritten:
```python
if name.value in [x.value for x in self.kwargs.keys() if isinstance(x, IdNode)]:
```
as
``python
if any((isinstance(x, IdNode) and name.value == x.value) for x in self.kwargs):
```
Which avoids doing two iterations, one to build the list, and a
second to do a search for name.value in said list, which does a single
short circuiting walk, as any returns as soon as one check returns True.
2021-08-31 16:28:54 -04:00
Jussi Pakkanen e83ab50c06 Delete old outputs that are no longer in the Ninja file. 2021-08-28 12:42:58 +03:00
Jussi Pakkanen 3f380b8e1d Fix duplicated frameworks in the Xcode backend. 2021-08-21 22:33:47 +03:00
Jussi Pakkanen 85d102bc6e Fix multiple generators in target in Xcode. 2021-08-21 22:33:47 +03:00
Jussi Pakkanen 267d5385d4 Path special casing for the Xcode backend. 2021-08-21 22:33:47 +03:00
Jussi Pakkanen 12e7b3afcf Handle .C extension in Xcode. 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 b2684a9887 backends/xcode: remove unused compiler parameter from escape_extra_args 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 2a70c039bf ninjabackend: add missing type annotation
I needed to figure this out for the purposes of annotating CleanTrees
anyway.
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
Dylan Baker adddb9af21 backends/vs: add a missing annotation 2021-08-20 18:57:19 +02:00
Dylan Baker 035df5369e backends/ninja: write depscan input files to json
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-18 11:58:45 -07:00
Nirbheek Chauhan d6243e3ebd rust targets: lld-link is the same as link for static libs
Without this, rustc will fail to find libfoo.a; same as with MSVC.
2021-08-17 19:58:23 -07:00
Xavier Claessens 8c5aa031b5 Add install tags
Fixes: #7007.
2021-08-17 15:19:18 -04:00
Jussi Pakkanen f0b16e4e83 Refresh Ninja cache files on regeneration. 2021-08-15 21:42:19 +03:00
Eli Schwartz 59d4f771d2
editorconfig: add setting to trim trailing whitespace
and clean up all outstanding issues

Skip 'test cases/common/141 special characters/meson.build' since it
intentionally uses trailing newlines.
2021-08-15 09:36:18 -04:00
Jussi Pakkanen f9d9cb174a Always generate Java rule, it is platform agnostic. 2021-08-11 21:54:54 +03:00
GustavoLCR 6a1157b2e5 Fix native targets for vs backend cross compilation 2021-08-09 11:27:10 -07:00
Dylan Baker 630a41eb81 ninjabackend: use get_subdir() instead of subdir attribute for cython
As this works correctly for CustomTarget, CustomTargetIndex, and
GeneratedList, but .subdir doesn't work for CustomTargetIndex.
2021-08-03 14:03:33 -07:00
Weston Schmidt 2e30b5a1e2 Add support for gcovr --sonarqube report
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-23 22:15:00 +03:00
Paolo Bonzini 3efed376c3 linkers: remove is_shared_module argument to get_soname_args
The argument is now unused, drop it.
2021-07-14 22:53:04 +02:00
Paolo Bonzini d5535065bc do not add SONAME to shared modules
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-14 22:53:04 +02:00
Eli Schwartz dd31891c1f more f-strings too complex to be caught by pyupgrade 2021-07-05 17:55:04 +03:00
Dylan Baker 210065ffe8 backends/ninja: only pass project specific arguments to scan-build
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
2021-07-02 17:18:02 +03:00
Simon Ser 1f3adc4dbe Add feed arg to custom_target() 2021-06-29 20:54:13 +03:00