Skip to content

RSDK-10366 - rust utils for windows #416

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

Merged
merged 95 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
e9d3ea1
only prepend unix when using uds
stuqdog Apr 18, 2025
0e3b8af
untested download and install rust-utils for windows
stuqdog Apr 18, 2025
b968803
cr comments
stuqdog Apr 18, 2025
5d5bb2d
const correctness
stuqdog Apr 18, 2025
d9827e5
try windows build
stuqdog Apr 21, 2025
adff932
test it
stuqdog Apr 21, 2025
59fd83c
try getting all dependencies installed
stuqdog Apr 21, 2025
a8e1751
no setting buf_config_dir
stuqdog Apr 21, 2025
ff01f42
try earlier cmake
stuqdog Apr 21, 2025
96652c8
goldilocks cmake
stuqdog Apr 21, 2025
46dad50
set boost root
stuqdog Apr 21, 2025
1d1ad1e
set boost includedir, try to find librarydir
stuqdog Apr 21, 2025
3268789
try list better
stuqdog Apr 21, 2025
57e6d5d
set librarydir
stuqdog Apr 21, 2025
cb01ea7
set boost compiler
stuqdog Apr 21, 2025
5cf9590
12 not 13
stuqdog Apr 21, 2025
ff5a2bf
had boost compiler backwards
stuqdog Apr 21, 2025
bc83e5b
github action for grpc
stuqdog Apr 21, 2025
674e729
specify grpc version
stuqdog Apr 21, 2025
952c305
install grpc with vcpkg
stuqdog Apr 21, 2025
7e38e1b
powershell
stuqdog Apr 21, 2025
9eab8c5
typo
stuqdog Apr 21, 2025
d590eff
try conan instead
stuqdog Apr 22, 2025
2d7df41
build too
stuqdog Apr 22, 2025
f299251
py -m conan
stuqdog Apr 22, 2025
9e36c2f
fixup
stuqdog Apr 22, 2025
02660a3
refreshenv
stuqdog Apr 22, 2025
6728c57
more installs, set envvars, etc
stuqdog Apr 22, 2025
38667a8
format fix
stuqdog Apr 22, 2025
ae64216
specify cmake version
stuqdog Apr 22, 2025
1dd810f
syntax change
stuqdog Apr 22, 2025
15abea3
cleanup release a bit, print more info
stuqdog Apr 22, 2025
d6982be
get correct arch
stuqdog Apr 23, 2025
11e56e9
one more arch fix
stuqdog Apr 23, 2025
b1e8526
fix unix://, another arch fix
stuqdog Apr 23, 2025
e21ba06
hardcode lib prefix
stuqdog Apr 23, 2025
c7490e2
print system name
stuqdog Apr 23, 2025
758bacf
Merge branch 'main' into RSDK-10366-rust-utils-for-windows
stuqdog Apr 23, 2025
7e0953c
case sensitive
stuqdog Apr 26, 2025
c98af91
Merge branch 'RSDK-10366-rust-utils-for-windows' of ssh://github.com/…
stuqdog Apr 26, 2025
72004be
restart tests
stuqdog Apr 26, 2025
412cbb9
set shared library prefix earlier
stuqdog Apr 28, 2025
73c5410
cleaner
stuqdog Apr 28, 2025
b4c4b84
just hardcode lib
stuqdog Apr 28, 2025
de30df1
fixups from windows testing
stuqdog May 2, 2025
0b2512b
fix token
stuqdog May 2, 2025
4c29471
some cleanup
stuqdog May 2, 2025
add6916
remove comments to self
stuqdog May 2, 2025
d4cb253
a couple more comment cleanups
stuqdog May 2, 2025
89df7fb
add instructions for building on windows
stuqdog May 2, 2025
ba316a3
Merge branch 'main' of ssh://github.com/viamrobotics/viam-cpp-sdk int…
stuqdog May 2, 2025
f1ba0d3
try keeping shared for unix
stuqdog May 2, 2025
07470b2
try keeping shared for unix pt2
stuqdog May 2, 2025
3ee79d5
typo
stuqdog May 2, 2025
6e77560
static for windows only, import chrono
stuqdog May 2, 2025
59ed94e
nominmax for windows
stuqdog May 6, 2025
0f5812a
specify type
stuqdog May 6, 2025
c66a2e0
prepare for working rust-utils
stuqdog May 7, 2025
51de5d8
try stuff from CR comments
stuqdog May 7, 2025
a9b2337
dont install when static building
stuqdog May 7, 2025
7afa451
shared again
stuqdog May 7, 2025
1bd47b2
test from convo with drew
stuqdog May 7, 2025
d43865b
fix ordering of link libraries for rust-utils
stuqdog May 7, 2025
b3a339a
rust-utils always static
stuqdog May 7, 2025
4b68fda
invert check for installing rust-utils
stuqdog May 7, 2025
952702b
revert to linking to viamsdk, not rust-utils
stuqdog May 7, 2025
f1c1e4f
shift to install FILES
stuqdog May 7, 2025
ec59387
did I get conan stuff wrong
stuqdog May 8, 2025
5e15a93
always install
stuqdog May 8, 2025
e5a3a5a
typo
stuqdog May 8, 2025
b843938
workflow cleanup, print out info for to find where to copy from with …
stuqdog May 8, 2025
861a35c
remove commented out stuff
stuqdog May 8, 2025
6306025
cleanup
stuqdog May 8, 2025
9de2913
fixup ls
stuqdog May 8, 2025
2779b50
Merge branch 'main' of ssh://github.com/viamrobotics/viam-cpp-sdk int…
stuqdog May 8, 2025
1e042cf
try cmake invocation for windows
stuqdog May 8, 2025
c6382e1
conanfile always include rust-utils info
stuqdog May 8, 2025
c4143af
include .lib
stuqdog May 8, 2025
165ca0c
interface not private
stuqdog May 8, 2025
d292417
try cmake invocation again
stuqdog May 8, 2025
9095b79
typos
stuqdog May 8, 2025
84b1874
actually install
stuqdog May 8, 2025
bfc6faf
no install
stuqdog May 8, 2025
4ba53d5
no all
stuqdog May 8, 2025
7cb2dd7
all-build
stuqdog May 9, 2025
3186390
more comprehensive listing
stuqdog May 9, 2025
3d56ccc
fix release, comment out windows conan build for now
stuqdog May 9, 2025
b710c7a
remove unused code
stuqdog May 9, 2025
47aca71
Merge branch 'main' into RSDK-10366-rust-utils-for-windows
stuqdog May 9, 2025
b56ab5c
cr comments
stuqdog May 16, 2025
3693c60
Merge branch 'RSDK-10366-rust-utils-for-windows' of ssh://github.com/…
stuqdog May 16, 2025
9459e17
Merge branch 'main' into RSDK-10366-rust-utils-for-windows
stuqdog May 16, 2025
230b29d
cr comments, test direct choco invocation
abe-winter May 16, 2025
cd7690b
get primetime ready
stuqdog May 16, 2025
fa063e4
improve comment
stuqdog May 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,21 @@ if (viam_rust_utils_files)
${viam_rust_utils_file}
ONLY_IF_DIFFERENT
)
elseif(NOT WIN32) # TODO(RSDK-10366): Currently, rust_utils is not published for windows, so don't even try downloading
elseif(NOT WIN32 OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "X86") OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "X64")) # TODO(RSDK-10366): Currently, rust_utils is not published for windows aarch, so don't even try downloading
set(lvru_system_name ${CMAKE_SYSTEM_NAME})
if (CMAKE_SYSTEM_NAME STREQUAL "Cygwin")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is supporting cygwin something important?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I'm aware of, I wasn't sure so I was trying to be conservative.

set(lvru_system_name "windows")
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe elseif here?

if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(lvru_system_name "macosx")
endif()
set(lvru_system_processor ${CMAKE_SYSTEM_PROCESSOR})
if ((CMAKE_SYSTEM_PROCESSOR STREQUAL "X86") OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "X64"))
set(lvru_system_processor "x86_64")
endif()
file(
DOWNLOAD
https://github.com/viamrobotics/rust-utils/releases/latest/download/${CMAKE_SHARED_LIBRARY_PREFIX}viam_rust_utils-${lvru_system_name}_${CMAKE_SYSTEM_PROCESSOR}${CMAKE_STATIC_LIBRARY_SUFFIX}
https://github.com/viamrobotics/rust-utils/releases/latest/download/${CMAKE_SHARED_LIBRARY_PREFIX}viam_rust_utils-${lvru_system_name}_${lvru_system_processor}${CMAKE_STATIC_LIBRARY_SUFFIX}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should hopefully download rust-utils on windows systems when building the SDK. However, it is currently untested. When I next have access to a windows laptop I will test and confirm. If it doesn't work and is not trivial to get working, I will remove all of this and update the README with instructions on building from source.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is reasonably easy to spin up a windows machine in GCP and RDP into it if you just need a quick test.

${viam_rust_utils_file}
STATUS lvru_status
)
Expand Down
18 changes: 13 additions & 5 deletions src/viam/sdk/rpc/dial.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <algorithm>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be down with the other C++ standard library includes around line 4-5

#include <viam/sdk/rpc/dial.hpp>

#include <istream>
Expand Down Expand Up @@ -148,20 +149,27 @@ std::shared_ptr<ViamChannel> ViamChannel::dial(const char* uri,
if (opts.entity()) {
entity = opts.entity()->c_str();
}
char* socket_path = ::dial(
char* proxy_path = ::dial(
uri, entity, type, payload, opts.allows_insecure_downgrade(), float_timeout.count(), ptr);
if (socket_path == NULL) {
if (proxy_path == NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr is preferred, or just invert the check: if (!proxy_path) {

free_rust_runtime(ptr);
throw Exception(ErrorCondition::k_connection, "Unable to establish connecting path");
}

std::string address("unix://");
address += socket_path;
std::string localhost_prefix("127.0.0.1");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other forms of localhost, like ::1. Probably not important?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the address we get back from rust-utils is consistently of the form 127.0.0.1:{port} so I opted for that.

auto tcp_check = std::mismatch(localhost_prefix.begin(), localhost_prefix.end(), proxy_path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why std::mismatch over just std::string::find? and comparing to npos? Is this doing something more than just checking for "127.0.0.1" as a substring?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no good reason why! I asked the internet how to find a substring in C++ and somehow the first thing I landed on was an SO post recommending std::mismatch 😅 I'll switch to std::string::find.

std::string address;
if (tcp_check.first != localhost_prefix.end()) {
// proxy path is not a localhost address and is therefore a UDS socket
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S socket is redundant. Maybe better to say it fully as unix domain socket (UDS).

address += "unix://";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 62d40eb#diff-03661151ee3ff17fde17964451d2ea2fbd2322f2bd21f4851eade22a2aaad233R254, I found that using unix: enabled Windows support, while I couldn't get anything with unix:// to work on windows. Per the gRPC docs, the only difference between the two is that the latter form with unix:// is restricted to absolute paths, while unix: will accept either: https://grpc.github.io/grpc/cpp/md_doc_naming.html.

It might be worth considering just making the switch to unix: here now, in case client usage on Windows is ever required, this hard to find fact will not need to be rediscovered.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good call, I'm happy to change this to unix:.

fwiw this PR is actually enabling windows client usage! The restriction was UDS support in tokio, but now that rust-utils will be using TCP sockets instead on windows, this PR enables us to use rust-utils on windows. but this change definitely still seems good, especially if tokio ever starts supporting UDS on windows.

}
address += proxy_path;

const std::shared_ptr<grpc::Channel> channel =
impl::create_viam_channel(address, grpc::InsecureChannelCredentials());
const std::unique_ptr<viam::robot::v1::RobotService::Stub> st =
viam::robot::v1::RobotService::NewStub(channel);
return std::make_shared<ViamChannel>(channel, socket_path, ptr);
return std::make_shared<ViamChannel>(channel, proxy_path, ptr);
};

unsigned int Options::refresh_interval() const {
Expand Down