-
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
Changes from all 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,6 +1,5 @@ | ||
| #include <fstream> | ||
| #include <string> | ||
| #include <unistd.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 know why all these files included |
||
| #include <vector> | ||
|
|
||
| #include <viam/sdk/common/instance.hpp> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| #include <unistd.h> | ||
|
|
||
| #include <chrono> | ||
| #include <fstream> | ||
| #include <iostream> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
|
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. 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). |
||
| target_compile_options(viamsdk PRIVATE -Wall -Werror) | ||
| elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
| target_compile_options(viamsdk PRIVATE -Wall -Werror) | ||
| elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
| # Note: Currently, the generated protos throw W4244 and W4267, so turn that back to a warning. | ||
| target_compile_options(viamsdk PRIVATE /W4 /WX /wd4244 /wd4267) | ||
| else() | ||
| message(ERROR "VIAMCPPSDK_USE_WALL_ERROR is set, but not known how to enable for compiler ID ${CMAKE_CXX_COMPILER_ID}") | ||
| endif() | ||
| endif() | ||
|
|
||
| if (VIAMCPPSDK_SANITIZED_BUILD) | ||
| target_link_options(viamsdk PRIVATE -fsanitize=undefined -fno-omit-frame-pointer -fno-sanitize-recover) | ||
| target_compile_options(viamsdk PRIVATE -fsanitize=undefined -fno-omit-frame-pointer -fno-sanitize-recover) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,6 @@ | |
| #include <memory> | ||
| #include <sstream> | ||
| #include <string> | ||
| #include <sys/socket.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 think these were only needed for the creation of the socket below, which we are no longer doing. |
||
| #include <sys/stat.h> | ||
|
|
||
| #include <boost/log/trivial.hpp> | ||
| #include <boost/none.hpp> | ||
|
|
@@ -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); | ||
|
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. Windows throws a shadowing warning here which gets promoted to an error because we have |
||
| manager->replace_one(cfg.resource_name(), resource); | ||
| } catch (const std::exception& exc) { | ||
| return grpc::Status(::grpc::INTERNAL, exc.what()); | ||
| } | ||
|
|
@@ -252,13 +250,8 @@ ModuleService::~ModuleService() { | |
| } | ||
|
|
||
| void ModuleService::serve() { | ||
| const mode_t old_mask = umask(0077); | ||
|
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 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. |
||
| const int sockfd = socket(AF_UNIX, SOCK_STREAM, 0); | ||
| listen(sockfd, 10); | ||
| umask(old_mask); | ||
|
|
||
| server_->register_service(impl_.get()); | ||
| const std::string address = "unix://" + module_->addr(); | ||
| const std::string address = "unix:" + module_->addr(); | ||
|
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. This is actually the most important change. Please see https://grpc.github.io/grpc/cpp/md_doc_naming.html regarding |
||
| server_->add_listening_port(address); | ||
|
|
||
| module_->set_ready(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ | |
| #include <mutex> | ||
| #include <string> | ||
| #include <thread> | ||
| #include <unistd.h> | ||
| #include <vector> | ||
|
|
||
| #include <boost/log/trivial.hpp> | ||
|
|
@@ -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&) { | ||
|
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. Windows warning that this was unused. |
||
| break; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
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. 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. |
||
| #pragma warning(push) | ||
| #pragma warning(disable : 4127) | ||
| #endif | ||
|
|
||
| // We need to handle the special case of an odd number of 16-bit | ||
| // elements because that will arrive appearing to have one more | ||
| // element than the shape would indicate, and we don't want to | ||
|
|
@@ -160,6 +165,10 @@ MLModelService::tensor_views make_sdk_tensor_from_api_tensor_t(const T* data, | |
| size -= 1; | ||
| } | ||
|
|
||
| #ifdef _MSC_VER | ||
| #pragma warning(pop) | ||
| #endif | ||
|
|
||
| if (size != shape_accum) { | ||
| std::ostringstream message; | ||
| // TODO: Provide the shape and details | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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&) {}); | ||
|
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. Unused var name warnings on windows, here and below. |
||
| } | ||
|
|
||
| Navigation::LocationResponse NavigationClient::get_location(const ProtoStruct& extra) { | ||
|
|
@@ -81,7 +81,7 @@ void NavigationClient::add_waypoint(const geo_point& location, const ProtoStruct | |
| *request.mutable_location() = to_proto(location); | ||
| *request.mutable_extra() = to_proto(extra); | ||
| }) | ||
| .invoke([](auto& response) {}); | ||
| .invoke([](auto&) {}); | ||
| } | ||
|
|
||
| void NavigationClient::remove_waypoint(const std::string id, const ProtoStruct& extra) { | ||
|
|
@@ -90,7 +90,7 @@ void NavigationClient::remove_waypoint(const std::string id, const ProtoStruct& | |
| *request.mutable_id() = id; | ||
| *request.mutable_extra() = to_proto(extra); | ||
| }) | ||
| .invoke([](auto& response) {}); | ||
| .invoke([](auto&) {}); | ||
| } | ||
|
|
||
| std::vector<geo_geometry> NavigationClient::get_obstacles(const ProtoStruct& extra) { | ||
|
|
@@ -107,7 +107,7 @@ std::vector<NavigationClient::Path> NavigationClient::get_paths(const ProtoStruc | |
|
|
||
| NavigationClient::Properties NavigationClient::get_properties() { | ||
| return make_client_helper(this, *stub_, &StubType::GetProperties) | ||
| .with([&](auto& request) {}) | ||
| .with([&](auto&) {}) | ||
| .invoke([](auto& response) { return Properties{MapType(response.map_type())}; }); | ||
| } | ||
|
|
||
|
|
||
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.