mstorsjo / llvm-mingw

An LLVM/Clang/LLD based mingw-w64 toolchain
Other
1.79k stars 176 forks source link

Windows Runtime (WinRT) APIs support #307

Open cristianadam opened 1 year ago

cristianadam commented 1 year ago

Windows 10 has been exposing APIs via Windows Runtime (WinRT) APIs. These APIs can also be used on Desktop, not just for Windows Store for UWP applications.

One example would be the Windows.Devices.Bluetooth Namespace which is described as:

The Windows.Devices.Bluetooth namespace defines a set of Windows Runtime API that allows UWP app and desktop apps to interact with Bluetooth devices

Qt 6.2 is using this with the MSVC compiler and has dropped the previous Win32 API version that MinGW was using.

This WinRT support is being offered by the The C++/WinRT language projection which is :

C++/WinRT is an entirely standard C++ language projection for Windows Runtime (WinRT) APIs, implemented as a header-file-based library, and designed to provide you with first-class access to the modern Windows API. With C++/WinRT, you can author and consume Windows Runtime APIs using any standards-compliant C++17 compiler.

Note that the project has a (closed) issue named MinGW GCC support, but since clang-cl can handle MSVC quirks, I think LLVM-MinGW would be in a better shape than the GCC MinGW.

This would be an extra argument for the QTBUG-107516 - Migrate from GCC MinGW to LLVM-MinGW migration.

driver1998 commented 3 weeks ago

It should be more or less done by now, so far nothing is terribly broken.

As for the headers, it is expected that one build their own from winmds. MSYS2 provides a prebuilt set in their repos though.

My take on various aspects of cppwinrt with MinGW: WinUI 3: https://github.com/driver1998/WinUI-MinGW XAML islands: https://github.com/driver1998/XamlMinGW UWP: https://github.com/driver1998/CoreAppMinGW in-proc WinRT Component: https://github.com/driver1998/winrt-component-mingw

alvinhochun commented 3 weeks ago

@alvinhochun any progress on this issue?

I have seen https://github.com/alvinhochun/mingw-w64-cppwinrt/ but I don't think cppwinrt headers / libraries are bundled with any mingw-w64 distro.

Just build the upstream tool and generate the headers yourself, or use MSYS2.

I haven't really managed to develop further on my ideas, mostly due to the lack of motivation (not needing to use it right now). I still don't think a mingw-w64 toolchain should bundle them, but I guess it is fine with MSYS2 since they are distributed as an individual package and it does get updated.