-
Notifications
You must be signed in to change notification settings - Fork 27
[RSDK-10385] Windows build system improvements and rust_utils workarounds #402
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| #ifdef _WIN32 | ||
| #define NOMINMAX | ||
| // clang-format off | ||
| // Otherwise clang-format tries to alphabetize these headers, | ||
| // but `winsock2.h` should definitely precede `windows.h`. | ||
| #include <winsock2.h> | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't love this. I'm surprised the gRPC headers don't handle this for themselves, but without this this file doesn't compile. The right way to do this would be with a global config precompiled header that got pulled into every
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| #include <windows.h> | ||
| // clang-format on | ||
| #endif | ||
|
|
||
| #include <viam/sdk/module/service.hpp> | ||
|
|
||
| #include <exception> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #if defined(__cplusplus) | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| // Prototypes for the entrypoints from viam_rust_utils | ||
| // that we use in the SDK. | ||
|
|
||
| void* init_rust_runtime(); | ||
| int free_rust_runtime(void* ptr); | ||
| void free_string(const char* s); | ||
| char* dial(const char* uri, | ||
| const char* entity, | ||
| const char* type, | ||
| const char* payload, | ||
| bool allow_insecure, | ||
| float timeout, | ||
| void* ptr); | ||
|
|
||
| #if defined(__cplusplus) | ||
| } // extern "C" | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #include <viam/sdk/rpc/private/viam_rust_utils.h> | ||
|
|
||
| #include <cstdlib> | ||
|
|
||
| // TODO(RSDK-10366): Currently, rust_utils is not published for windows | ||
| // so we just implement the associated entry points as `abort`. | ||
| #ifdef _WIN32 | ||
| void* init_rust_runtime() { | ||
| abort(); | ||
| } | ||
|
|
||
| int free_rust_runtime(void*) { | ||
| abort(); | ||
| } | ||
|
|
||
| void free_string(const char*) { | ||
| abort(); | ||
| } | ||
|
|
||
| char* dial(const char*, const char*, const char*, const char*, bool, float, void*) { | ||
| abort(); | ||
| } | ||
| #endif |
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.
instead of doing an
#if WIN32in the cpp file, what if we did this at the CMake level: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.
Sure, I'll give that a try, and as long as it works (which I expect it will) I'll merge with that.