Commit Graph

424 Commits

Author SHA1 Message Date
Jussi Pakkanen 44ff3e6c7d
Merge pull request #6736 from dcbaker/mesonlib-type-annotations
Mesonlib type annotations
2020-03-08 14:49:23 +02:00
Xavier Claessens 8edc6d655d Improve logged messages for overriden dependencies 2020-03-06 15:26:02 -05:00
Xavier Claessens 2fdedc4d0f Add meson.override_dependency()
Similar to meson.override_find_program() but overrides the result of the
dependency() function.

Also ensure that dependency() always returns the same result when
looking for the same dependency, this fixes cases where parts of the
project could be using a system library and other parts use the library
provided by a subproject.
2020-03-06 15:25:46 -05:00
Dylan Baker 06b1a317d2 Make use of unholder
We have a lot of cases of code like:
```python
if hasattr(var, 'held_object'):
    var = var.held_object`
```

replace that with the unholder function.
2020-03-05 09:58:52 -08:00
Dylan Baker 581d69a8d3 remove ability to pass multiple keys to extract_as_list
This makes the typing annotations basically impossible to get right, but
if we only have one key then it's easy. Fortunately python provides
comprehensions, so we don't even need the ability to pass multiple keys,
we can just [extract_as_list(kwargs, c) for c in ('a', 'b', 'c')] and
get the same result.
2020-03-05 09:58:52 -08:00
Dylan Baker a8293dd59c mesonlib: Replace unholder argument to listify
listify shouldn't be unholdering, it's a function to turn scalar values
into lists, or flatten lists. Having a separate function is clearer,
easier to understand, and can be run recursively if necessary.
2020-03-05 09:31:29 -08:00
Dylan Baker 1a82880730 mesonbuild/mesonlib: Add type annotations 2020-03-05 09:31:29 -08:00
Michael Brockus 98ddd52ced
Cherry-picking - (rm python2 % add python3 .format) (#6725) 2020-03-03 21:45:43 +02:00
ur4t 9787de59d4 Fixed linker detecting on windows. Added comments about linker detecting for further debugging and refactoring. 2020-02-29 00:43:00 +02:00
Jon Turney 1464ac6ed5
Improve error reported when language has no compiler
This gives consistent reporting of this error for all platforms.

Also, reporting this error when constructing the BuildTarget, rather
than discovering the problem during backend generation means that the
error is reported against with a location.
2020-02-12 13:33:07 +00:00
Xavier Claessens 15eb0014ac interpreter: Iterate custom target outputs 2020-02-04 21:28:32 +02:00
Jussi Pakkanen a51c9af921
Merge pull request #6423 from dcbaker/declare-dependency-variables
Add ability to set and query arbitrary variables on declare_dependency objects
2020-01-27 18:29:22 +02:00
Nirbheek Chauhan d8e738f04f typing: Fix compatibility with Python 3.5.2
Explicitly use the type instead of the string 'NotImplemented' which
still works with Python 3.5.2

Fixes https://github.com/mesonbuild/meson/issues/6427
2020-01-24 02:53:34 +05:30
Dylan Baker cd895be99a dependencies: Add ability to set arbitrary variables on
declare_dependencies

This allows dependencies declared in subprojects to set variables, and
for those variables to be accessed via the get_variable method, just
like those from pkg-config and cmake. This makes it easier to use
projects from subprojects in a polymorphic manner, lowering the
distinction between a subproject and an external dependency every
further.
2020-01-09 11:02:17 -08:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Dylan Baker e88b3c8022 build: Fix type signature of rich comparison dunders
There are three problems:

1) Dunders like `__lt__` and `__gt__` don't return bool, they return
   either a bool or the NotImplemented singleton to signal that they don't
   know how to be compared.
2) The don't take type object, the take `typing.Any`
3) They need to return NotImplemented if the comparison is not
   implemented, this allows python to try the inverse dunder from the
   other object. If that object returns NotImplemented as well a
   TypeError is raised.
2019-12-05 22:15:40 +02:00
Daniel Mensinger ae018a3c68 lgtm: fix Incomplete ordering 2019-12-05 11:08:12 -05:00
Daniel Mensinger 268d59516f lgtm: fix Mismatch between signature and use of an overridden method
by renaming process_kwargs to process_kwargs_base for the base
target class.
2019-12-05 00:22:10 +02:00
Daniel Mensinger e0001fbe0a lgtm: fix format string numbering 2019-12-05 00:22:10 +02:00
taz-007 eed05c9045 improve error message when old version detected
Be more explicit about the --wipe command requiring to be executed from the source dir.
2019-11-30 21:55:51 +02:00
Xavier Claessens 7dd302773d Fix link_whole with a custom target
t.pic won't be defined. We can only hope it has been built with -fPIC.
Linker will complain otherwise any way.

t.extract_all_objects_recurse() won't be defined. We could support this
case by extracting the archive somewhere and pick object files.
2019-11-25 20:34:37 -05:00
Jussi Pakkanen 35e809fc5e Store run target names in build.
This way we can easily check that we only provide builtin targets such
as clang-format if the user has not provided their own.
2019-11-10 23:45:42 +02:00
Jakub Adam 1bf1782476 Fix *.pdb files missing in meson introspect --installed output
On Windows, make sure the introspect command lists all Program database
(PDB) files containing debugging information that Meson will install.
2019-10-09 15:50:20 +02:00
Daniel Mensinger 73d52266b5
Use include_type instead of is_system 2019-10-03 10:06:04 +02:00
Daniel Mensinger a7c4682be1
Also add support for declare_dependency objects 2019-10-03 10:06:04 +02:00
Daniel Mensinger f508b4cf80
use getters for dependency access 2019-10-03 10:06:03 +02:00
Xavier Claessens dd5a0df3ec Recursively include all objects from uninstalled static libraries 2019-10-01 13:06:45 -04:00
Xavier Claessens a3153747b9 Do not promote to link_whole when an internal library links to another 2019-10-01 13:06:45 -04:00
Xavier Claessens 19fc692b25 pkgconfig: Include dependencies of uninstalled static libraries 2019-10-01 13:06:45 -04:00
Xavier Claessens dc5ad1fad9 pkgconfig: Do not include uninstalled static libraries 2019-10-01 13:06:45 -04:00
Xavier Claessens 484b721369 Fix link_with of a static library with an uninstalled static library 2019-10-01 13:06:45 -04:00
Xavier Claessens f396c71c52 Fix link_whole of static libraries 2019-10-01 13:06:45 -04:00
Aleksey Gurtovoy 6ac5db50c9 CUDA support on Windows 2019-09-24 14:22:20 -07:00
Jussi Pakkanen 1ea3ddc6ad
Merge pull request #5681 from dcbaker/dynamic-linker-split
split dynamic linker representations from compilers
2019-08-20 23:14:05 +03:00
Rachel Mant f431cff809 Make .extract_objects() work correctly as an input to custom_target 2019-08-17 21:12:56 +03:00
Dylan Baker 06dcbd50ee compilers: Dispatch to dynamic linker class
Most of the cuda code is from Olexa Bilaniuk.
Most of the PGI code is from Michael Hirsc
2019-08-14 13:13:23 -07:00
Jussi Pakkanen f41bdae368 Add basic Webassembly support via Emscripten. 2019-08-05 19:31:32 +03:00
Marc-André Lureau 341d245e68 Accept vs_module_defs for modules
Like shared libraries, modules may have vs_module_defs.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-07-17 19:19:56 +03:00
Xavier Claessens 12d4031f52 Add alias_target() function 2019-07-10 15:01:18 -04:00
Cody Schafer 11248eb203 sanitycheckc: avoid linking sanitycheckc when cross compiling 2019-06-27 20:36:09 +03:00
Roman Shpuntov 3b17344b11 tvOS: added support AppleTVOS 2019-06-13 21:31:03 +03:00
John Ericson 3b54f38c84 Add some type annotations
Some things, like `method[...](...)` or `x: ... = ...` python 3.5
doesn't support, so I made a comment instead with the intention that it
can someday be made into a real annotation.
2019-06-09 13:13:27 -04:00
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00
John Ericson 32e827dcdc Use `env.machines.*` to avoid some `is_cross`
This is a small example of the `is_cross` removal the that abstraction
enables.
2019-06-09 13:13:20 -04:00
Jussi Pakkanen 79d530e325 Generators can have extra target dependencies. Closes #4131. 2019-05-20 23:38:13 +03:00
Jon Turney fb35e6faac Remove compiler data from build object
The actual data is in Coredata (which is serialized) and we just held a
reference in Build for (in)convenience.
2019-05-20 11:29:17 -07:00
Dylan Baker 0b38171710 build: add a few annotations
As needed by mtest
2019-05-14 16:43:29 -07:00
Dylan Baker 502a684872 build: TestSetup doesn't take keyword arguments
This function is currently setup with keyword arguments defaulting to
None. However, it is never called without passing all of it's arguments
explicitly, and only one of it's arguments would actually be valid as
None. So just drop that, and make them all positional. And annotate
them.
2019-05-14 16:43:29 -07:00
Dylan Baker 94591ce7b0 build: Treat ICL like MSVC in regards to standard lib linking 2019-05-13 11:22:31 -07:00
Michael Hirsch, Ph.D 06bfc2dab6 per-target manual specification of link_language 2019-05-02 23:26:51 +03:00
Jussi Pakkanen 7059c47aad
Merge pull request #5161 from TheQwertiest/feature/custom_target_link
Can link against custom_target[i]
2019-05-02 22:21:56 +03:00
John Ericson 4c2617a9c6 Add some type annotations and fix lints
Some things, like `method[...](...)` or `x: ... = ...` python 3.5
doesn't support, so I made a comment instead with the intention that it
can someday be made into a real annotation.
2019-05-02 10:58:23 -07:00
TheQwertiest d74ab216db Cleaned up `isinstance` usage 2019-04-29 17:57:02 +03:00
TheQwertiest 0ab9d474e1 Use parent `custom_target` for dependency handling (for consistency and future-proofing) 2019-04-29 16:08:50 +03:00
TheQwertiest 8c9a25456d Added custom_target[i] support for link_with and link_whole 2019-04-29 16:07:50 +03:00
Dylan Baker add821db64 Don't use mutable types as default arguments
This isn't safe given the way python implements default arguments.
Basically python store a reference to the instance it was passed, and
then if that argument is not provided it uses the default. That means
that two calls to the same function get the same instance, if one of
them mutates that instance every subsequent call that gets the default
will receive the mutated instance. The idiom to this in python is to use
None and replace the None,

def in(value: str, container: Optional[List[str]]) -> boolean:
   return src in (container or [])

if there is no chance of mutation it's less code to use or and take
advantage of None being falsy. If you may want to mutate the value
passed in you need a ternary (this example is stupid):

def add(value: str, container: Optional[List[str]]) -> None:
    container = container if container is not None else []
    container.append(value)

I've used or everywhere I'm sure that the value will not be mutated by
the function and erred toward caution by using ternaries for the rest.
2019-04-23 02:03:19 +03:00
Paolo Bonzini b9774b4485 generator: add dependency on generator in source tree
If find_program() returns a file from the source directory, anything
that uses it should add the file to the dependencies, so that they are
rebuilt whenever the script changes.  Generator is not doing that.

While at it, I am doing two related fixes:

- Generator is not checking whther the generator actually was found,
resulting in a Python error involving NoneType if it isn't.  To minimize
backwards compatibility issues, I am only raising the error when
g.process() is acutally called.

- the error message for custom_target with a nonexisting program
erroneously mention a not-found external program "nonexistingprogram".
The new error is similar to the one I am adding for generators.
2019-04-16 01:46:31 +00:00
Nirbheek Chauhan 10468b3a28 interpreter: Warn when environment() ops are overriden
Warn when someone tries to use append() or prepend() on an env var
which already has an operation set on it. People seem to think that
multiple append/prepend operations stack, but they don't.

Closes https://github.com/mesonbuild/meson/issues/5087
2019-04-13 22:53:33 +03:00
Dylan Baker b842b0b04a dependencies: Add ext_deps to all dependencies
I'll be using this later, but it seems useful to allow dependencies to
that have special handlers to declare that they depend on other
dependencies. This should allow us to stop treating threads special
internally and just make it a normal dependency.
2019-04-05 16:19:30 -07:00
Jussi Pakkanen 5905533fcd
Merge pull request #5103 from mesonbuild/linkcustom
Can link against custom targets
2019-04-01 01:29:51 +03:00
Jussi Pakkanen 3196e4e141 Support link_whole with custom targets. 2019-03-28 22:56:37 +02:00
Jussi Pakkanen 40b5abd668 Better error message when PCH argument is not a string. 2019-03-24 20:56:34 +02:00
Jussi Pakkanen 8361da5c52 Fix setup so test suite runs with rustc + MSVC. Closes: 5099 2019-03-24 20:56:06 +02:00
Jussi Pakkanen 19eb0e762a Win fixes. 2019-03-19 00:26:43 +02:00
Jussi Pakkanen e81f48db16 Can link against custom targets. Closes #4908. 2019-03-18 22:01:07 +02:00
Bruce Richardson cfe82db5ab do not duplicate external dependencies in list
Since the "-l<lib>" flags in the build.ninja file are passed in
"--start-group"/"--end-group" flags, there should be no need to have any
library listed twice, even if there are circular dependencies. Therefore we
can eliminate duplicates. For speed, rather than deduplicating at the end
of the process, it's faster to not add the duplicate flags in the first
place.

This should help fix #2150
2019-03-13 11:54:39 +00:00
Dylan Baker 89e46f0d92 build: Handle EOFError and AttributeError like coredata
Fixes #5056
2019-03-12 03:54:41 +00:00
Nicolas Schneider ded0defc3f auto generate msvc pch source file if none is provided by the user 2019-03-01 21:50:31 +02:00
Raphael Salamon c23ac0b3dc Allow custom targets with same name in project and subprojects
closes #4377
2019-02-19 19:41:57 +02:00
Maarten ter Huurne 37a962e90c Allow File arguments in extract_objects() arguments
Passed strings are converted to Files, but passing a File directly
wasn't supported yet.
2019-02-19 10:02:30 -05:00
Olexa Bilaniuk ad442b3520 Add cuda_args keyword. 2019-01-31 04:26:37 -05:00
Nicolas Schneider 1058430898 raise an error if PCH files are stored in different folders 2019-01-29 22:04:35 +02:00
Luca Boccassi 267792174c custom_target: do not let install override build_by_default
A custom_target, if install is set to true, will always be built by
default even if build_by_default is explicitly set to false.
Ensure that this does not happen if it's set explicitly. To keep
backward compatibility, if build_by_default is not set explicitly and
install is true, set build_by_default to true.

Fixes #4107
2019-01-17 20:40:19 +02:00
John Ericson b53c982b58 Build class should not duplicate compiler state
Compilers should be held by coredata, so this is just here for
convenience.
2019-01-14 00:16:36 +02:00
Daniel Mensinger 3588786138
Some small fixes 2019-01-06 12:19:31 +01:00
Daniel Mensinger 5c39dd0668
Doc updates and throw if no target type is set 2019-01-06 12:19:31 +01:00
Daniel Mensinger b034f52656
Filenames are now lists 2019-01-06 12:19:29 +01:00
Daniel Mensinger c4eb5c79fe
Added unit test 2019-01-06 12:19:28 +01:00
Daniel Mensinger a5be893b19
Some code cleanup 2019-01-06 12:19:28 +01:00
Nicolas Schneider 31e1a31030 fail configuration if PCH files do not exist
Previously, the configuration worked fine, but the compiler raised an
error. Now, we explicitly check for the existence of files and print a
useful error message if they do not exist.
2019-01-01 19:36:37 +02:00
Jussi Pakkanen d64f93800f Do not write cp entry when it is empty. Closes #4602. 2018-12-09 16:24:37 +02:00
Xavier Claessens 377719cc7b BuildTarget: Fix typo, self.install does not exists 2018-12-04 06:49:02 -05:00
John Ericson 0fd548e16f Combine `run_tests` import lines in `run_unittests` 2018-12-03 22:33:20 +02:00
Aleksey Filippov 1c8c888854 Use first 7 letters of sha256 for subdirectory part of target id
Fixed-size hash makes paths shorter and prevents doubling of path length
because of subdir usage in target id: "subdir/id" would generate
"subdir/{subdir-without-slashes}@@id" target otherwise.

Export construct_id_from_path() to aid tests.
Add a separate unit test for this function to make sure it is not broken unexpectedly.

Closes #4226.
2018-11-22 23:38:40 +02:00
Stian Selnes 0821462ce3 Add kwarg is_default to add_test_setup()
is_default may be used to set the name of the test setup that will be
used by default whenever the option --setup is not given.

Fixes #4430
2018-11-12 16:23:59 +05:30
Jussi Pakkanen 59774702b2
Merge pull request #4480 from jon-turney/fix-implib-prefix-suffix
Fix naming of implib when name_prefix/suffix is used
2018-11-10 23:40:24 +02:00
Phillip Cao 68c83cb213 Add support for Renesas CC-RX toolchain 2018-11-08 00:02:22 +13:00
Jon Turney e64a9c9830
Generate import lib even if both name_suffix and name_prefix are used
It's a (presumably unintentional) quirk of the current implementation of
SharedLibrary.determine_filenames() that if both name_suffix and
name_prefix are set, an import library isn't generated.

Adjust test 'common/25 library versions': Make the library have exports,
so an implib is generated with MSVC. Add implib to set of files expected
to be installed

Adjust test 'common/122 shared module': Add libnosyms implib to set of
files expected to be installed, except for MSVC, where none is generated
as it has no exports
2018-11-06 13:17:21 +00:00
Jon Turney 7a959ffbba
Fix library implib name when name_prefix: is used
Use the specified name_prefix for implib, rather than hardcoding it.

(This is needed to allow an installed library given name_prefix:'' and a
name starting with 'lib' to be linked with using -l. (This case is
handled specially in the pkgconfig module))
2018-11-06 12:52:02 +00:00
Jon Turney 64edfd5069
Detect clang-cl as msvc-like, not clang-like
Handle clang's cl or clang-cl being in PATH, or set in CC/CXX

Future work: checking the name of the executable here seems like a bad idea.
These compilers will fail to be detected if they are renamed.

v2:
Update compiler.get_argument_type() test
Fix comparisons of id inside CCompiler, backends and elsewhere

v3:
ClangClCPPCompiler should be a subclass of ClangClCCompier, as well

Future work: mocking in test_find_library_patterns() is effected, as we
now test for a subclass, rather than self.id in CCompiler.get_library_naming()
2018-11-04 15:42:00 +00:00
Xavier Claessens edccb11f01 Rollback if an optional subproject fails
If a subproject is not required and fails during its configuration, the
parent project continues, but should not include any target or state set
by the failed subproject. This fix ninja still trying to build targets
generated by subprojects before they fail in their configuration.

The 'build' object is now per-interpreter instead of being global. Once
a subproject interpreter succeed, values from its 'build' object are
merged back into its parent 'build' object.
2018-10-29 20:22:33 +02:00
Xavier Claessens c453400d59 Add 'b_pie' compiler option
On Android executables must be position independent, many
distributions enable it by default too for security reasons.
2018-10-20 00:47:27 +03:00
Jussi Pakkanen 88054c48a6
Merge pull request #4293 from marcelhollerbach/master
Performance optimize the install part generation
2018-10-04 22:10:09 +03:00
Marcel Hollerbach c53d35aa72 build: generate the mappings in the Targets
Before, the mappings has been created over all the links, while it
actaully only used the Shared or Static Targets. This structure now is
tree like structured and cached, thus the results can be computed a lot
faster.
The generator step generate_install is now for EFL from 6 sec. down to
0.3s. Which improves the overall build time from ~20 sec. to ~14 sec.
2018-10-01 23:47:19 +02:00
Marcel Hollerbach c38544a6ec build: move default_install_dir to the Target classes
there is a huge amount of isinstance calls, this reduces the amount of
these calls while splitting up a rather big function. It also assosiates
every target type with theire default install directory.
2018-10-01 23:47:19 +02:00
GoaLitiuM 8776dac773 Add conditional debug identifiers for D compilers, and enable for debug builds
Also includes parsing the highest integer level for debug and version.
2018-09-27 17:49:48 +03:00
Jussi Pakkanen b6f03f897b
Merge pull request #4174 from jon-turney/link-with-custom-target
Improve error when trying to link_with a custom_target
2018-09-17 22:49:01 +03:00
Jon Turney b338add554 Fix flake8 whitespace reports
$ flake8 | grep -E '(E203|E221|E226|E303|W291|W293)'
./mesonbuild/build.py:964:5: E303 too many blank lines (2)
./tools/dircondenser.py:70:36: E221 multiple spaces before operator
2018-09-13 20:33:17 +03:00
Jon Turney 44a340a4fe
Move default is_linkable_target method up from BuildTarget to Target
BuildTarget.link() assumes that it can call is_linkable_target() on any
objects which are a subclass of Target
2018-09-13 17:02:43 +01:00
Marcel Hollerbach 7ae3fbf88d mesonbuild: move subdir generation along link dep generation
The problem with the earlier position of the generation code was, that
the results could not be cached, because the list of all link_deps was
overall different. However, it shared a special kind of subsets with
other build build targets.

Generating the set of subdirs that are required for linking, alongside
with the link dependencies brings the possibility of caching this.
This reduces the buildting from 1 min. in efl down to 20 sec. And
reduces the amount of 30872534 calls down.

this saves ~40 sec.
2018-09-11 03:03:30 -07:00