-
Notifications
You must be signed in to change notification settings - Fork 26
basic windows and macos build compatibility improvements #401
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
Conversation
@@ -150,6 +150,10 @@ if (VIAMCPPSDK_ENFORCE_COMPILER_MINIMA) | |||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) | |||
message(FATAL_ERROR "Insufficient Apple clang version: XCode 10.0+ required") | |||
endif() | |||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") |
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.
This establishes a compiler minimum for Windows. Since there is no history here, the newest Visual Studio seems like fair game. We can always try to downgrade it later if we find a need.
@@ -1,6 +1,5 @@ | |||
#include <fstream> | |||
#include <string> | |||
#include <unistd.h> |
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.
I don't know why all these files included <unistd.h>
and at least on my mac they appear to compile without it. We will see what CI says.
@@ -34,8 +34,18 @@ configure_file(common/grpc_fwd.hpp.in common/grpc_fwd.hpp) | |||
|
|||
# Set compile and link options based on arguments | |||
if (VIAMCPPSDK_USE_WALL_WERROR) | |||
target_compile_options(viamsdk PRIVATE -Wall -Werror) | |||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
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.
This enables warnings as errors flags for MSVC, and makes it an error if you ask for it and we can't do it on the current toolchain (or the toolchain is unknown).
@@ -4,8 +4,6 @@ | |||
#include <memory> | |||
#include <sstream> | |||
#include <string> | |||
#include <sys/socket.h> |
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.
I think these were only needed for the creation of the socket below, which we are no longer doing.
@@ -115,8 +113,8 @@ struct ModuleService::ServiceImpl : viam::module::v1::ModuleService::Service { | |||
Registry::get().lookup_model(cfg.name()); | |||
if (reg) { | |||
try { | |||
const std::shared_ptr<Resource> res = reg->construct_resource(deps, cfg); | |||
manager->replace_one(cfg.resource_name(), res); | |||
const std::shared_ptr<Resource> resource = reg->construct_resource(deps, cfg); |
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.
Windows throws a shadowing warning here which gets promoted to an error because we have res
above.
server_->register_service(impl_.get()); | ||
const std::string address = "unix://" + module_->addr(); | ||
const std::string address = "unix:" + module_->addr(); |
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.
This is actually the most important change. Please see https://grpc.github.io/grpc/cpp/md_doc_naming.html regarding unix://
vs unix:
. The former, which is what we were using before, requires an absolute path, and I was entirely unable to get it to work with Windows paths. However, the latter can handle both absolute and relative, and it seems to work just fine on windows.
@@ -216,7 +215,7 @@ void RobotClient::refresh_every() { | |||
std::this_thread::sleep_for(std::chrono::seconds(refresh_interval_)); | |||
refresh(); | |||
|
|||
} catch (std::exception& exc) { | |||
} catch (std::exception&) { |
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.
Windows warning that this was unused.
@@ -150,6 +150,11 @@ MLModelService::tensor_views make_sdk_tensor_from_api_tensor_t(const T* data, | |||
shape_accum = next_shape_accum; | |||
} | |||
|
|||
#ifdef _MSC_VER |
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.
A nuisance. Windows concludes that for one instantiation of the template that the conditional on 164 is tautologically true, which it is. But the point is to handle it for the instantiations where it is not a tautology. I opted to just to suppress the warning at the site.
@@ -55,7 +55,7 @@ void NavigationClient::set_mode(const Navigation::Mode mode, const ProtoStruct& | |||
request.set_mode(viam::service::navigation::v1::Mode(mode)); | |||
*request.mutable_extra() = to_proto(extra); | |||
}) | |||
.invoke([](auto& response) {}); | |||
.invoke([](auto&) {}); |
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.
Unused var name warnings on windows, here and below.
@@ -252,13 +250,8 @@ ModuleService::~ModuleService() { | |||
} | |||
|
|||
void ModuleService::serve() { | |||
const mode_t old_mask = umask(0077); |
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.
I forgot to mention this in my batch of comments. This code, which has been here forever, has always done nothing. It sure looked like it was making the socket that we were going to use for communication with RDK, but look carefully and you can see that we never actually bind the socket anywhere, or invoke it in any way. The actual socket gets made by gRPC.
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.
this looks good overall, __has_include
comment would be nice to address but non-blocking
Small fixes needed for building the C++ SDK on Windows. This is far from complete - this is just the stuff that seems reasonable to land as is. I'll leave some comments to explain a few things.