Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
Exporting platform_impl_lib headers (#8045)
Browse files Browse the repository at this point in the history
This allows consuming projects using repository overlaying to disambiguate overlapping include paths when it comes to platform_impl.h by going through envoy/external/...

Addendum to #8005

Risk Level: Low
Testing: N/A

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
  • Loading branch information
oschaaf authored and htuch committed Aug 27, 2019
1 parent 816d6f1 commit e1cd4cc
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 56 deletions.
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.

0 comments on commit e1cd4cc

Please sign in to comment.