Commit Graph

155 Commits

Author SHA1 Message Date
Eli Schwartz 50921263bd
delete dead code that has never been referenced 2023-06-20 16:24:45 -04:00
Eli Schwartz a981433705
backends/xcode: various sundry low-effort typing fixes
I slapped the obvious type annotations onto a bunch of places, and got
the errors down from 668 to 112.
2023-06-20 16:24:45 -04:00
HiPhish 439a61affa Change "can not" to "cannot" throughout project
The word "cannot" expresses inability to do something whereas "can not"
expresses the ability to refrain from doing something.
2023-04-11 17:10:01 +03:00
Dylan Baker 4a014d1724 Add support for meson.options as a replacement for meson_options.txt
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
2023-03-28 15:01:10 +03:00
Eli Schwartz b4c347674b
backends: simplify class setup 2023-03-20 16:58:15 -04:00
Dylan Baker 6aeec80836 backends: Stop passing generator exes to ExecutableSerialisation as strings
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
2023-01-10 13:02:07 -08:00
Dylan Baker d5e899c768
pylint: enable the bad_builtin checker
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
2022-11-29 23:26:05 -05:00
Jan Tojnar a590cfde0c compilers: Add optimization=plain option
https://github.com/mesonbuild/meson/pull/9287 changed the `optimization=0`
to pass `-O0` to the compiler. This change is reasonable by itself
but unfortunately, it breaks `buildtype=plain`, which promises
that “no extra build flags are used”.

`buildtype=plain` is important for distros like NixOS,
which manage compiler flags for optimization and hardening
themselves.

Let’s introduce a new optimization level that does nothing
and set it as the default for `buildtype=plain`.
2022-10-09 14:43:18 +03:00
Paolo Bonzini e4a8f4dbd6 backend: always use the same code to compute the files in ExtractedObjects
Instead of asking the ExtractedObjects, but with a hook back into the backend,
use the existing function in the backend itself.  This fixes using the
extract_objects(...) of a generated source file in a custom_target.

It should also fix recursive extract_all_objects with the Xcode backend.

Fixes: #10394
2022-06-14 10:11:22 -07:00
Eli Schwartz a49cd00d64 treewide: various cleanups to move imports for mypy into typechecking blocks
Along the way, add __future__ annotations where lacking.
2022-06-10 09:15:48 -04:00
Jussi Pakkanen a7356f6bf2 Handle same Framework multiple times in Xcode. 2022-03-31 21:30:16 -04:00
Jussi Pakkanen 6f24ab9407 Handle feed and capture in xcodebackend. 2022-03-31 21:30:16 -04:00
Jussi Pakkanen be63e77949 Fix typos in Xcode backend. 2022-03-30 22:32:55 +03:00
Xavier Claessens 90310116ab Replace backend.get_option_for_target() with target.get_option()
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-29 16:10:28 -04:00
Xavier Claessens 86aaac8e42 backends: Stop separating base and compiler options
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-22 17:20:48 -04:00
Eli Schwartz a28d546795 flake8: fix wonky comment style 2022-01-27 10:48:01 -08:00
Eli Schwartz 8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Eli Schwartz 4ab70c5512
fix extra whitespace
discovered via flake8 --select E303
2021-10-04 16:29:31 -04:00
Eli Schwartz 5a8e066c56
remove useless variables that are no longer or were never used 2021-10-04 16:29:31 -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
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 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 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
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
Eli Schwartz dd31891c1f more f-strings too complex to be caught by pyupgrade 2021-07-05 17:55:04 +03:00
Eli Schwartz 48ebfa9a99
another pyupgrade pass 2021-06-07 16:51:47 -04:00
Jussi Pakkanen 43f0aa17b7 Add swift executable support in Xcode. 2021-05-23 17:59:14 +01:00
Jussi Pakkanen e23fd086bf Remove unnecessary hierarchical layer. 2021-05-23 13:28:25 +03:00
Jussi Pakkanen b84265052e Remove top level sources entry as unnecessary. 2021-05-23 13:28:25 +03:00
Jussi Pakkanen 7ceba6388c Add meson.build files to pbxgroup. 2021-05-23 13:28:25 +03:00
Jussi Pakkanen 818685ec18 Write project info in a tree structure rather than the current flat one. 2021-05-23 13:28:25 +03:00
Jussi Pakkanen 53f6ef3b7b Xcode: fix project cleaning. 2021-04-29 21:12:11 +01:00
Jussi Pakkanen 1a31882f59 Xcode: make Swift projects work. 2021-04-25 15:35:13 +03:00
Jussi Pakkanen 1cd80985b4 Xcode: add objective C++ flags to plain C++ because Xcode requires it. 2021-04-25 15:35:13 +03:00
Jussi Pakkanen 0e4c358f35 Xcode: add objective C flags to plain C because Xcode requires it. 2021-04-25 15:35:13 +03:00
Jussi Pakkanen aa2a153afb Xcode: fix linking to customtargetindex objects. 2021-04-24 19:41:27 +03:00
Jussi Pakkanen 22d0e6dd55 Xcode: even more command line argument expansion. 2021-04-23 23:03:26 +03:00
Jussi Pakkanen 0785ec3317 Xcode: Quote McQuoteface. 2021-04-23 23:03:26 +03:00
Jussi Pakkanen ee2363dbb7 Xcode: handle CustomTargetIndexes. 2021-04-23 17:29:29 +03:00
Jussi Pakkanen 2a341dd4ec Xcode: ever more quoting. 2021-04-23 17:29:29 +03:00
Jussi Pakkanen 7fba94997f Xcode: only add source and build dirs if implicit_include_directories is set. 2021-04-23 17:29:29 +03:00
Jussi Pakkanen bff85e2a6c Xcode: do not link shared modules against executables. 2021-04-22 16:53:43 +03:00
Jussi Pakkanen 40fb466513 Xcode: add missing quote character. 2021-04-22 16:53:43 +03:00
Jussi Pakkanen 965f7e18fa Xcode: fix shell quotings. 2021-04-22 16:53:43 +03:00
Jussi Pakkanen 4881c2cf98 Xcode: skip link language override test. 2021-04-22 16:53:43 +03:00