Commit Graph

107 Commits

Author SHA1 Message Date
Justin Handville 9f248c778d Fix for Issue 8910 (Meson filters CMake asm files) 2021-06-22 12:46:17 +02: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
Daniel Mensinger 9b5463681e
cmake: select correct generator in toolchain.py 2021-05-30 16:33:09 +02:00
Daniel Mensinger f0812baf8d
cmake: exclude generated files from the buildsystem files list 2021-05-29 17:31:19 +02:00
Daniel Mensinger 49c730ef05
cmake: Fix CMakeToolchain (fixes #8293)
Instead of guessing the internal compiler
variables, Meson now runns CMake once to
determine what they actually are.
2021-05-29 13:20:25 +02:00
Dylan Baker 40e3577a65 split program related classes and functions out of dependencies
Dependencies is already a large and complicated package without adding
programs to the list. This also allows us to untangle a bit of spaghetti
that we have.
2021-03-19 08:47:10 -04:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Dylan Baker 23d3b98fc1 split mesonlib into a package
Currently mesonlib does some import tricks to figure out whether it
needs to use windows or posix specific functions. This is a little
hacky, but works fine. However, the way the typing stubs are implemented
for the msvcrt and fnctl modules will cause mypy to fail on the other
platform, since the functions are not implemented.

To aleviate this (and for slightly cleaner design), I've split mesonlib
into a pacakge with three modules. A universal module contains all of
the platform agnositc code, a win32 module contains window specific
code, a posix module contains the posix specific code, and a platform
module contains no-op implementations. Then the package's __init__ file
imports all of the universal functions and all of the functions from the
approriate platform module, or the no-op versions as fallbacks. This
makes mypy happy, and avoids `if`ing all over the code to switch between
the platform specific code.
2021-01-23 12:48:29 +01:00
Antonin Décimo 39ede12aa5 Fix misspells
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-13 12:53:10 -05:00
Jussi Pakkanen d47a5c81a9
Merge pull request #8080 from dcbaker/submit/option-key-type
Use an object for option keys
2021-01-04 23:42:50 +00:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -08:00
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
I would have prefered to do these seperatately, but they are combined in
some cases, so it was much easier to convert them together.

this eliminates the builtins_per_machine dict, as it's duplicated with
the OptionKey's machine parameter.
2021-01-04 12:20:40 -08:00
Dylan Baker f9b19e73a5 move OptionKey to mesonlib
There's starting to be a lot of things including coredata that coredata
needs to itself include. putting it in mesonlib makes more sense
2021-01-04 12:20:40 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Daniel Mensinger 6b515c4321 cmake: fix missing languages from CMake (fixes #8132) 2021-01-04 20:16:30 +00:00
Daniel Mensinger 5cbc8f866c cmake: fix -framework dependencies (fixes #8045) 2020-12-29 21:43:54 +00:00
Daniel Mensinger 5c821edf26 cmake: Revert to using self.for_machine instead of MachineChoice.BUILD (fixes #8028) 2020-12-16 21:50:27 +00:00
Dylan Baker f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
Daniel Mensinger 1eb9d8ad6e cmake: Always create missing includes in build dir
There really isn't any reason to not always create missing
include directories inside the build dir. Just restricting
this to generate generated sources should work in an ideal
world, however, there exists lots of suboptimal CMake code
where this assumption is not always true.
2020-10-24 19:31:15 +02:00
Daniel Mensinger 5f1da86a9b
cmake: ignore CMAKE_TOOLCHAIN_FILE and CMAKE_PROJECT_INCLUDE to avoid conflicts with the meson CMake logic 2020-10-16 20:44:04 +02:00
Daniel Mensinger 7e58f33376
cmake: Add cross compilation support 2020-10-13 17:04:19 +02:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Daniel Mensinger 77b5c82d07 cmake: switch to pathlib (fixes #7322) 2020-10-04 10:45:48 +02:00
Daniel Mensinger 2f3ef6f1af
typing: fully annotate cmake.interpreter 2020-09-28 13:54:04 +02:00
Daniel Mensinger 6a71391de6
typing: fully annotate cmake.common 2020-09-27 20:56:09 +02:00
Daniel Mensinger 4cef45af21 cmake: fix shared_module dependency (fixes #7715) 2020-09-10 06:41:24 +00:00
Sebastian Würl 6f3c8667ed CMake module: fix cmake 3.10 compatibility in path generation 2020-08-30 23:53:00 +02:00
Sebastian Würl fb42db8883 CMake module: fix python 3.6 compatibility in path generation 2020-08-30 23:53:00 +02:00
Sebastian Würl 8e004afc90 CMake module: Allow paths of generated CMake sources for include directories 2020-08-30 23:53:00 +02:00
Daniel Mensinger a98db022aa cmake: Detect custom command targets in compiler args
This is required to make `-include /path/to/custom/target.hpp`
work. This setup is used by wxWidgets and this PR is
required to use wxWidgets as a CMake subproject.
2020-08-09 19:36:38 +03:00
Daniel Mensinger 1c1ec9ff11
cmake: resolve IMPORTED executables in custom commands (fixes #7509) 2020-08-03 17:48:12 +02:00
Daniel Mensinger 05ddd6543d
mdata: remove setuptools and use mesondata instead 2020-07-16 21:03:23 +02:00
Jussi Pakkanen 64f36613ef
Merge pull request #7231 from mensinda/cmOverride
cmake: Add more advanced subproject configuration options
2020-07-01 00:04:08 +03:00
georgev93 5acd8acd51 Move mesonbuild/cmake/data/run_ctgt.py to mesonbuild/scripts/cmake_run_ctgt.py, as well as enclose everything in a run() function so it can be called by `meson --internal cmake_run_ctgt ...`. Also, include mesonbuild/cmake/data/ in the msi package. 2020-06-30 23:50:10 +03:00
Daniel Mensinger 6c56478ee1 cmake: fix definitions with interface libraries (fixes #7299) 2020-06-13 18:50:00 +00:00
Daniel Mensinger a2f94ca18b
cmake: Add more advanced subproject configuration options
This is done with the new cmake subprojects options object
that is similar to the already exisiting configuration data
object. It is consumed by the new `options` kwarg of the
cmake.subproject function.
2020-06-05 11:45:05 +02:00
Daniel Mensinger a252a17e6e cmake: always split property lists (fixes #7228) 2020-06-02 20:47:22 +03:00
Alexander Neumann ec7ee8fd9e fix cmake target configuration selection. 2020-05-24 12:59:53 +02:00
Nirbheek Chauhan f2d0551941 cmake: Print supported stds when warning
This was helpful while debugging CI failure on the 0.54 branch due to
a difference in the structure of self.env.coredata.compiler_options:

https://github.com/mesonbuild/meson/runs/674391139
https://travis-ci.org/github/mesonbuild/meson/jobs/686982807
2020-05-15 02:09:33 +00:00
Nirbheek Chauhan 76c636daac cmake: Fix string substitution index error
```
  File "mesonbuild/cmake/interpreter.py", line 293, in postprocess
    'Unknown {}_std "{}" -> Ingoring. Try setting the project'
IndexError: Replacement index 2 out of range for positional args tuple
```
2020-05-14 15:37:38 +00:00
Daniel Mensinger 956cba0222 cmake: Ignore unknown c(pp)? stds (fixes #7104) 2020-05-12 20:45:06 +03:00
Dylan Baker 57b468c75a Use pkg_resource to find resources files (data)
Doing this by hand is fraught with corner cases, and we're running into
some of those problems already. setuptools pkg_resource is a well tested
solution for not running into corner cases, and we already rely on
setuptools to make our entry point scripts work, so we might as well
make us of the other things it can solve for us.

Fixes #6801
2020-04-21 00:40:19 +03:00
Daniel Mensinger cf4b9e6502 cmake: Do not compile explicit header files 2020-04-17 18:28:40 +03:00
Daniel Mensinger fa1bb2a676 cmake: Preserve include directory order (fixes #6959) 2020-04-12 19:39:01 +03:00
Daniel Mensinger 95e7477d12 cmake: Only expand executable targets in COMMAND (fixes #6857) 2020-03-29 19:35:37 +03:00
Daniel Mensinger 91976a3489 cmake: Fix build_by_default: false, install: true (fixes #6737) 2020-03-08 14:10:22 +02:00
Daniel Mensinger ab988198c7
review: Initial fixup 2020-03-02 10:47:20 +01:00
Daniel Mensinger c14aea2812
types: Annotate mparser.py
This also fixes that the keys in ArgumentNode.kwargs are
all of the type BaseNode now. Before this commit, it was
possible that both strings and Nodes where used as keys.
2020-03-02 10:34:55 +01:00
Jussi Pakkanen bacf063aae
Merge pull request #6635 from mensinda/cmOTMFix
cmake: Fix dependency loops in custom targets (fixes #6632)
2020-02-23 12:49:50 +02:00
Daniel Mensinger 113ec96626
cmake: Fix relative paths for add_custom_{command,target}
Do this by tracking CMAKE_CURRENT_{SOURCE,BINARY}_DIR variables.
This is achieved by injecting CMake code with CMAKE_PROJECT_INCLUDE
and overriding some builtin functions with a wrapper that adds
additional trace information.
2020-02-20 11:16:37 +01:00