Commit Graph

745 Commits

Author SHA1 Message Date
Xavier Claessens 1fef03c0f0 build: dependencies should come after link_with on link command
This fixes regression caused by
3162b901ca
that changes the order in which libraries are put on the link command.

In addition, that commit was wrong because libraries from dependencies
were processed before process_compiler() is called, which that commit
wanted to avoid.
2023-07-10 23:12:24 +03:00
Xavier Claessens cd63853ad2 build: Fix linking multiple libraries and some are promoted
When a link() is promoted to link_whole() we still have to handle the
rest of the list.

Fixes: #11956
2023-07-10 23:12:24 +03:00
Dylan Baker 8369dbbfec build: use self.compilers instead of all_compilers for stdlib langs
We need a union of the compilers used by the target, and by those used
by all dependencies, not all the compilers in all projects. We do,
however, need to look compilers up from all possible compilers, as a
dependency that is a subproject could use a language not present in the
current project.
2023-07-05 07:17:26 -04:00
Jussi Pakkanen d391e5281c
Merge pull request #11742 from xclaesse/link-whole-cases
Fix niche cases when linking static libs
2023-07-05 01:10:58 +03:00
Dylan Baker 772cb92624 rust: get stdlib arguments for non-rust languages when linking
Otherwise we might not get things like libstdc++, which we need.
2023-06-27 11:53:18 -07:00
Eli Schwartz a1ef957e34
linkers: delay implementations import until detect is run
This saves on a 1500-line import at startup and may be skipped entirely
if no compiled languages are used. In exchange, we move the
implementation to a new file that is imported instead.

Followup to commit ab20eb5bbc.
2023-06-26 13:10:33 -04:00
Xavier Claessens 6c480085d5 rust: PIC is always enabled
rustc enables PIC by default and Meson currently has no way to force
disabling PIC, it can only force enable or use compiler's default.
2023-06-07 13:18:58 -04:00
Volker Weißmann 12a2dc86ca Allow generator.process(generator.process(...))
Fixes #1141
2023-05-21 22:12:57 +03:00
Xavier Claessens c6db870fc7 rust: Add system libs used by rust std to staticlib external deps 2023-05-20 10:35:42 -04:00
Xavier Claessens ff86e799a4 extract_all_objects: Include PCH object with MSVC
This changes the object file name with ninja backend to match the
name used by vs backend and add it in outputs of the ninja rule.
2023-05-01 12:57:45 -04:00
Xavier Claessens 25f4f77a3b Rust: Allow Rust static libraries to link_whole other libraries
Rustc can do it without needing Meson to extract all objects.
2023-05-01 12:57:45 -04:00
Xavier Claessens 3162b901ca build: Process compilers before calling link() and link_whole()
To take good decisions we'll need to know if we are a Rust library which
is only know after processing source files and compilers.

Note that is it not the final list of compilers, some can be added in
process_compilers_late(), but those are compilers for which we don't
have source files any way.
2023-05-01 12:57:45 -04:00
Xavier Claessens 01949df4f6 build: Don't do a deep copy of kwargs
It seems to only be used by the Rust module now, and it already does a
copy.
2023-05-01 12:57:45 -04:00
Xavier Claessens 2dadc3ae5b Rust: C static library cannot link_whole Rust static library 2023-05-01 12:57:45 -04:00
Xavier Claessens a78af23686 Fix niche cases when linking static libs
Case 1:
- Prog links to static lib A
- A link_whole to static lib B
- B link to static lib C
- Prog dependencies should be A and C but not B which is already
  included in A.

Case 2:
- Same as case 1, but with A being installed.
- To be useful, A must also include all objects from C that is not
  installed.
- Prog only need to link on A.
2023-05-01 12:57:45 -04:00
Nomura 18cfa545f0 Initial support for Metrowerks C/C++ compiler 2023-04-24 09:07:37 -04:00
Sebastian Dröge 01420bf8fc rust: Add new `rust_dependency_map` target configuration
This allows changing the crate name with which a library ends up being
available inside the Rust code, similar to cargo's dependency renaming
feature or `extern crate foo as bar` inside Rust code.
2023-04-21 15:35:06 -04:00
Charles Brunet fbab1488ae extra_files keyword in declare_dependency() 2023-04-20 18:31:39 +03:00
Sebastian Dröge e2c454b86e rust: Also disallow `.` in Rust library target names 2023-04-20 13:53:26 +05:30
Sebastian Dröge 3c9817fe7f rust: Don't allow spaces/dashes in Rust library names
The library names are directly mapped to filenames by meson while the
crate name gets spaces/dashes replaced by underscores. This works fine
to a certain degree except that rustc expects a certain filename scheme
for rlibs that matches the crate name.

When using such a library as a dependency of a dependency compilation
will fail with a confusing error message.

See https://github.com/rust-lang/rust/issues/110460
2023-04-20 13:53:26 +05:30
Daniele Nicolodi 285e0d3c59 mbuild: .pdb files are created only when debug symbols are enabled
This is the same fix as the one in #10800 for shared libraries but
applied to executables instead.
2023-04-14 16:20:23 -04:00
Josh Soref cf9fd56bc9 fix various spelling issues
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11 19:21:05 -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
Xavier Claessens b30cd5d2d5 Make --vsenv a readonly builtin option
We need to remember its value when reconfiguring, but the Build object
is not reused, only coredata is.

This also makes CLI more consistent by allowing `-Dvsenv=true` syntax.

Fixes: #11309
2023-03-29 09:33:41 -04:00
Xavier Claessens 65c22d8c38 custom_target: libfoo.so.1 is linkable 2023-03-27 15:19:17 -04:00
Xavier Claessens 72cd2a395a coredata: Do not pickle it twice
Exclude coredata from build.dat because it gets pickled separately
already.
2023-03-16 21:02:23 -04:00
Charles Brunet ef5da765af add typename to AliasTarget
It will allow to distinguish AliasTarget from RunTarget in introspection
files (e.g. meson-info/intro-targets.json).
2023-03-14 22:03:46 -04:00
Charles Brunet 90b6d6dafb rewriter: fix warning about empty sources 2023-03-14 16:22:05 +02:00
Dylan Baker 162ac25beb build: fully type CompileTarget
Which is pretty trivial
2023-03-09 15:03:03 -05:00
Dylan Baker a769a0de35 build: Add some missing annotations to BuildTarget initializer 2023-03-09 15:03:03 -05:00
Dylan Baker 6dc96e7266 build: move all Target attributes to dataclass
We'll want to be able to pass all of these to the initializer, so make
them all available.
2023-03-09 15:03:03 -05:00
Dylan Baker 06453ed7a4 build: Add missing annotation to Target method 2023-03-09 15:03:03 -05:00
Dylan Baker 4cf5ad2463 build: make Target an abstract properties instead of doing hasattr
checks
2023-03-09 15:03:03 -05:00
Dylan Baker 019fda91d0 vala: don't build .h, .vala, and .gir if export_dynamic is False
The current check results in *any* value to `export_dynamic` generating
vala import targets, even `false`. This is pretty clearly wrong, as it
really wants to treat an unset export_dynamic as false.
2023-02-19 02:59:56 +05:30
Xavier Claessens c2a55bfe43 preprocess: Allow custom_tgt, custom_idx and generated_list
It was documented to be supported but only File and str were actually
working.
2023-02-15 15:12:34 -05:00
Dylan Baker e268d9f137 build: Add a found method to Executable
Again, this is necessary for polymorphism with ExternalProgram
2023-01-10 09:53:22 -08:00
Dylan Baker 1f90873844 build: Add a get_path method to Executable
This is needed to make Executable Polymorphic with ExternalProgram. This
can happen when a build program overrides a lookup.
2023-01-10 09:53:22 -08:00
Paolo Bonzini b3fc3cd6b5 add objects keyword argument to declare_dependencies 2023-01-04 09:44:32 -08:00
Paolo Bonzini 8d2940024b allow passing generated objects in the "objects" keyword argument
Generated objects can already be passed in the "objects" keyword argument
as long as you go through an extract_objects() indirection.  Allow the
same even directly, since that is more intuitive than having to add them
to "sources".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-01-04 09:44:32 -08:00
Eli Schwartz 2fa0749175
add license_files kwarg to project
Hook this up to installed dependency manifests. This is often needed
above and beyond just an SPDX string -- e.g. many licenses have custom
copyright lines.
2022-12-27 20:29:46 -05:00
Eli Schwartz 100456de07
fix broken fs.copyfile function that crashed if you tried to use it
At least, if you tried to use it when passing an install_dir. Because
T.Sequence is horrible and we should never use it, and the annotations
are a lie that produces bugs.

So, fix the annotations on CustomTarget to never allow this to happen
again, and also fix the function too. Move some definitions elsewhere
inline to satisfy the linter.

Fixes #11157
2022-12-11 18:28:39 -05:00
Eli Schwartz cbf4496434
simplify install_tag handling according to the accepted API
There are two problems here: a typing problem, and an algorithm problem.

We expect it to always be passed to CustomTarget() as a list, but we ran
list() on it, which became horribly mangled if you violated the types
and passed a string instead. This caused weird*er* errors and didn't
even do anything. We want to do all validation in the interpreter,
anyway, and make the build level dumb.

Meanwhile we type it as accepting a T.Sequence, which technically
permits... a string, actually. This isn't intentional; the point of
using T.Sequence is out of a misguided idea that APIs are supposed to be
"technically correct" by allowing "anything that fulfills an interface",
which is a flawed concept because we aren't using interfaces here, and
also because "technically string fulfills the same interface as a list,
if we're talking sequences".

Basically:
- mypy is broken by design, because it typechecks "python", not "what we
  wish python to be"
- we do not actually need to graciously permit passing tuples instead of
  lists

As far as historic implementations of this logic go, we have formerly:
- originally, typeslistified anything
- switched to accepting list from the interpreter, redundantly ran list()
  on the list we got, and mishandling API violations passing a string
  (commit 11f9638035)
- switched to accepting anything, stringlistifying it if it was not
  `None`, mishandling `[None]`, and invoking list(x) on a brand new list
  from stringlistify (commit 157d438835)
- stopped stringlistify, just accept T.List[str | None] and re-cast to
  list, violates typing because we use/handle plain None too
  (commit a8521fef70)
- break typing by declaring we accept a simple string, which still
  results in mishandling by converting 'foo' -> ['f', 'o', 'o']
  (commit ac576530c4)

All of this. ALL of it. Is because we tried to be fancy and say we
accept T.Tuple; the only version of this logic that has ever worked
correctly is the original untyped do-all-validation-in-the-build-phase
typeslistified version.

Let's just call it what it is. We want a list | None, and we handle it too.
2022-12-11 18:28:38 -05:00
Eli Schwartz 9e8a3b9cbd when generating optional utility targets in ninja, skip existing aliases too
When auto-generating e.g. a `clang-format` target, we first check to see
if the user has already defined one, and if so we don't bother creating
our own. We check for two things:

- if a ninja target already exists, skip
- if a run_target was defined, skip

The second check is *obviously* a duplicate of the first check. But the
first check never actually worked, because all_outputs was only
generated *after* generating all utility rules and actually writing out
the build.ninja file. The check itself compares against nothing, and
always evaluates to false no matter what.

Fix this by reordering the target creation logic so we track outputs
immediately, but only error about them later. Now, we no longer need to
special-case run_target at all, so we can drop that whole logic from
build.py and interpreter.py, and simplify the tracked state.

Fixes defining an `alias_target()` for a utility, which tried to
auto-generate another rule and errored out. Also fixes doing the same
thing with a `custom_target()` although I cannot imagine why anyone
would want to produce an output file named `clang-format` (unless clang
itself decided to migrate to Meson, which would be cool but feels
unlikely).
2022-12-05 12:33:17 -08:00
Dylan Baker 2d349eae8c
pylint: enable the set_membership plugin
Which adds the `use-set-for-membership` check. It's generally faster in
python to use a set with the `in` keyword, because it's a hash check
instead of a linear walk, this is especially true with strings, where
it's actually O(n^2), one loop over the container, and an inner loop of
the strings (as string comparison works by checking that `a[n] == b[n]`,
in a loop).

Also, I'm tired of complaining about this in reviews, let the tools do
it for me :)
2022-11-30 16:23:29 -05:00
Dylan Baker 67da2ad0fb
pylint: enable simplifiable-if-statement 2022-11-30 07:01:22 -05:00
David Robillard e85138fcc8 Fix various spelling errors
Found with codespell.
2022-11-24 15:17:23 -05:00
Dylan Baker e45367169f build: fix annotations of BuildTarget derived classes
Which thinks `sources` should be `List[File]`, but they should be
`List[SourceOutputs]`
2022-11-17 19:07:15 -05:00
Eli Schwartz 0d3be23377 build: use the unified pickle loader to handle more edge cases
We have divergent implementations of loading a pickled *.dat file. The
Build class loader has a better error message. But the generic loader
handles TypeError and ModuleNotFoundError. Merge the implementations,
and use it for Build as well.

Fixes #11051
2022-11-17 12:56:04 -08:00
Eli Schwartz 4533dfc279
Revert "build: don't add targets to link_whole_targets if we took their objects"
This reverts commit c94c492089.

This broke propagated deps as well as PCH in MSVC, and has not been
fixed in time for the final release of 0.64.0, so it needs to be
reverted and then brought back later.

Fixes #10745
Fixes #10975
2022-10-31 23:22:07 -04:00
Xavier Claessens 01ee141339 Add NASM compiler 2022-10-24 11:06:57 +02:00
Jussi Pakkanen 4c2b64188d
Merge pull request #10916 from xclaesse/preprocess
Add cc.preprocess() method
2022-10-23 17:24:46 +03:00
Xavier Claessens 65590e6e4b Add cc.preprocess() method for c-like compilers
This introduce a new type of BuildTarget: CompileTarget. From ninja
backend POV it is the same thing as any other build target, except that
it skips the final link step. It could be used in the future for
transpilers too.
2022-10-23 12:21:46 +02:00
Thomas Li 2761131ff9 BUG: Don't add debug files as targets when not building in debug mode 2022-10-19 11:32:25 -04:00
Dylan Baker df1b95cf2b
pylint: enable consider-merging-isinstance 2022-10-04 00:33:14 -04:00
Xavier Claessens 2dfd952eb9 Move classes used by scripts to their own module
Those classes are used by wrapper scripts and we should not have to
import the rest of mesonlib, build.py, and all their dependencies for
that.

This renames mesonlib/ directory to utils/ and add a mesonlib.py module
that imports everything from utils/ to not have to change `import
mesonlib` everywhere. It allows to import utils.core without importing
the rest of mesonlib.
2022-09-28 19:36:13 -04:00
Xavier Claessens e1db50d4d9 compilers: Cleanup a bit languages/suffixes lists
Use set where order does not matter, fix is_source() to really mean only
source suffixes.
2022-09-27 11:15:07 -04:00
Dylan Baker 6f7ea0cc28 pylint: enable use-sequence-for-iteration
This found a couple of places where we *don't* want to use set(), and
want to use list() instead.
2022-09-19 20:57:52 -04:00
Thomas Li a4d5442207 Fix install_subdirs not showing up in intro-install_plan.json 2022-09-06 02:09:38 -04:00
Eli Schwartz af28826c24 flake8: fix missing import
This sort of worked, because it was a typing-only import and this file
isn't actually tested by mypy yet.
2022-08-29 23:32:43 +03:00
Dylan Baker c94c492089 build: don't add targets to link_whole_targets if we took their objects
What happens is this:
 - liba is a convenience static library
 - libb is an installed static library
 - libb links in liba with --link-whole
 - libc links to libb
 - we generate a link line with libb *and* liba, even though libb is a
   strict superset of liba

This is a bug that has existed since the we stopped using link-whole to
combine convenience libraries, and to instead propagate their
dependencies up. For most linkers this is harmless, if inefficient.
However, for apple's ld64 with the addition calling `ranlib -c`, this
ends up causing multiple copies of symbols to clash (I think that other
linkers recognize that these symbols are the same and combine them), and
linking to fail.

The fix is to stop adding libraries to a target's `link_whole_targets`
when we take its objects instead. This is an all around win since it
fixes this bug, shortens linker command lines, and avoids opening
archives that no new symbols will be found in anyway.
2022-08-24 22:50:35 -04:00
Dylan Baker a044f42308 build: add a `uses_fortran()` convenience method 2022-08-24 22:50:35 -04:00
Dylan Baker 741de25462 build: Don't attempt to link-whole with rust convenience libraries
There are two distinct cases here that need to be considered. The first
issue is https://github.com/mesonbuild/meson/issues/10723 and
https://github.com/mesonbuild/meson/issues/10724, which means that Meson
can't actually generate link-whole arguments with rust targets. The
second is that rlibs are never valid candidates for link-whole anyway.
The promotion happens to work because of another bug in the promotion
path (which is fixed in the next commit).
2022-08-24 22:50:35 -04:00
Eli Schwartz 3e73d4d77d
introspection: untangle install_plan implemetation, fix a bunch of wrong ones
Generally plumb through the values of get_option() passed to
install_dir, and use this to establish the install plan name. Fixes
several odd cases, such as:

- {datadir} being prepended to "share" or "include"

- dissociating custom install directories and writing them out as
  {prefix}/share/foo or {prefix}/lib/python3.10/site-packages

This is the second half of #9478
Fixes #10601
2022-08-22 14:15:22 -04:00
Eli Schwartz d395b1a768
fix up some message strings that don't include "setup" in the configure command 2022-08-22 00:23:14 -04:00
Dylan Baker 394f734b1d build: Add a Union alias for all build targets 2022-08-18 21:57:36 -04:00
Dylan Baker 5ca5e0c900 build: actually check for targets with no sources
Do to a bug in which a method, rather than an attribute, was checked
we would never detect that a target had no sources, even though we meant
to. As a result we would never actually error out when a target has no
sources. When fixing the check, I've changed the error to a warning
so that existing projects will continue to build without errors, only
warnings.
2022-08-17 13:44:08 -07:00
Eli Schwartz 00f8ced048
add compilers from extracted objects directly to build targets
In order to reliably link to static libraries or individual object
files, we need to take their languages into account as well. For static
libraries this is easy: we just add the static library's list of
compilers to the build target. For extracted objects, we need to only
add the ones for the objects we use.

But we did this really inefficiently -- in fact, downright terribly. We
iterated over all source files from the extracted objects, then tried to
look up a new compiler for them. Even though the extracted objects
already had a list of compilers! This broke once compilers were made
per-subproject, because while the extracted objects have a reference to
all the compilers it needs (just like static archives do, actually) we
might not actually be able to look up that compiler from scratch inside
the current subproject.

Fix this by asking the extracted objects to categorize all its own
sources and return the compilers we want.

Fixes #10579
2022-08-11 07:12:55 -04:00
Eli Schwartz 37f95303f0
typing: simplify type annotations for libraries
In a bunch of places we need to list various types of libraries
including custom_target outputs, and it gets very long. Use a common
T.Union for this.
2022-08-04 20:06:01 -04:00
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