Open dvrogozh opened 1 year ago
There are few paths forward with that I think:
library()
and executable()
to actually support building UMDF/KMDFdriver()
entrypoint to build drivers. At least for Windows. But maybe there are some extensions possible to cover Linux/OSX - I am really not sure here.I am in favor of 2nd item even if driver()
entrypoint will be Windows-only thing. Such entrypoint would be better visible for users and will cry out that meson does support UMDF/KMDF driver builds.
Adding
windows = import('windows')
windows.driver('name', 'src.c')
Seems like it should be straightforward enough.
2. But maybe there are some extensions possible to cover Linux/OSX - I am really not sure here.
For the Linux side of things this sounds more or less like "reimplement Kbuild". There is actually a draft PR that teaches meson to run the Kbuild make
as part of the external_project module... I'm not sure it's worth planning in advance to make this proposed feature generic enough to handle that.
Seems like it should be straightforward enough.
No, it's not. https://mesonbuild.com/Windows-module.html - this does not mention windows.driver()
driver whatsoever. And I did spend ~1-2 weeks looking around having no clue that windows.driver()
actually exists. Basically your reply is the first time I am getting aware of the this :)! I'll get it a try tomorrow, but documentation really needs an update.
If my request will transform to the docs update - that will be really good.
Adding it to the meson language, not adding it to your build file.
Oh, I misunderstood your initial reply thinking this might be some implemented feature I overlooked. Sorry for that. Looks like that's still to be implemented.
I'd also prefer to add it to the windows module first, and make it generic later if necessary. It's relatively easy to make the windows module version just an alias of the other if that happens, but having worked on out-of-tree linux modules, there's a lot going on there, and the external project module probably makes more sense
I'd also prefer to add it to the windows module first, and make it generic later if necessary.
I am fine with that.
2. Provide new dedicated
driver()
entrypoint to build drivers. At least for Windows. But maybe there are some extensions possible to cover Linux/OSX - I am really not sure here.
This would be also useful for Haiku. Haiku kernel modules are regular ELF shared libraries linked with kernel executable and some arch-dependent compiler flags like -mno-red-zone -mcmodel=kernel
. Haiku kernel modules must have no any prefixes or suffixed in file name because modules are searched and loaded by file name (wrong: libbfs.so
, right: bfs
).
Haiku kernel modules must have no any prefixes or suffixed in file name because modules are searched and loaded by file name
I wanted to say name_suffix: ''
is capable of doing that, but no, we specially emit an error message if you do to tell you that acquiring default per-platform behavior should be specified as an empty array.
Haiku kernel modules must have no any prefixes or suffixed in file name because modules are searched and loaded by file name
I wanted to say
name_suffix: ''
is capable of doing that, but no, we specially emit an error message if you do to tell you that acquiring default per-platform behavior should be specified as an empty array.
I attemted to make patch, but it is not so trivial as I expected: https://github.com/mesonbuild/meson/pull/11001.
Windows KMDF/UMDF driver builds require a) special compiler and linker flags, b) special set of libraries to link against, c) special additional steps to generate certain optional/required files for the driver installation (such as .cat files). As of today it is possible to achieve the goal to build KMDF/UMDF with meson if above steps will be carefully crafted. For example, with msys2 meson 1.1.1 installation on Windows 11 with MSVC2022 and 10.0.22621.0 and latest WDK it's possible to do something like this: https://github.com/dvrogozh/Windows-driver-samples/commit/f74b8dfb69d570753b201f88fd203e3a79b3666c (caveat: that's just example how to build with meson, that's not a runtime example). With provided meson.build steps:
In above I did reuse
shared_library()
andexecutable()
targets to build UMDF and KMDF respectfully. They both did not actually fully suite the need to build neither of these targets which is the problem. Probably it should be possible to overcome these issues by usingcustom_target()
, but a) this introduces additional complexity, b) it will entirely miss to generated UMDF/KMDF enabled MSVC solution. For the latter - MSVC does support UMDF/KMDF builds via specialized settings, for example:As of today with meson it is entirely not possible to generated UMDF/KMDF aware solution.
Summarizing, there are 2 feature requests
Note: the fact that building UMDF/KMDF might require special treatment was actually noted in the work done in https://github.com/mesonbuild/meson/issues/7765, but this was not never investigated as it seems.
Notes
In general, this summarizes some of my experience with UMDF/KMDF, hope this helps:
/ENTRY:FxDriverEntry
) and associated standard library to link against.inx -> .inf -> .cat
generation has circular dependency in.inf
(due tostampinf.exe
not having output)