webview_go
webview_go copied to clipboard
Support for EventToken.h on mingw64
@SteffenL Sorry for bringing this up again, because I know you have answered this question so many times:
- https://github.com/webview/webview_go/issues/40
- https://github.com/webview/webview_go/issues/32#issuecomment-1994886418
- https://github.com/webview/webview_go/issues/21#issuecomment-1855110818
- https://github.com/webview/webview_go/issues/20#issuecomment-1855112766
- https://github.com/webview/webview_go/issues/20#issuecomment-1855114803
- https://github.com/webview/webview_go/issues/17#issuecomment-1831236249
- https://github.com/webview/webview_go/issues/8#issuecomment-1732569840
I have a suggestion that might add better support for mingw64. Here are a few examples I want to present:
- https://learn.microsoft.com/en-us/windows/win32/api/eventtoken/
- https://github.com/microsoft/win32metadata/blob/main/generation/WinSDK/RecompiledIdlHeaders/winrt/EventToken.h
- https://learn.microsoft.com/en-us/windows/win32/api/eventtoken/ns-eventtoken-eventregistrationtoken
- https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/include/eventtoken.h
- https://github.com/ziglang/zig/blob/9be8a9000faead40b1aec4877506ff10b066659c/lib/libc/include/any-windows-any/eventtoken.h#L4
- https://github.com/search?q=eventtoken.h&type=code&p=2
Here is a screenshot of the file on my local system:
The associated verbose build output:
TERM='dumb' x86_64-w64-mingw32-g++ -I . -m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=$WORK/b500=/tmp/go-build -gno-record-gcc-switches -I $WORK/b500/ -I/nix/store/57s2nhck96xz82vpdq92jkii9c1q2bdq-mingw-w64-x86_64-w64-mingw32-11.0.1-headers/include -I/home/user/go/pkg/mod/github.com/webview/[email protected]/libs/webview/include -DWEBVIEW_STATIC -DWEBVIEW_EDGE -std=c++14 -I/home/user/go/pkg/mod/github.com/webview/[email protected]/libs/mswebview2/include -frandom-seed=Isb35zOTZ8oW2P-K900j -o $WORK/b500/_x004.o -c webview.cc
# github.com/webview/webview_go
In file included from /home/user/go/pkg/mod/github.com/webview/[email protected]/libs/webview/include/webview.h:2076,
from webview.cc:1:
/home/user/go/pkg/mod/github.com/webview/[email protected]/libs/mswebview2/include/WebView2.h:978:10: fatal error: EventToken.h: No such file or directory
978 | #include "EventToken.h"
| ^~~~~~~~~~~~~~
compilation terminated.
The important part in the above output is the additional header location added via -I/nix/store/57s2nhck96xz82vpdq92jkii9c1q2bdq-mingw-w64-x86_64-w64-mingw32-11.0.1-headers/include
, so that eventtoken.h
will be available for include.
It looks like the convention for referencing the "EventToken.h"
header with the mingw-64 compilation toolchain, is to use lowercase, e.g. <eventtoken.h>
. The Windows API docs itself also refers to this header in lowercase. However, searching GitHub, I can see that both variants are used.
What I'm trying to figure out, is whether this generated file (https://github.com/webview/webview_go/blob/master/libs/mswebview2/include/WebView2.h) could somehow be patched to use a lowercase include of eventtoken.h
, and whether that would still work for non-mingw builds.
@SteffenL Do you have insight in how WebView2.h is generated and whether somewhere in the process a lowercase include of eventtoken.h
can be used (if not for every toolchain, then specifically for the mingw toolchain)?