aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
AgeCommit message (Collapse)AuthorFilesLines
2022-09-06Fix install_subdirs not showing up in intro-install_plan.jsonThomas Li1-0/+1
2022-08-29flake8: fix missing importEli Schwartz1-0/+1
This sort of worked, because it was a typing-only import and this file isn't actually tested by mypy yet.
2022-08-24build: don't add targets to link_whole_targets if we took their objectsDylan Baker1-3/+5
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-24build: add a `uses_fortran()` convenience methodDylan Baker1-0/+3
2022-08-24build: Don't attempt to link-whole with rust convenience librariesDylan Baker1-1/+9
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-22introspection: untangle install_plan implemetation, fix a bunch of wrong onesEli Schwartz1-2/+3
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-22fix up some message strings that don't include "setup" in the configure commandEli Schwartz1-1/+1
2022-08-18build: Add a Union alias for all build targetsDylan Baker1-7/+9
2022-08-17build: actually check for targets with no sourcesDylan Baker1-2/+4
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-11add compilers from extracted objects directly to build targetsEli Schwartz1-4/+7
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-04typing: simplify type annotations for librariesEli Schwartz1-1/+2
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-07-06cuda: don't inject `-lstdc++` when linkingDavid Seifert1-1/+10
Fixes: #10570
2022-07-03move various unused typing-only imports into type-checking blocksEli Schwartz1-2/+3
2022-06-16fix regression that broke proper warnings about passing subproject as a depEli Schwartz1-0/+3
Regression in commit 7c757dff71c031ae02ecc358a69a213a5db4051a. 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-16fix crash when passing invalid inputs as build_target dependenciesfxxf1-6/+7
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-14backend: always use the same code to compute the files in ExtractedObjectsPaolo Bonzini1-7/+1
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-14take override_option('unity=...') into account when allowing extract_objects()Paolo Bonzini1-2/+5
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-13flake8: don't use f-strings for strings without formattingEli Schwartz1-1/+1
2022-06-10build: CustomTargetIndex.is_linkable_target misses '.dylib'Sutou Kouhei1-1/+1
CustomTarget.is_linkable_target has '.dylib'. See also 93b1d31af9d90f306aa104eee1e9be8e1ebbacad that added '.dylib' to CustomTarget.is_linkable_target but didn't add '.dylib' to CustomTargetIndex.is_linkable_target.
2022-06-09intro-install_plan: fix destinations for build_targets with custom install_dirEli Schwartz1-2/+3
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-08build: correctly annotate _process_install_tag helperDylan Baker1-1/+1
Which could receive `None | Sequence[Optional[str]]`, but isn't annotated for the `None`
2022-06-08Revert "build: check for -fno-pic and -fno-pie while we're checking for pic ↵Dylan Baker1-5/+2
and pie" This reverts commit 5f02d0d9e164a5bcda072d223eaa5bc92b57747e. 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-08build: fix types added in CustomTarget.get_target_dependenciesDylan Baker1-3/+3
Because everything except ExternalProgram in CustomTarget.sources is a valid dependency
2022-06-08build: Fix type annotations for get_target_dependenciesDylan Baker1-4/+5
2022-06-08build: use inheritance properly for is_internalDylan Baker1-1/+4
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-08build: Fix annotations for CustomTargetDylan Baker1-1/+1
and fix a bug in the backend that the correct annotations uncover
2022-06-08build: Store depends in GeneratedList instead of GeneratorDylan Baker1-2/+2
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-08typing: replace ImmutableSetProtocol with typing.AbstractSetDylan Baker1-4/+4
Which does the same thing, but is a builtin and is more accurate
2022-06-08build: move typename to class level in Target subclassesDylan Baker1-7/+14
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-08build: check for -fno-pic and -fno-pie while we're checking for pic and pieDylan Baker1-2/+5
2022-06-08build: use a helper to process set install tagsDylan Baker1-4/+13
Which can be shared by BuildTarget
2022-06-01build: stop overwriting outputs, and replace the intended outputDylan Baker1-2/+4
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-01targets: Fix annotations of get_install_dir to be accurateDylan Baker1-7/+7
2022-05-30fix incorrectly allowed kwarg for custom_targetEli Schwartz1-3/+0
override_options makes no sense for custom_target as we don't use it for anything. Also, this was added in commit c3c30d4b060239654c9b848092692ab346ebed9d 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 e08d73510552fa4a3a087af1a9e5fded8f5749fd 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-25build: replace hand rolled code with CustomTarget[Index].links_dynamically()Dylan Baker1-2/+2
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-25build: Add a `links_dynamically` method to CustomTarget[Index]Dylan Baker1-0/+20
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-25build: fix annotations for BuildTarget.link*targetDylan Baker1-2/+2
which do not hold BuildTargets, they are `SharedLibrary | StaticLibrary | CustomTarget | CustomTargetIndex` (whole doesn't accept `SharedLIbrary`)
2022-05-08fix regression in reporting errors for invalid gnu_symbol_visibilityEli Schwartz1-1/+1
In commit fb2cdd0fe2797b30e1fd4c118407302402739a3b 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-04-30pkgconfig: Use EnvironmentVariables to build PKG_CONFIG_* envXavier Claessens1-1/+1
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-27Validate setting of install_tag for CustomTargetFerdinand Thiessen1-7/+3
2022-03-31allow RunTarget to skip wrapping due to envEli Schwartz1-1/+3
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-29Target: Stop passing environment in method argsXavier Claessens1-55/+55
2022-03-29Replace backend.get_option_for_target() with target.get_option()Xavier Claessens1-16/+21
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-29Pass environment down to base Target classXavier Claessens1-6/+8
2022-03-24build.py: Simplify uses_rust()Xavier Claessens1-19/+1
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-24build.py: Simplify validate_sources()Xavier Claessens1-15/+3
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-24Make compilers list per subprojectXavier Claessens1-103/+98
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-23Make sure we support "<lang>_args" kwarg for all languagesXavier Claessens1-25/+8
2022-03-22backends: Stop separating base and compiler optionsXavier Claessens1-6/+5
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-22Add ability to add resources to jarsTristan Partin1-2/+6
Previously Meson lacked the ability to add resources to jar files. Fixes #9945