mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.5k stars 1.6k forks source link

Windows compile_resources() doesn't specify path dependency correctly #8612

Open nomis opened 3 years ago

nomis commented 3 years ago

Describe the bug My resource file #includes a generated resource file. The automatic include path for this is not specified correctly for use on Windows.

To Reproduce Remove include_directories from https://github.com/nomis/qmk-hid-identify/blob/062fff8f123a0724fd4db57e84c05567d9cd98df/windows/meson.build#L22 and build on Windows with mingw64.

Meson uses the path ./ as an include path which doesn't work as intended:

MINGW64 ~/Documents/qmk-hid-identify/windows/build/release (main)
$ "c:\Progra~1\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\windres.EXE" "-I./" "../../app.rc" "app.rc_app.o" "--preprocessor-arg=-MD" "--preprocessor-arg=-MQapp.rc_app.o" "--preprocessor-arg=-MFapp.rc_app.o.d"
../../app.rc:1:10: fatal error: events.rc: No such file or directory
 #include "events.rc"
          ^~~~~~~~~~~
compilation terminated.
C:\Progra~1\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\windres.EXE: preprocessing failed.

Expected behavior Meson should use the correct include path for the dependency.

System parameters

Ninja build file (native and cross-compile from Linux) Resource file with no dependencies:

# windows.compile_resources('app.rc')
COMMAND = /usr/bin/i686-w64-mingw32-windres ../../app.rc app.rc_app.o ...
COMMAND = "c:\Progra~1\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\windres.EXE" "../../app.rc" "app.rc_app.o" ...

Resource file with dependency adds build directory to the path but -I./ does not work on the Windows build of windres:

# windows.compile_resources('app.rc', depends: events_files)
COMMAND = /usr/bin/i686-w64-mingw32-windres -I./ ../../app.rc app.rc_app.o ...
COMMAND = "c:\Progra~1\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\windres.EXE" "-I./" "../../app.rc" "app.rc_app.o" ...

Resource file with dependency and '.' in the include path adds source and build directory to the path in a way that does work on the Windows build of windres:

# windows.compile_resources('app.rc', depends: events_files, include_directories: include_directories('.'))
COMMAND = /usr/bin/i686-w64-mingw32-windres -I./ -I./. -I../../. ../../app.rc app.rc_app.o ...
COMMAND = "c:\Progra~1\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\windres.EXE" "-I./" "-I./." "-I../../." "../../app.rc" "app.rc_app.o" "--preprocessor-arg=-MD" "--preprocessor-arg=-MQapp.rc_app.o" ...

Using either . or ./. or .\. works but ./ and .\ do not.

tristan957 commented 1 year ago

@nomis is this still an issue?

nomis commented 1 year ago

@nomis is this still an issue?

Yes, it's still an issue with Meson 0.61.5

tristan957 commented 1 year ago

Unfortunately there aren't many Meson developers that regularly contribute that use both Windows and mingw. Do you think you might be able to find some time to work on this issue? I am sure it would be very much appreciated!