-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow windows-result
to work on non-Windows platforms
#3082
Allow windows-result
to work on non-Windows platforms
#3082
Conversation
What's the supporting rationale for this? |
I've opened an issue which describes the problem: #3083. Briefly, I need cross-platform COM to work. The |
We previously explored similar changes to support DirectX, its pseudo-COM semantics, and non-Windows targeting, but it showed signs of becoming a tangled web of related issues (e.g. mismatching wide strings).
There is no cross-platform COM though, right?
I'm not certain if this reflects a strong opinion or a shift in Microsoft's direction for this crate. I believe our current stance is to focus squarely on Windows targets only. @kennykerr thoughts? |
There is definitely cross-platform COM in the sense that code uses COM interfaces on different platforms. DWriteCore is a shipping Microsoft product that has a COM-based API, and ships on Android, iOS, Mac OS, and Linux desktop. DWriteCore is implemented mostly in Rust. We are currently using I understand that many parts of the Windows crates will naturally not work on other platforms. But for cross-platform development and for implementing systems that interoperate with Windows, such as systems that use COM or HRESULTs and such, this is important and is easily achievable. |
There are certainly many aspects of cross-platform support that are very problematic, such as is the case with strings, but I think we can provide some minimal support for things like the essentials of COM - boiling it down to I do however think that this PR is a little premature and we need to be a bit more deliberate about the scope of such work and that should be discussed in an issue like #3083 before we get too deep into an implementation such as this PR. |
72495ed
to
59c7328
Compare
Maybe some basic tests for https://github.com/microsoft/windows-rs/tree/master/crates/tests/linux/tests That way the |
59c7328
to
ec3495b
Compare
Added test coverage for functions that are different on non-Windows platforms. |
The Mac job runners appear to be failing, but without providing any error logs. :[ |
I'll just override - those runners are not too reliable. |
This updates the
windows-result
crate so that it can compile and work on non-Windows platforms. Right now, there are dependencies on things likeGetErrorInfo
, which are obviously not present on other platforms.This modifies
Error
so that theinfo
field is only present on Windows. Everything that reads/writes that field is also made conditional.I also manually imported definitions for some HRESULT constants, so that we did not need to rely on bindgen for them. This was necessary because none of the bindings should be used on non-Windows platforms. When we convert from
std::io::ErrorKind
toHRESULT
, we do our best to map things to error codes that make sense, although some of them are a bit of a stretch.This is one part of fixing #3083.