Commit Graph

69 Commits

Author SHA1 Message Date
Eli Schwartz 680b5ff819
treewide: add future annotations import 2023-02-01 17:01:30 -05:00
Jehan a692395186 Fix 2 typos in a single string which can be shown in error messages. 2022-08-31 21:20:47 -04:00
Dylan Baker 6843f56f6b modules: use module level information about new and deprecation
Instead of using FeatureNew/FeatureDeprecated in the module.

The goal here is to be able to handle information about modules in a
single place, instead of having to handle it separately. Each module
simply defines some metadata, and then the interpreter handles the rest.
2022-08-17 16:25:36 -04:00
Eli Schwartz edb38fd6f6
fix confusing incorrect default name for a KwargInfo
We can use this lots of places, and it's always the same kwarg. There
doesn't seem to be a point in naming it badly, then evolving it to the
standard name in the one place it is currently used. This made it not
shareable.
2022-06-17 14:33:01 -04:00
Xavier Claessens e33ec88ac7 Pass environment down to base Target class 2022-03-29 16:10:28 -04:00
Dylan Baker 11f9638035 build: replace kwargs in CustomTarget initializer
Because we don't want to pass the Interpreter kwargs into the build
layer. This turned out to be a mega commit, as there's really on elegant
way to make this change in an incremental way. On the nice side, mypy
made this change super easy, as nearly all of the calls to
`CustomTarget` are fully type checked!

It also turns out that we're not handling install_tags in custom_target
correctly, since we're not converting the boolean values into Optional
values!
2022-01-28 15:53:20 -05:00
Daniel Mensinger c5ce9744b2 Fix mypy errors 2021-12-17 14:00:28 -05:00
Eli Schwartz 32821be623
add location nodes to some Feature calls 2021-11-20 20:48:30 -05:00
Dylan Baker 6849baa476 modules/windows: allow CustomTargets with more than one output for compile_resources 2021-10-09 21:34:54 -07:00
Dylan Baker 88060d47c1 modules/windows: allow CustomTargetIndex for compile_resources
In the positional arguments
2021-10-09 21:34:54 -07:00
Dylan Baker cc231de08e modules/windows: use typed_kwargs 2021-10-09 21:34:48 -07:00
Dylan Baker dc1866aedc modules/windows: use typed_pos_args 2021-10-08 14:32:32 -07:00
Dylan Baker e3c8257fc9 modules/windows: add some easy type annotations
This isn't complete, it's just the easy stuff
2021-10-08 14:32:19 -07:00
Luca Bacci 6d1e182476 Windows module: Make path flattening for windres work in more cases
If either 'name' or 'name_formatted' are absolute paths,
then they are of the form:

C:\path/to/file.ext                            (example)

By only substituting slashes with the underscore, we get:

C:_path_to_file.ext

This is still not quite right, infact os.path.basename()
returns:

_path_to_file.ext

Also replace colons with underscores to overcome issues when
absolute paths are involved.
2021-10-07 21:52:18 -04:00
Connor Abbott 62702005eb windows: Support wrc resource compiler
It has a similar interface to windres, but it produces ELF instead of
COFF binaries. It uses its own preprocessor which doesn't support
creating depfiles, but we can convince it to use the system preprocessor
instead and pass those arguments using the --preprocessor option.

Together with some hacks to override the shared library/executable
suffix and some wine patches [1] this is enough to compile dxvk when
ripping out the hand-rolled rc support.

[1] https://www.winehq.org/pipermail/wine-devel/2021-July/190100.html
https://www.winehq.org/pipermail/wine-devel/2021-July/190098.html
https://www.winehq.org/pipermail/wine-devel/2021-July/190099.html
https://www.winehq.org/pipermail/wine-devel/2021-July/190101.html
2021-07-07 18:54:45 +03:00
Daniel Mensinger 34c28dc92c holders: remove unholder 2021-06-18 23:48:33 +02:00
Xavier Claessens 2e02ef6592 modules: Add methods dict everywhere
This fix calling random internal methods from meson.build as long as
they were not prefixed by underscore.
2021-05-28 15:17:10 -04:00
Xavier Claessens 4e312c19e6 gnome: Fix gtkdoc generation
install_scripts used to replace @BUILD_ROOT@ and @SOURCE_ROOT@ but it
was not documented and got removed in Meson 0.58.0. gnome.gtkdoc() was
relying on that behaviour, but it has always been broken in the case the
source or build directory contains spaces.

Fix this by changing get_include_args() to substitue paths directly
which will then get escaped correctly.

Add a unit test that builds GObject documentation which is where this
issue has been spotted.

Fixes: #8744
2021-05-12 15:54:37 -04: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
Xavier Claessens 2e80c52129 windows: Avoid target name clash happening in GTK+ 2020-10-15 23:07:29 +03:00
Peter Harris 2664ab069d windows: reduce chance of going over path limit in backend/vs
When building with vs2019 (not ninja), a path length error will be thrown
if the path to a resource file is even remotely deep within the tree.

This is largely because the target name includes the string "Windows
resource for file 'full path'", which is then expanded twice (once for
the .vcxproj itself, and once for IntDir) and added to the full path.
When combined with the tiny path limits on Windows, it is easy to exceed
path limits.

This error is largely avoided by the ninja back-end. Unlike the
vs back-end, the ninja back-end does not use target.get_id() as part of
the project file path, nor does it use target.get_id() as part of
get_target_private_dir().

Example error:

error MSB4184: The expression "[MSBuild]::NormalizePath(
C:\src\mesonbuild\Misc\FreeRDP-master\client\X11\xfreerdp\xfreerdp,
f3f7317@@Windows resource for file
'Misc_FreeRDP-master_client_X11_xfreerdp_xfreerdp_xfreerdp.rc'@cus\,
f3f7317@@Windows resource for file
'Misc_FreeRDP-master_client_X11_xfreerdp_xfreerdp_xfreerdp.rc'@cus.
vcxproj.CopyComplete)" cannot be evaluated. Path:
C:\src\mesonbuild\Misc\FreeRDP-master\client\X11\xfreerdp\xfreerdp\f3f7317
@@Windows resource for file
'Misc_FreeRDP-master_client_X11_xfreerdp_xfreerdp_xfreerdp.rc'@cus\f3f7317
@@Windows resource for file
'Misc_FreeRDP-master_client_X11_xfreerdp_xfreerdp_xfreerdp.rc'@cus.
vcxproj.CopyComplete exceeds the OS max path limit.
The fully qualified file name must be less than 260 characters.
2020-09-28 12:34:12 +00:00
Nirbheek Chauhan ea46daa7bc Revert "windows: reduce chance of going over path limit in backend/vs"
This reverts commit 807f88739e.
2020-09-17 20:39:37 +00:00
Peter Harris 807f88739e windows: reduce chance of going over path limit in backend/vs
When building with vs2019 (not ninja), a path length error will be thrown
if the path to a resource file is even remotely deep within the tree.

This is largely because the target name includes the string "Windows
resource for file 'full path'", which is then expanded twice (once for
the .vcxproj itself, and once for IntDir) and added to the full path.
When combined with the tiny path limits on Windows, it is easy to exceed
path limits.

This error is largely avoided by the ninja back-end. Unlike the
vs back-end, the ninja back-end does not use target.get_id() as part of
the project file path, nor does it use target.get_id() as part of
get_target_private_dir().

Example error:

error MSB4184: The expression "[MSBuild]::NormalizePath(
C:\src\mesonbuild\Misc\FreeRDP-master\client\X11\xfreerdp\xfreerdp,
f3f7317@@Windows resource for file
'Misc_FreeRDP-master_client_X11_xfreerdp_xfreerdp_xfreerdp.rc'@cus\,
f3f7317@@Windows resource for file
'Misc_FreeRDP-master_client_X11_xfreerdp_xfreerdp_xfreerdp.rc'@cus.
vcxproj.CopyComplete)" cannot be evaluated. Path:
C:\src\mesonbuild\Misc\FreeRDP-master\client\X11\xfreerdp\xfreerdp\f3f7317
@@Windows resource for file
'Misc_FreeRDP-master_client_X11_xfreerdp_xfreerdp_xfreerdp.rc'@cus\f3f7317
@@Windows resource for file
'Misc_FreeRDP-master_client_X11_xfreerdp_xfreerdp_xfreerdp.rc'@cus.
vcxproj.CopyComplete exceeds the OS max path limit.
The fully qualified file name must be less than 260 characters.
2020-09-17 11:24:53 +00:00
Nirbheek Chauhan 40319c9634 Don't make unactionable warnings fatal
Some warnings are out of the user's control, such as the RCC QT bug,
or the GNU windres bug, or our informational warning about
auto-disabling of options when -Db_bitcode is enabled.

Such warnings should not be fatal when --fatal-meson-warnings is
passed because there's no action that the user can take to fix it. The
only purpose it serves is to prevent people who use those features
from using --fatal-meson-warnings.
2020-07-05 16:13:00 +03:00
John Ericson 3a4388e51d Fix legacy env var support with cross
Fix #3969
2020-03-23 17:51:36 +02: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
ePirat b347f00dc0 Fix windres module argument flattening 2019-07-05 22:20:16 +03: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
Jon Turney 58870fda16 Remove compilers from ModuleState object
It doesn't make much sense to have this and not also have
cross-compilers (so any use of this is already pretty suspect as
probably wrong when cross-compiling).

This information is accessible anyhow via environment.coredata.
2019-05-20 11:29:17 -07:00
Dylan Baker de011e031c modules/windows: ICL uses rc, not windres 2019-05-13 11:22:31 -07:00
Daniel Mensinger e75211d321
Fix builtin variable names 2019-04-29 12:17:40 +02:00
John Ericson 2b22576fb6 Remove cross_info; cross file is parsed up front and discarded 2019-01-02 16:22:47 -05:00
Dylan Baker 091452f8cd modules/python3: allow specifying in the native file 2018-11-14 15:57:37 -08:00
Dylan Baker f159735c3b modules/windows: Allow getting windres from native file 2018-11-14 15:57:37 -08:00
Dylan Baker 95403cb615 replace ExternalProgram.from_cross_info with from_bin_list
This more generic method will also be used to check a config file for
binary information.
2018-11-14 15:57:37 -08:00
Jon Turney d35034b21b
Use 'rc' resource compiler with clang-cl toolchain
The LLVM toolchain doesn't come with a Windows resource compiler at
the moment. Use 'rc' from the Windows SDK.
2018-11-04 15:42:06 +00:00
Jon Turney d0acada1d5
Probe Windows resource compiler type
Determine the type of the Windows resource compiler by looking at its
output, not its name.

Also log the name and version of the resource compiler we are using.
2018-10-02 13:19:08 +01:00
Jon Turney d769de316d
Factor out windows resource compiler determination
Factor out determination of the windows resource compiler as
_find_resource_compiler().  Cache the result, so the work is only done once.
2018-10-01 21:30:45 +01:00
Jon Turney 654101414c Improve windows resource compiler executable selection
Always honour any windres setting in cross-file (we can't be compiling with
msvc, but this should apply when cross-compiling using gcc or clang)

Always honour WINDRES environment variable

Otherwise look for the resource compiler which is part of the same toolset
as the C or C++ compiler.

Add some commentary on why the conventions for compiled resource file
extensions differ between RC and windres

Also don't try to report non-existent path when we couldn't find the
resource compiler.
2018-09-10 21:03:41 +03:00
Jon Turney e0e980e064 Remove some spurious calls to the format() function
Remove some spurious calls to the format() function, left by mistake after
c2f37853
2018-08-27 00:56:14 +03:00
Jon Turney c2f3785383
Use unique output for windows.compile_resources()
Use a unique output filename for windows.compile_resources() even when input
basename is not unique.
2018-08-16 20:34:44 +01:00
Nirbheek Chauhan ec29f19c12 Add a helper for fetching of binaries from cross files
A number of cases have to be taken care of while doing this, so
refactor it into a helper on ExternalProgram and use it everywhere.

1. Command is a list of len > 1, use it as-is
2. Command is a list of len == 1 (or a string), use as a string
3. If command is an absolute path, use it as-is
4. If command is not an absolute path, search for it
2018-07-01 13:59:48 +00:00
Jon Turney 7c4b8591b0 Make depends: of windows.compile_resources() include-able
Add the output directories for any custom target in depends: to the resource
compiler include path
2018-06-18 10:52:21 +00:00
Jon Turney c0f59399e4 Add a depends: keyword to windows.compile_resources()
Expose depends: from the custom_target this creates.
2018-06-18 10:52:21 +00:00
Jon Turney 884f38fe1b Use a unique name for windows resource compilation custom target 2018-06-07 18:11:49 +01:00
Nirbheek Chauhan 9b314c9c24 FeatureNew: add two features that were just merged 2018-06-05 15:57:57 +00:00
Jon Turney 7a15214a69 Have the windows.resource_compiler() preprocesor write a depfile
When using binutils's windres, we can instruct it to invoke the preprocessor
in such a way that it writes a depfile, so that dependencies on #included
files are automatically tracked.

Not implemented for MSVC tools, so skip testing it in that case.
2018-06-03 21:06:23 +00:00
Jon Turney aa27f7cec9 Add a depend_files: keyword to windows.compile_resources()
Expose depend_files: from the custom_target this creates.

This is the change suggested in #2815, with tests and documentation added.

Fixes #2789 (duplicate #2830)
2018-06-01 20:21:09 +00:00
Xavier Claessens b3f74b9c3a Windows: Fix exception when windres is not found
If rescomp is not found its command is None and that make meson print
backtrace instead of displaying the error message.
2018-05-21 23:29:06 +03:00