Commit Graph

627 Commits

Author SHA1 Message Date
David Seifert 11f76c2fc7 cuda: don't inject `-lstdc++` when linking
Fixes: #10570
2022-07-06 14:33:58 -07:00
Eli Schwartz 0703ee0aef
move various unused typing-only imports into type-checking blocks 2022-07-03 14:11:31 -04:00
Eli Schwartz b87067dc8b
fix regression that broke proper warnings about passing subproject as a dep
Regression in commit 7c757dff71.
SubprojectHolder is no longer an ObjectHolder and says so via a TODO:
this means that we have to fiddle with held_object. Yay.
2022-06-16 21:19:06 -04:00
fxxf b7159f4a1a
fix crash when passing invalid inputs as build_target dependencies
The `add_deps` function did not behave correctly when a specified
dependency is not an instance of `dependencies.Dependency`.

Reorder the logic flow to perform this validation first.

Fixes #10468
2022-06-16 21:15:27 -04: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
Paolo Bonzini dae986073d take override_option('unity=...') into account when allowing extract_objects()
A single target could be picked for unity build, and in that case
extract_objects() should not be allowed.

Likewise for the opposite case, where extract_objects() should be allowed
if unity build is disabled for a single target.  A test that covers that
case is added later.
2022-06-14 10:11:22 -07:00
Eli Schwartz 85f3fc2022 flake8: don't use f-strings for strings without formatting 2022-06-13 13:34:39 +03:00
Sutou Kouhei f6e7cc070e build: CustomTargetIndex.is_linkable_target misses '.dylib'
CustomTarget.is_linkable_target has '.dylib'.

See also 93b1d31af9 that added '.dylib'
to CustomTarget.is_linkable_target but didn't add '.dylib' to
CustomTargetIndex.is_linkable_target.
2022-06-10 02:48:41 -04:00
Eli Schwartz c151988b39
intro-install_plan: fix destinations for build_targets with custom install_dir
There are a couple issues that combine to make the current handling a
bit confusing.

- we call it "install_dir_name" but it is only ever the class default

- CustomTarget always has it set to None, and then we check if it is
  None then create a different variable with a safe fallback. The if is
  useless -- it cannot fail, but if it did we'd get an undefined
  variable error when we tried to use `dir_name`

Remove the special handling for CustomTarget. Instead, just always
accept None as a possible value of outdir_name when constructing install
data, and, if it is None, fall back to {prefix}/outdir regardless of
what type it used to be.
2022-06-09 20:37:26 -04:00
Dylan Baker ac576530c4 build: correctly annotate _process_install_tag helper
Which could receive `None | Sequence[Optional[str]]`, but isn't
annotated for the `None`
2022-06-08 19:18:03 -04:00
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