aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
AgeCommit message (Collapse)AuthorFilesLines
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
2022-03-18structured_sources: fix subdir handlingDylan Baker1-9/+5
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-13Merge pull request #9339 from dcbaker/submit/structured_sourcesJussi Pakkanen1-19/+113
Structured Sources
2022-03-07treewide: string-quote the first argument to T.castEli Schwartz1-1/+1
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-07Add support for rust proc-macro cratesDylan Baker1-2/+4
2022-03-07build: plumb structured sources into BuildTargetsDylan Baker1-17/+56
2022-03-07build: Add structured sourcesDylan Baker1-0/+55
2022-03-07build: fix typo in type aliasDylan Baker1-1/+1
The declaration is `EnvInitValueType`, but when it's used it's `EnvValueType`.
2022-03-07build: fix type annotation issueDylan Baker1-1/+1
I noticed by inspection
2022-03-07Merge pull request #10043 from dcbaker/submit/type-checking-for-subprojectJussi Pakkanen1-4/+4
Add typing for subproject()
2022-03-07Fix default install tag for shared lib symlinksXavier Claessens1-6/+8
Versioned shared libraries should have .so file in devel, .so.1 and .so.1.2.3 in runtime. Fixes: #9811
2022-03-03interpreter: annotate the find_program chainDylan Baker1-2/+2
2022-03-03build: Add a couple of type annotations for the Interpreter to useDylan Baker1-2/+2