Commit Graph

11411 Commits

Author SHA1 Message Date
Eli Schwartz 6170f1175e python module: produce the correct install path on every OS
The sysconfig paths are, by default, correct for every OS -- they are
supposed to follow the scheme that python knows about per default.

For some reason, this overrode the scheme to posix_prefix, which is the
default for posix OSes like linux and macOS, but wrong on Windows.
Simply deleting this entirely makes everything that used to work, still
work, and a couple new things start working.
2021-08-27 07:46:58 -04:00
Tristan Partin 959e1bb2e3 Add typed_kwargs to add_languages() 2021-08-26 09:51:33 -07:00
Eli Schwartz 1dce556dc2 gnome: don't let fortify defines into the g-ir-scanner after stripping -O
The tool needs to run the preprocessor (but does not actually produce
compiled outputs), and meanwhile ignores lots of flags it doesn't think
it needs. In the case of -D_FORTIFY_SOURCE=...  this is only valid if -O
is there too, but otherwise spits out confusing warnings.

The warnings are spurious and can be safely ignored, but in this case
let's go the extra mile and fix g-ir-scanner's upstream bug by removing
the fortify flag first.

Fixes #9161
2021-08-23 21:01:16 -04:00
Eli Schwartz b3c240989b java module: fix FeatureNew version
It should apply to the *next* stable release.

Reported-by: Tristan Partin <tristan@partin.io>
2021-08-23 12:53:26 -04:00
Xavier Claessens e646130ef1 interpreter: Fix dependency(..., static: true) fallback
It should build the fallback subprject with default_library=static and
override the dependency for both static=True and static kwarg not given.

Fixes: #8050.
2021-08-23 10:52:18 -04:00
Xavier Claessens 0063eb251e python: Workaround broken install path 2021-08-22 22:14:59 -04:00
Eli Schwartz 2a7125928e
use even more informative error message for invoking meson in a subdir
Follow-up on commit 5a7b8d86d0

Sometimes, we find a parent meson.build which is also malformed, and we
shouldn't suggest that maybe the user meant to use that, if it isn't a
valid project() either. Do a rough and dirty check to see if the very
first line is a project() declaration, and if not, don't try to be
clever and suggest using it.

The "invalid source tree" error suffices here, since we're not
absolutely sure meson can be successfully run in that parent directory
and actually advising people about the wrong location is a lot more
confusing than just saying "please figure this out yourself, here is
what to look for".

Granted, we miss cases where project() comes after blank lines and/or
comments, but doing a full AST parse here is excessively overkill and
probably too painful to do, and we don't need to be *that* clever. So
let's be content with merely going above and beyond the call of duty.
2021-08-22 12:12:26 -04:00
Eli Schwartz aad986b4b5
Fix syntax error that broke the website
Regression in commit be92e37837
2021-08-22 12:06:18 -04:00
Tristan Partin be92e37837 Add Java module
The Java module will serve as a source for easing Java development
within Meson. Currently it only supports generating native header files.
2021-08-22 07:57:29 -07:00
Tristan Partin cd9db63bfb Add typing to ModuleState machine members 2021-08-22 07:57:29 -07:00
Tristan Partin 2e7019dd85 Add subscript to subprocess.Popen 2021-08-22 07:57:29 -07:00
Eli Schwartz 0287af461c fix coding errors in unstable-coredata subcommand
One percent-formatted string had a .format() method style placeholder
and thus never output anything other than

TypeError: not all arguments converted during string formatting

The other error may be due to changing format elsewhere, because it
attempted to treat an entire tuple as though it only contained one
element. Based on context, it's clear this is supposed to be the actual
dependency name, but the internal representation may have changed over
time.

These fixes allow the command to run to completion successfully; of
course it is still unstable and possibly not actually maintained, since
it's been broken for 2 years and no one actually noticed.
2021-08-22 13:56:41 +03:00
Eli Schwartz 5a7b8d86d0 use a more informative error message for invoking meson in a subdir
Explicitly mention that the project definition is invalid, and clarify
that project is `project()` -- a function.

Also try to walk the directory tree upward, and if there are parent
meson.build files, just say this isn't the project root, and "maybe you
meant to run meson there instead?"

This won't catch calls to subdir('foo/bar') but we can't be perfect,
only better than before and catch the *majority* of such cases, and
hopefully it's a lot more clear if meson protests that the project is
"invalid, there is no project() function", where the user should look
for a potential solution.

Fixes #3426
2021-08-22 12:49:11 +03:00
Eli Schwartz db04a3f5f2 Fix incomplete guidance on solving sandbox violations
We recommend people use declare_dependency and access it via
dependency() in a parent project. But this requires a wrap file (or to
use override_dependency and an explicit subproject call).

Let's actually mention that.

Fixes #9146
2021-08-22 12:46:57 +03:00
Jussi Pakkanen e69b9c982c Update instructions on installing with Pip. Closes #9034. 2021-08-21 22:34:40 +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 e0ab7290f0 unittests: Ensure that symlink is removed after tests complete
using `TestCase.addCleanup` is both neat and tidy, and also ensures that
the cleanup will be done, even if the test fails.
2021-08-20 21:22:55 +03:00
Jussi Pakkanen 3d98d54fc5
Merge pull request #9012 from dcbaker/submit/qt-custom-targets
Qt module generated sources
2021-08-20 21:09:49 +03:00
Dylan Baker a0e2de02bf run_mypy: add backends/backends 2021-08-20 18:57:19 +02: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 a3c94956c8 compilers: Add get_no_warn_args to the base Compiler class
Because it should be defined there.
2021-08-20 18:57:19 +02:00
Dylan Baker abababfb93 interpreterobjects: fix Test annotations 2021-08-20 18:57:19 +02:00
Dylan Baker 4d6f15b1f1 environment: add annotations and fix get_meson_command
It is theoretically possible for the command to be None so we should
handle that.
2021-08-20 18:57:19 +02:00
Dylan Baker b7ebccd257 environment: add some missing annotations 2021-08-20 18:57:19 +02:00
Dylan Baker c52b454b69 mesonlib: Fix typing of substitute_values
This is really, really, annoying. What we really want is (psuedocode):
```python
class SubValues(TypedDict[str, str], total=False):

    @INPUT@: T.List[str]
    @OUTPUT@: T.List[str]
```

Which would specifiy that `@INPUT@` and `@OUTPUT@` *may* be present and
if they are, then they are lists. There may be additional keys, which
have a single string as a value. Of course there is currently no way to
do that with typing, so we have to instead take a union type and then
use asserts to help the type checker unerstand this.

More info: https://github.com/python/mypy/issues/4617
2021-08-20 18:57:19 +02:00
Dylan Baker 0f5f265a16 mesonlib: Add an exception for what should be unreachable code
It gives us a little more saftey, and makes pylance happy.
2021-08-20 18:57:19 +02:00
Dylan Baker a5c4cf3a3f mesonlib: Fix type annotations
get_compiler_for_source and classify_unity_sources are both wrong, in
that they expect to be given a seqence of strings, but they really
should take a `Sequence[str | File]`.

Additionally, they're using `CompilerType`, which we don't need anymore,
and should stop using, most methods for the Compiler are actually
defined in the base compiler class.
2021-08-20 18:57:19 +02:00
Dylan Baker 3a45c5a7ce build: Add type annotations to Target.get_debug_filename 2021-08-20 18:57:19 +02:00
Dylan Baker e938ffb763 build: Add annotations to the CustomTargetIndex class
These are not complete, and are just enough for backends/backends.py
2021-08-20 18:57:19 +02:00
Dylan Baker c9e827a6a1 build: Add a `name` property to CustomTargetIndex
This is needed to make CustomTargetIndex polymorphic with Target derived
classes, and is used in the build module.
2021-08-20 18:57:19 +02:00
Dylan Baker d754ee1a7f build: Fix CustomTarget initializer annotation
the `output` parameter is a string, not an int.
2021-08-20 18:57:19 +02:00
Dylan Baker e08f896802 build: Add a couple of annotations to RunTarget 2021-08-20 18:57:19 +02:00
Dylan Baker cd7d602f33 build: Add type annotations for CustomTarget
Again, this is not complete and is just enough for backend.py. Again,
typing these is complicated massively by the layering violations in the
Target classes and the interpreter.
2021-08-20 18:57:19 +02:00
Dylan Baker b7d5ecc298 build: type get_import_filenames 2021-08-20 18:57:19 +02:00
Dylan Baker f21c50223b build: Add some type annotations to BuildTarget
This is not complete, it's just enough for backend/backend.py. A more
completely typing would be more difficult, especially whithout
untangling the layering violation between the build targets and the
interpreter.
2021-08-20 18:57:19 +02:00
Dylan Baker 225022abf6 build: Add type annotations for ExtractedObjects 2021-08-20 18:57:19 +02:00