-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Windows support #15
Windows support #15
Conversation
I keep getting the error This is what the
Any ideas @ssalonen? |
The idea of smoke test is to compile a small c application, including headers from cec project and linking to libcec shared library. Note that intent is not utilize vendor library in any way here. Even on linux this does not work by default, as the directories are not findable in the common distros without extra flags/environmental variables. However, when setting those environment variables, it offers the user a viable option without pkg config (or without pkg config files). You can find concrete example from github CI flow where this is tested. Are there similar same environment variables on windows? Is there precompiled distribution of libcec for windows? |
Based on quick googling visual studio might utilize these directories and env variables
If this is correct, it makes sense to keep the same smoke test with windows as well. Is this something you can try out at some point? I am not sure how hard would it be to setup windows github action to test all this... There seems to be supporting actions available https://github.com/marketplace/actions/setup-msbuild |
Yes, that sounds about right. The build script runs every compilation as to why I thought the smoke tests would fix it. There must be something in the I'll have to check out the github actions once everything looks good. |
I added a basic Windows test for vendored builds and it works well. The reason the I'm not sure what |
I understand the issue without the --release. Ideally it would make sense not use --release as some of the rust assertions are not active then. On the other hand, there are no tests at all in libcec-sys, so it's not a big deal here, more of a topic for cec-rs. Can we not compile the vendored build always as non-debug? I am not sure but is this how it goes with nix builds? Cross is not needed in windows here. In fact, it does not seem to support msvc, only gnu compiler https://github.com/cross-rs/cross Cross is used for cross compiling and running the tests with different architectures. My thinking was that this library might be used with different type of embedded environments / devices, so why not introduce the compilation check for it as well. However, since there is little platform specific code, it is not doing much now... |
BTW, on windows, does this build the library as statically linked to the application binary? Should it? I am not sure which way is the preferred way on windows. |
We could technically always compile libcec in release mode, although I'm assuming it may cancel out some of the debug assertions and other nice features. I guess the same also goes for Rust, so I'll add the correct python installation to CI. As for Cross, if it is no longer useful, do you think we should remove it? By default, according to here, it will compile dynamically before statically. I don't see any use for a dynamic library, especially when everything Rust is pretty much compiled statically and upstream crates will probably expect this to just "work," so I'll add an explicit check. |
I keep running into issues statically linking. When linking against |
There is also no easy way to find installed Visual Studio versions. An alternative would be to use the Edit: Although |
When testing static linking, did you remove the cargo:rustc-link-lib=cec? I think it is the thing that adds the link? EDIT: According to rustc docs, pointed by build script docs
They talk only about the attribute and cli arg but you would imagine the same applies for build scripts... |
No, I kept it as is and even tried changing it to |
You may be able to see for yourself if you fork my branch and run the CI. Tomorrow... well, later today for me, I could send u the output I get. There isn't much problem linking against a dynamic lib, but then it would have to be packaged with the binary I believe? It would definitely be preferable to statically link. |
Yes, I would expect static linking with windows while keeping dynamic linking with Linux. With Linux libcec is often easily available from distribution repos. We can always make this configurable as well, if need arises in the future. |
Was this resolved? Why is not ok to utilize the latest installed version? |
Regarding cross: On second thought it makes sense to ensure the build works, e.g. with arm (raspberry pi). This way we would get early failure already with libcec-sys, not with cec-rs, in case the build needs some adjustment. With windows we are only looking at non-gnu compilation (not mingw), thus, cross is not usable there. |
|
Should definitely cache python, it takes 1-2 minutes to install. The only thing left is to support static linking and add to the markdown files. I'll probably leave static linking for another PR, seems like it will be a pain. |
Thank you! This has been quite some work but really great to see windows supported as well 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review comments. Also, don't forget to update Readme (there is a statement on win support) and changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more final comment, then we are good to merge!
Big thank you! |
Closes #13
Support for Windows is fairly straightforward and libcec takes care of most of the work via their batch files.
Prerequisites:
TODO
vendor
submodule to latest commit #14.Release
andDebug
build.For now, I've hardcoded a few parameters just for testing.