Commit Graph

617 Commits

Author SHA1 Message Date
Dylan Baker 2c6def856b Revert "build: check for -fno-pic and -fno-pie while we're checking for pic and pie"
This reverts commit 5f02d0d9e1.

Which isn't correct, we have very strange behavior of "force on pie/pic
or let the toolchain do whatever it wants, but you can't turn it off."
2022-06-08 19:18:03 -04:00
Dylan Baker c3ef52311a build: fix types added in CustomTarget.get_target_dependencies
Because everything except ExternalProgram in CustomTarget.sources is a
valid dependency
2022-06-08 23:19:09 +03:00
Dylan Baker c621ab2251 build: Fix type annotations for get_target_dependencies 2022-06-08 23:19:09 +03:00
Dylan Baker 629a9c68e2 build: use inheritance properly for is_internal
Calling `isinstance(self, X)` is an anti-pattern, we should just be using
inheritance for this, letting the `StaticLibrary` override the method, and
having the base class always return `False`.
2022-06-08 23:19:09 +03:00
Dylan Baker f235b814c3 build: Fix annotations for CustomTarget
and fix a bug in the backend that the correct annotations uncover
2022-06-08 23:19:09 +03:00
Dylan Baker d0a0e04c98 build: Store depends in GeneratedList instead of Generator
Since they are actually dependencies out the output not the Generator
itself.

This fixes dependency issues in the ninja backend, allowing Meson to
rebuild more accurately. It also does sometimes in the vs backend, but
there are problems in the vs backend I'm not sure how to solve. The
vsbackend is, itself, so fragile looking I don't want to get too
involved with it.
2022-06-08 23:19:09 +03:00
Dylan Baker c51639b4ff typing: replace ImmutableSetProtocol with typing.AbstractSet
Which does the same thing, but is a builtin and is more accurate
2022-06-08 23:19:09 +03:00
Dylan Baker f84a7d3827 build: move typename to class level in Target subclasses
There's no reason for this to be defined at the instance level (and thus
duplicated into each instance, when it's really a class constant.
2022-06-08 23:19:09 +03:00
Dylan Baker 5f02d0d9e1 build: check for -fno-pic and -fno-pie while we're checking for pic and pie 2022-06-08 23:19:09 +03:00
Dylan Baker a8521fef70 build: use a helper to process set install tags
Which can be shared by BuildTarget
2022-06-08 23:19:09 +03:00
Dylan Baker b53d144794 build: stop overwriting outputs, and replace the intended output
Currently, the code puts a placeholder in for the first output, then
replaces all of the outputs when it generates final value. Instead,
let's only replace the placeholder value.
2022-06-01 22:49:10 -04:00
Dylan Baker 503a061e68 targets: Fix annotations of get_install_dir to be accurate 2022-06-01 22:49:10 -04:00
Eli Schwartz 194c28297f fix incorrectly allowed kwarg for custom_target
override_options makes no sense for custom_target as we don't use it for
anything. Also, this was added in commit c3c30d4b06
despite not being allowed in permittedKwargsc3c30d4b0.

For inexplicable reasons, we had a known_kwargs for custom_target that
looped over kwargs and issued a warning, not an error, for unknown
kwargs. It was impossible to ever hit that check to begin with, though,
ever since commit e08d735105 which added
permittedKwargs and obsoleted those manual checks with real errors.

So at one point override_options was specially permitted to be used
without emitting a warning, and then for about half a decade it was an
error, and then based on some dead code it was allowed again for a bit.
But through all this it doesn't do anything and isn't documented.
2022-05-30 12:26:19 -04:00
Dylan Baker a6df51aa8c build: replace hand rolled code with CustomTarget[Index].links_dynamically()
Which also fixes builds on windows that might produce a .lib instead of
a .a. The error message has been changed to reflect that as well
2022-05-25 22:41:03 -04:00
Dylan Baker bd68e8c613 build: Add a `links_dynamically` method to CustomTarget[Index]
This is useful for cases where we treat CustomTargets as linkable
targets, and need to know whether they're going to link statically or
dynamically.
2022-05-25 22:41:03 -04:00
Dylan Baker 6e36f8f666 build: fix annotations for BuildTarget.link*target
which do not hold BuildTargets, they are `SharedLibrary | StaticLibrary |
CustomTarget | CustomTargetIndex` (whole doesn't accept `SharedLIbrary`)
2022-05-25 22:41:03 -04:00
Eli Schwartz d6e3517e0d
fix regression in reporting errors for invalid gnu_symbol_visibility
In commit fb2cdd0fe2 the internal property
was renamed, but one use case of it in raising a MesonException was not
changed to go with it.

This meant that instead of erroring out with:

```
ERROR: GNU symbol visibility arg XXXX not one of: default, internal, hidden, protected, inlineshidden
```

we instead errored out with:
```
AttributeError: 'SharedLibrary' object has no attribute 'symbol_visibility'
```

Fixes #9659
2022-05-08 14:43:29 -04:00
Xavier Claessens 18bec0d3e3 pkgconfig: Use EnvironmentVariables to build PKG_CONFIG_* env
The new get_env() method that returns an EnvironmentVariables object
will be needed in next commit that will pass it to CustomTarget.

This has the side effect to use the proper os specific path separator
instead of hardcoding `:`. It is the obvious right thing to do here, but
has caused issues in the past. Hopefully issues have been fixed in the
meantime. If not, better deal with fallouts than keep doing the wrong
thing forever.
2022-04-30 15:01:28 -04:00
Ferdinand Thiessen 157d438835 Validate setting of install_tag for CustomTarget 2022-04-27 09:29:38 -04:00
Eli Schwartz 8ae2bf5a9e
allow RunTarget to skip wrapping due to env
Forcing serialization on when writing out the build rule makes very
little sense. It was always "forced" on because we mandated a couple of
environment variables due to legacy reasons.

Add an attribute to RunTarget to say that a given target doesn't *need*
those environment variables, and let ninja optimize them away and run
the command directly if set.
2022-03-31 22:52:31 -04:00
Xavier Claessens 05cfe756f1 Target: Stop passing environment in method args 2022-03-29 16:10:28 -04: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 e33ec88ac7 Pass environment down to base Target class 2022-03-29 16:10:28 -04:00
Xavier Claessens b66a477bbc build.py: Simplify uses_rust()
There is no need to check all source files again, if there are .rs
sources then rust compiler is in self.compilers already.
2022-03-24 12:27:06 -04:00
Xavier Claessens c8c8aeef0f build.py: Simplify validate_sources()
There is no need to go through all sources again, we already did that to
populate self.compilers. When cs or java compilers are in the list, then
there must be only one compiler.

The code was also not considering generate sources any way.
2022-03-24 12:27:06 -04:00
Xavier Claessens f2d21bf8a9 Make compilers list per subproject
Previously subprojects inherited languages already added by main
project, or any previous subproject. This change to have a list of
compilers per interpreters, which means that if a subproject does not
add 'c' language  it won't be able to compile .c files any more, even if
main project added the 'c' language.

This delays processing list of compilers until the interpreter adds the
BuildTarget into its list of targets. That way the interpreter can add
missing languages instead of duplicating that logic into BuildTarget for
the cython case.
2022-03-24 12:27:06 -04:00
Xavier Claessens eccdbfe3d1 Make sure we support "<lang>_args" kwarg for all languages 2022-03-23 15:44:01 -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
Tristan Partin 39f1d52e4a Add ability to add resources to jars
Previously Meson lacked the ability to add resources to jar files.

Fixes #9945
2022-03-22 13:21:26 +02:00
Dylan Baker f9445300b3 structured_sources: fix subdir handling
We currently don't handle subdirectories correctly in
structured_sources, which is problematic. To make this easier to handle
correctly, I've simply changed `structured_sources` to only use Files
and not strings as an implementation detail.
2022-03-18 19:46:24 -07:00
Jussi Pakkanen 69ade4f4cf
Merge pull request #9339 from dcbaker/submit/structured_sources
Structured Sources
2022-03-13 01:01:55 +02:00
Eli Schwartz a009eacc65
treewide: string-quote the first argument to T.cast
Using future annotations, type annotations become strings at runtime and
don't impact performance. This is not possible to do with T.cast though,
because it is a function argument instead of an annotation.

Quote the type argument everywhere in order to have the same effect as
future annotations. This also allows linters to better detect in some
cases that a given import is typing-only.
2022-03-07 19:01:04 -05:00
Dylan Baker c08b6e29d9 Add support for rust proc-macro crates 2022-03-07 18:35:31 -05:00
Dylan Baker 7d1431a060 build: plumb structured sources into BuildTargets 2022-03-07 12:33:33 -08:00
Dylan Baker 39433762a9 build: Add structured sources 2022-03-07 12:33:33 -08:00
Dylan Baker aa03a0c346 build: fix typo in type alias
The declaration is `EnvInitValueType`, but when it's used it's
`EnvValueType`.
2022-03-07 12:33:33 -08:00
Dylan Baker df2a437b5b build: fix type annotation issue
I noticed by inspection
2022-03-07 12:33:33 -08:00
Jussi Pakkanen ade6e3a19e
Merge pull request #10043 from dcbaker/submit/type-checking-for-subproject
Add typing for subproject()
2022-03-07 16:43:44 +02:00
Xavier Claessens 01e92dc543 Fix default install tag for shared lib symlinks
Versioned shared libraries should have .so file in devel, .so.1 and
.so.1.2.3 in runtime.

Fixes: #9811
2022-03-07 09:27:02 -05:00
Dylan Baker bcf924dc7b interpreter: annotate the find_program chain 2022-03-03 10:30:31 -08:00
Dylan Baker b07d4bb206 build: Add a couple of type annotations for the Interpreter to use 2022-03-03 10:29:14 -08:00
Remi Thebault 4fe6f0dd29 add D features to InternalDependency 2022-03-03 08:42:56 -08:00
Dylan Baker b4a512b9f8 build: Add a `__bool__` dunder to ConfigurationData
Which will be used by the `configure_file` method of the interpreter.
2022-03-01 15:17:59 -05:00
Xavier Claessens 6acfe48f32 Allow setting method/separator in environment() and meson.add_devenv() 2022-02-28 09:03:27 -05:00
Xavier Claessens 24f224777d devenv: Add --dump option
It prints all envorinmente variables that have been modified. Can be
used by shell scripts that wish to setup their environment themself.
2022-02-28 09:03:27 -05:00
Tristan Partin 80cb87e7b7 Change jar() default install dir
The previous install dir seemed incorrect when looking at various Linux
distributions.
2022-02-28 11:44:29 +02:00
Eli Schwartz 9daaece785
flake8: fix various whitespace errors with badly aligned code 2022-02-16 23:00:31 -05:00
Eli Schwartz aa0450adda
fix a couple misuses of textwrap.dedent
A backslash-escape of the last newline before a run of whitespace
leading to the indented string ending and function termination `)` does
not actually escape the entire line and make it do nothing. In fact what
it does is cause all that whitespace to be part of the preceding line,
and get printed.

Meanwhile the textwrap.dedent documentation states that lines with only
whitespace get normalized. When you *don't* mess with that final line,
dedent actually does the right thing and makes the output message end
with a single newline after the important text.
2022-02-16 22:59:48 -05:00
Nirbheek Chauhan 2d56ff135e shared module: Allow linking on Android
Android requires shared modules that use symbols from other shared
modules to be linked before they can be dlopen()ed in the correct
order. Not doing so leads to a missing symbol error:
https://github.com/android/ndk/issues/201

We need to always allow linking for this. Also add a soname, although
it's not confirmed that it's needed, and it doesn't really hurt if it
isn't needed.
2022-02-14 23:30:24 -05:00
Eli Schwartz c0b8e02d9f
FeatureNew: add mypy type annotations for subproject arg
Use a derived type when passing `subproject` around, so that mypy knows
it's actually a SubProject, not a str. This means that passing anything
other than a handle to the interpreter state's subproject attribute
becomes a type violation, specifically when the order of the *four*
different str arguments is typoed.
2022-02-14 20:40:41 -05:00