Skip to content
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

Exporting platform_impl_lib headers #8045

Merged
merged 7 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 23 additions & 6 deletions source/exe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ envoy_cc_library(
],
deps = [
":envoy_main_common_lib",
] + envoy_cc_platform_dep("platform_impl_lib"),
":platform_impl_lib",
],
)

envoy_cc_library(
Expand All @@ -66,6 +67,7 @@ envoy_cc_library(
hdrs = ["main_common.h"],
deps = [
":envoy_common_lib",
":platform_impl_lib",
":process_wide_lib",
"//source/common/api:os_sys_calls_lib",
"//source/common/common:compiler_requirements_lib",
Expand All @@ -80,7 +82,7 @@ envoy_cc_library(
"//source/common/signal:sigaction_lib",
":terminate_handler_lib",
],
}) + envoy_cc_platform_dep("platform_impl_lib"),
}),
)

envoy_cc_library(
Expand All @@ -96,21 +98,36 @@ envoy_cc_library(
] + envoy_google_grpc_external_deps(),
)

envoy_cc_library(
name = "platform_impl_lib",
deps = [":platform_header_lib"] +
envoy_cc_platform_dep("platform_impl_lib"),
)

envoy_cc_library(
name = "platform_header_lib",
hdrs = ["platform_impl.h"],
deps = [
"//include/envoy/filesystem:filesystem_interface",
"//include/envoy/thread:thread_interface",
],
)

envoy_cc_posix_library(
name = "platform_impl_lib",
hdrs = ["posix/platform_impl.h"],
strip_include_prefix = "posix",
srcs = ["posix/platform_impl.cc"],
deps = [
":platform_header_lib",
"//source/common/common:thread_lib",
"//source/common/filesystem:filesystem_lib",
],
)

envoy_cc_win32_library(
name = "platform_impl_lib",
hdrs = ["win32/platform_impl.h"],
strip_include_prefix = "win32",
srcs = ["win32/platform_impl.cc"],
deps = [
":platform_header_lib",
"//source/common/common:assert_lib",
"//source/common/common:thread_lib",
"//source/common/filesystem:filesystem_lib",
Expand Down
19 changes: 19 additions & 0 deletions source/exe/platform_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include "envoy/filesystem/filesystem.h"
#include "envoy/thread/thread.h"

namespace Envoy {

class PlatformImpl {
public:
PlatformImpl();
Thread::ThreadFactory& threadFactory() { return *thread_factory_; }
Filesystem::Instance& fileSystem() { return *file_system_; }

private:
std::unique_ptr<Thread::ThreadFactory> thread_factory_;
std::unique_ptr<Filesystem::Instance> file_system_;
};

} // namespace Envoy
12 changes: 12 additions & 0 deletions source/exe/posix/platform_impl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "common/common/thread_impl.h"
#include "common/filesystem/filesystem_impl.h"

#include "exe/platform_impl.h"

namespace Envoy {

PlatformImpl::PlatformImpl()
: thread_factory_(std::make_unique<Thread::ThreadFactoryImplPosix>()),
file_system_(std::make_unique<Filesystem::InstanceImplPosix>()) {}

} // namespace Envoy
18 changes: 0 additions & 18 deletions source/exe/posix/platform_impl.h

This file was deleted.

26 changes: 26 additions & 0 deletions source/exe/win32/platform_impl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "common/common/assert.h"
#include "common/common/thread_impl.h"
#include "common/filesystem/filesystem_impl.h"

#include "exe/platform_impl.h"

// clang-format off
#include <winsock2.h>
// clang-format on

namespace Envoy {

PlatformImpl::PlatformImpl()
: thread_factory_(std::make_unique<Thread::ThreadFactoryImplWin32>()),
file_system_(std::make_unique<Filesystem::InstanceImplWin32>()) {
const WORD wVersionRequested = MAKEWORD(2, 2);
WSADATA wsaData;
const int rc = ::WSAStartup(wVersionRequested, &wsaData);
RELEASE_ASSERT(rc == 0, "WSAStartup failed with error");
}

~PlatformImpl() { ::WSACleanup(); }

}; // namespace Envoy

} // namespace Envoy
32 changes: 0 additions & 32 deletions source/exe/win32/platform_impl.h

This file was deleted.