Commit Graph

1198 Commits

Author SHA1 Message Date
Daniel Mensinger 3f889606c7 Split compiler detection from Environment
This moves all the compiler detection logic into the new
compilers.detect module. This dramatically reduces the size
and complexity of Environment.
2021-06-25 19:34:48 +02:00
Jussi Pakkanen 6e0a0fd1da
Merge pull request #8884 from dcbaker/submit/type-and-annotate-install-functions
Add annotations for the various install_* functions
2021-06-23 01:00:59 +03:00
fanc999 edfe24178d
Add Visual Studio 2012/2013 backends (#8803)
* backends: Add a Visual Studio 2013 backend

This is more-or-less a quick port from the VS2015 backend, except that
we update the Visual Studio version strings and toolset versions
accordingly.  Also correct the generator string for Visual Studio 2015
in mesonbuild/cmake/common.py.

* backend: Add VS2012 backend

Similar to what we did for Visual Studio 2013, add a Visual Studio 2012
backend.

* vs2010backend.py: Implement `link_whole:` if needed

We actually need Visual Studio 2015 Update 2 to use `/WHOLEARCHIVE:`,
which is what we are currently using for `link_whole:` on Visual Studio.
For Visual Studio versions before that, we need to expand from the
static targets that were indicated by `link_whole:`, and any of the
sub-dependent targets that were pulled in via the dependent target's
`link_whole:`.  This wil ensure `link_whole:` would actually work in
such cases.

* vs2010backend.py: Handle objects from generated sources

Unforunately, we can't use backends.determine_ext_objs() reliably, as
the Visual Studio backends handle this differently.

* vs2010backend.py: Fix generating VS2010 projects

Visual Studio 2010 (at least the Express Edition) does not set the envvar
%VisualStudioVersion% in its command prompt, so fix generating VS2010
projects by taking account into this, so that we can determine the location
of vcvarsall.bat correctly.

* whole archive test: Disable on vs2012/2013 backends too

The Visual Studio 2012/2013 IDE has problems handling the items that would be
generated from this test case, so skip this test when using
--backend=vs[2012|2013].  This test does work for the Ninja backend when
VS2012 or VS2013 is used, though.

Consolidate this error message with XCode along with the vs2010 backend.

* docs: Add the new vs2012 and vs2013 backends

Let people know that we have backends for vs2012 and 2013.  Also let
people know that generating Visual Studio 2010 projects have been fixed
and the pre-vs2015 backends now handle the `link_whole:` project option.
2021-06-22 21:00:23 +03:00
Dylan Baker d636b92c1a install_*: FileMode doesn't need to be None
There's no reason to allow None into the backend, it already has code to
check that all of the values of the FileMode object are None, so let's
use that, which is much simpler all the way down.
2021-06-22 09:13:41 -07:00
Dylan Baker f2ad5e377e backend: Headers.install_subdir is allowed to be None
But we don't properly handle that.
2021-06-22 09:12:54 -07:00
Daniel Mensinger 34c28dc92c holders: remove unholder 2021-06-18 23:48:33 +02:00
Dylan Baker 9851c25895 backends: fix TestSerialisation.suite annotations
It's a `str[]` not `str`
2021-06-14 12:30:02 -07:00
Ralf Gommers bc6df45663 Fix issue with generated Cython code in a subdir
This is a follow-up to gh-8706, which contained the initial fix
to ninjabackend.py but somehow lost it. This re-applies the fix
and adds a test for it.

Without the fix, the error is:

  ninja: error: 'ct2.pyx', needed by 'libdir/ct2.cpython-39-x86_64-linux-gnu.so.p/ct2.pyx.c',
  missing and no known rule to make it
2021-06-14 09:36:28 -07:00
Eli Schwartz 48ebfa9a99
another pyupgrade pass 2021-06-07 16:51:47 -04:00
Eli Schwartz 3eb1da1fa2
condense lines 2021-06-07 16:51:47 -04:00
Eli Schwartz 2c71b63e77
more f-strings everywhere
pyupgrade didn't catch many .format() methods which were too complex
(e.g. multiline or applied to templates rather than string literals)
2021-06-07 16:51:47 -04:00
Dylan Baker 0bc18f26a2 cython: Add an option for selecting python 3 vs python 2 output 2021-06-07 09:25:32 -07:00
Dylan Baker ec4d8143df ninjabackend: generate cython compilation rules 2021-06-07 09:16:19 -07:00
Dylan Baker 80cdbe41bd ninjabackend: cython doesn't use a linker 2021-06-07 09:16:19 -07:00
Dylan Baker 201dc64226 add a couple more type annotations 2021-06-02 15:53:17 -07:00
Dylan Baker 113a159514 use an immutable list for an lru_cached functions
When mutable items are stored in an lru cache, changing the returned
items changes the cached items as well. Therefore we want to ensure that
we're not mutating them. Using the ImmutableListProtocol allows mypy to
find mutations and reject them. This doesn't solve the problem of
mutable values inside the values, so you could have to do things like:

```python
ImmutableListProtocol[ImmutableListProtocol[str]]
```

or equally hacky. It can also be used for input types and acts a bit
like C's const:

```python
def foo(arg: ImmutableListProtocol[str]) -> T.List[str]:
    arg[1] = 'foo'  # works while running, but mypy errors
```
2021-06-02 15:53:17 -07:00
Dylan Baker c6ec13e6bf
Only try to get RSP syntax if RSP is supported (#8804) 2021-05-30 00:24:53 +03:00
Xavier Claessens 25fa2d4f7b vsenv: Recommend using "meson compile" wrapper
When meson has setup the VS environment, running ninja to build won't
work, user should use meson wrapper to compile.
2021-05-28 17:34:25 -04:00
Chun-wei Fan bbb6f2c51c ninjabackend.py: Implement `link_whole:` for pre-VS2015
...Update 2, to be exact, since the Visual Studio linker only gained the
`/WHOLEARCHIVE:` feature since Visual Studio 2015 Update 2.

This checks whether we have the corresponding `cl.exe` which is
versioned at or after Visual Studio 2015 Update 2 before we try to apply
the `/WHOLEARCHIVE:xxx` linker flag.  If we aren't, use built-in methods
in Meson to grab the object files of the dependent static lib's, along
with the objects that were `link_whole:`'ed into them, and feed this
list into the linker instead.

This would make `link_whole:` work on Visual Studio 2015 Update 1 and
earlier, including previous Visual Studio versions.
2021-05-27 09:54:37 -07:00
Jussi Pakkanen 43f0aa17b7 Add swift executable support in Xcode. 2021-05-23 17:59:14 +01:00
Jussi Pakkanen e23fd086bf Remove unnecessary hierarchical layer. 2021-05-23 13:28:25 +03:00
Jussi Pakkanen b84265052e Remove top level sources entry as unnecessary. 2021-05-23 13:28:25 +03:00
Jussi Pakkanen 7ceba6388c Add meson.build files to pbxgroup. 2021-05-23 13:28:25 +03:00
Jussi Pakkanen 818685ec18 Write project info in a tree structure rather than the current flat one. 2021-05-23 13:28:25 +03:00
Dylan Baker bfd06783bd backends: use a set for processed targets instead of a dict
We're only interested in the keys, not in the value (which was always
set to True), so a set is a better data structure anyway.
2021-05-19 23:28:17 +03:00
Dylan Baker 7659ae50a0 ninjabackend: Fix vala type annotations 2021-05-19 23:28:17 +03:00
Dylan Baker b1b8e777a2 rust: override get_linker_always_args
instead of opencoding what should be there in the rust compile rule
2021-05-19 23:28:17 +03:00
Dylan Baker e7e04c814b Add a rust test for internal c linkage
We have code to support this, but no tests. That seems pretty bad.
And better yet, it doesn't work on MSVC in some cases.
2021-05-18 09:34:36 -07:00
Dylan Baker 11d123332d ninjabackend: fix linking dynamic c libraries with rust
The correct name is "dylib" not "shared"
2021-05-17 15:21:27 -07:00
Peter Harris be015a37d7
Visual Studio Address Sanitizer updates
* Allow address sanitizer for Visual Studio 2019 version 16.9

Address Sanitizer was first supported with the current syntax in Visual
Studio 16.9.0 (cl version 19.28.29910).

* VS: Convert /fsanitize=address to project file setting
2021-05-15 18:47:04 +03:00
Marco Trevisan (Treviño) 739e499554 ninjabackend: Add pch includes as early as possible not to be overridden
When pch are used for a target meson will make the compiler to include
the pre-compiled header. While this is useful, this needs to happen
before any other header has been included, otherwise:

 1) we won't take advantage of pch for anything else previously included
 2) gcc will just fail as it won't even try to look for a pre-compiled
    header in this case [1]

This case can happen quite a easily when a dependency provides an
included header in its cflags.

As per this, split _generate_single_compile() in two phases, one is
responsible of initializing the compiler data, while the other is
defining commands for the context.

In this way, when pch can be used, we can insert the pch inclusion
earlier than any other provided by the target.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100462
2021-05-08 21:27:35 +03:00
Jussi Pakkanen 53f6ef3b7b Xcode: fix project cleaning. 2021-04-29 21:12:11 +01:00
Jason Francis 39c751b94c introspection: export all sources for custom targets
Also adds some test cases for source files in target_sources.
2021-04-26 17:08:26 +01:00
Jussi Pakkanen 1a31882f59 Xcode: make Swift projects work. 2021-04-25 15:35:13 +03:00
Jussi Pakkanen 1cd80985b4 Xcode: add objective C++ flags to plain C++ because Xcode requires it. 2021-04-25 15:35:13 +03:00
Jussi Pakkanen 0e4c358f35 Xcode: add objective C flags to plain C because Xcode requires it. 2021-04-25 15:35:13 +03:00
Jussi Pakkanen aa2a153afb Xcode: fix linking to customtargetindex objects. 2021-04-24 19:41:27 +03:00
Jussi Pakkanen 22d0e6dd55 Xcode: even more command line argument expansion. 2021-04-23 23:03:26 +03:00
Jussi Pakkanen 0785ec3317 Xcode: Quote McQuoteface. 2021-04-23 23:03:26 +03:00
Jussi Pakkanen ee2363dbb7 Xcode: handle CustomTargetIndexes. 2021-04-23 17:29:29 +03:00
Jussi Pakkanen 2a341dd4ec Xcode: ever more quoting. 2021-04-23 17:29:29 +03:00
Jussi Pakkanen 7fba94997f Xcode: only add source and build dirs if implicit_include_directories is set. 2021-04-23 17:29:29 +03:00
Jussi Pakkanen bff85e2a6c Xcode: do not link shared modules against executables. 2021-04-22 16:53:43 +03:00
Jussi Pakkanen 40fb466513 Xcode: add missing quote character. 2021-04-22 16:53:43 +03:00
Jussi Pakkanen 965f7e18fa Xcode: fix shell quotings. 2021-04-22 16:53:43 +03:00
Jussi Pakkanen 4881c2cf98 Xcode: skip link language override test. 2021-04-22 16:53:43 +03:00
Jussi Pakkanen 674538d8c9 Xcode: put all include dirs via a property rather than a cmd line arg. 2021-04-21 17:16:01 +03:00
Jussi Pakkanen b42a5e21d0 Xcode: add target private dir to include path. 2021-04-21 17:16:01 +03:00
Jussi Pakkanen 3f99830f74 Xcode: quote some entries as needed. 2021-04-21 17:16:01 +03:00
Jussi Pakkanen d116d94f92 Xcode: fix file objects in various places. 2021-04-20 17:23:50 +03:00