From a70102b1eb52346cfc5b5640df07516c66ef38cb Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 18 May 2018 07:46:22 -0700 Subject: [PATCH] Use cc rather than mm files and merge cfstream related files into core --- build.yaml | 23 ++----- include/grpc/impl/codegen/port_platform.h | 3 + .../iomgr/{error_apple.mm => error_apple.cc} | 2 +- src/core/lib/iomgr/iomgr_cfstream.cc | 66 ------------------- src/core/lib/iomgr/iomgr_cfstream.h | 26 -------- src/core/lib/iomgr/port.h | 4 +- .../{tcp_cfstream.mm => tcp_cfstream.cc} | 2 +- src/core/lib/iomgr/tcp_cfstream.h | 2 +- ..._cfstream_sync.mm => tcp_cfstream_sync.cc} | 2 +- src/core/lib/iomgr/tcp_cfstream_sync.h | 2 +- ...ent_cfstream.mm => tcp_client_cfstream.cc} | 2 +- templates/gRPC-Core.podspec.template | 10 --- 12 files changed, 19 insertions(+), 125 deletions(-) rename src/core/lib/iomgr/{error_apple.mm => error_apple.cc} (97%) delete mode 100644 src/core/lib/iomgr/iomgr_cfstream.cc delete mode 100644 src/core/lib/iomgr/iomgr_cfstream.h rename src/core/lib/iomgr/{tcp_cfstream.mm => tcp_cfstream.cc} (99%) rename src/core/lib/iomgr/{tcp_cfstream_sync.mm => tcp_cfstream_sync.cc} (99%) rename src/core/lib/iomgr/{tcp_client_cfstream.mm => tcp_client_cfstream.cc} (99%) diff --git a/build.yaml b/build.yaml index 73fd2cd0e93..ae0a1246bad 100644 --- a/build.yaml +++ b/build.yaml @@ -259,6 +259,7 @@ filegroups: - src/core/lib/iomgr/endpoint_pair_uv.cc - src/core/lib/iomgr/endpoint_pair_windows.cc - src/core/lib/iomgr/error.cc + - src/core/lib/iomgr/error_apple.cc - src/core/lib/iomgr/ev_epoll1_linux.cc - src/core/lib/iomgr/ev_epollex_linux.cc - src/core/lib/iomgr/ev_epollsig_linux.cc @@ -274,7 +275,6 @@ filegroups: - src/core/lib/iomgr/gethostname_sysconf.cc - src/core/lib/iomgr/iocp_windows.cc - src/core/lib/iomgr/iomgr.cc - - src/core/lib/iomgr/iomgr_cfstream.cc - src/core/lib/iomgr/iomgr_custom.cc - src/core/lib/iomgr/iomgr_internal.cc - src/core/lib/iomgr/iomgr_posix.cc @@ -306,7 +306,10 @@ filegroups: - src/core/lib/iomgr/socket_utils_uv.cc - src/core/lib/iomgr/socket_utils_windows.cc - src/core/lib/iomgr/socket_windows.cc + - src/core/lib/iomgr/tcp_cfstream.cc + - src/core/lib/iomgr/tcp_cfstream_sync.cc - src/core/lib/iomgr/tcp_client.cc + - src/core/lib/iomgr/tcp_client_cfstream.cc - src/core/lib/iomgr/tcp_client_custom.cc - src/core/lib/iomgr/tcp_client_posix.cc - src/core/lib/iomgr/tcp_client_windows.cc @@ -436,6 +439,7 @@ filegroups: - src/core/lib/iomgr/endpoint.h - src/core/lib/iomgr/endpoint_pair.h - src/core/lib/iomgr/error.h + - src/core/lib/iomgr/error_apple.h - src/core/lib/iomgr/error_internal.h - src/core/lib/iomgr/ev_epoll1_linux.h - src/core/lib/iomgr/ev_epollex_linux.h @@ -447,7 +451,6 @@ filegroups: - src/core/lib/iomgr/gethostname.h - src/core/lib/iomgr/iocp_windows.h - src/core/lib/iomgr/iomgr.h - - src/core/lib/iomgr/iomgr_cfstream.h - src/core/lib/iomgr/iomgr_custom.h - src/core/lib/iomgr/iomgr_internal.h - src/core/lib/iomgr/iomgr_posix.h @@ -478,6 +481,8 @@ filegroups: - src/core/lib/iomgr/socket_utils_posix.h - src/core/lib/iomgr/socket_windows.h - src/core/lib/iomgr/sys_epoll_wrapper.h + - src/core/lib/iomgr/tcp_cfstream.h + - src/core/lib/iomgr/tcp_cfstream_sync.h - src/core/lib/iomgr/tcp_client.h - src/core/lib/iomgr/tcp_client_posix.h - src/core/lib/iomgr/tcp_custom.h @@ -1336,20 +1341,6 @@ filegroups: deps: - grpc++ - grpc -- name: grpc_cfstream - language: objc++ - headers: - - src/core/lib/iomgr/error_apple.h - - src/core/lib/iomgr/tcp_cfstream.h - - src/core/lib/iomgr/tcp_cfstream_sync.h - src: - - src/core/lib/iomgr/error_apple.mm - - src/core/lib/iomgr/tcp_cfstream.mm - - src/core/lib/iomgr/tcp_cfstream_sync.mm - - src/core/lib/iomgr/tcp_client_cfstream.mm - uses: - - gpr_base_headers - - grpc_base_headers libs: - name: address_sorting build: all diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index bf1bf3df6a6..01ce5f03e96 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -227,7 +227,10 @@ #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 #define GPR_GETPID_IN_UNISTD_H 1 +/* TODO(mxyan): Remove when CFStream becomes default */ +#ifndef GRPC_CFSTREAM #define GPR_SUPPORT_CHANNELS_FROM_FD 1 +#endif #ifdef _LP64 #define GPR_ARCH_64 1 #else /* _LP64 */ diff --git a/src/core/lib/iomgr/error_apple.mm b/src/core/lib/iomgr/error_apple.cc similarity index 97% rename from src/core/lib/iomgr/error_apple.mm rename to src/core/lib/iomgr/error_apple.cc index 6976a798d44..e8f98bf0ba6 100644 --- a/src/core/lib/iomgr/error_apple.mm +++ b/src/core/lib/iomgr/error_apple.cc @@ -19,7 +19,7 @@ #include #ifdef GPR_APPLE -#import +#include #include #include diff --git a/src/core/lib/iomgr/iomgr_cfstream.cc b/src/core/lib/iomgr/iomgr_cfstream.cc deleted file mode 100644 index 2fde202b8a7..00000000000 --- a/src/core/lib/iomgr/iomgr_cfstream.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include "src/core/lib/iomgr/port.h" - -#ifdef GRPC_CFSTREAM_IOMGR - -#include "src/core/lib/debug/trace.h" -#include "src/core/lib/iomgr/ev_posix.h" -#include "src/core/lib/iomgr/iomgr_internal.h" -#include "src/core/lib/iomgr/iomgr_posix.h" -#include "src/core/lib/iomgr/resolve_address.h" -#include "src/core/lib/iomgr/tcp_client.h" -#include "src/core/lib/iomgr/tcp_posix.h" -#include "src/core/lib/iomgr/tcp_server.h" -#include "src/core/lib/iomgr/timer.h" - -extern grpc_tcp_client_vtable grpc_posix_tcp_client_vtable; -extern grpc_timer_vtable grpc_generic_timer_vtable; -extern grpc_pollset_vtable grpc_posix_pollset_vtable; -extern grpc_pollset_set_vtable grpc_posix_pollset_set_vtable; -extern grpc_address_resolver_vtable grpc_posix_resolver_vtable; - -static void iomgr_platform_init(void) { - grpc_wakeup_fd_global_init(); - grpc_event_engine_init(); -} - -static void iomgr_platform_flush(void) {} - -static void iomgr_platform_shutdown(void) { - grpc_event_engine_shutdown(); - grpc_wakeup_fd_global_destroy(); -} - -static grpc_iomgr_platform_vtable vtable = { - iomgr_platform_init, iomgr_platform_flush, iomgr_platform_shutdown}; - -void grpc_set_default_iomgr_platform() { - grpc_set_tcp_client_impl(&grpc_posix_tcp_client_vtable); - grpc_set_tcp_server_impl(nullptr); - grpc_set_timer_impl(&grpc_generic_timer_vtable); - grpc_set_pollset_vtable(&grpc_posix_pollset_vtable); - grpc_set_pollset_set_vtable(&grpc_posix_pollset_set_vtable); - grpc_set_resolver_impl(&grpc_posix_resolver_vtable); - grpc_set_iomgr_platform_vtable(&vtable); -} - -#endif /* GRPC_CFSTREAM_IOMGR */ diff --git a/src/core/lib/iomgr/iomgr_cfstream.h b/src/core/lib/iomgr/iomgr_cfstream.h deleted file mode 100644 index 19bc859bd56..00000000000 --- a/src/core/lib/iomgr/iomgr_cfstream.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_LIB_IOMGR_IOMGR_CFSTREAM_H -#define GRPC_CORE_LIB_IOMGR_IOMGR_CFSTREAM_H - -#include - -#include "src/core/lib/iomgr/iomgr_internal.h" - -#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_CFSTREAM_H */ diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index e1ca43aecc0..a1a029e1bfe 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -98,7 +98,7 @@ #define GRPC_POSIX_FORK 1 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 #ifdef GRPC_CFSTREAM -#define GRPC_CFSTREAM_IOMGR 1 +#define GRPC_POSIX_SOCKET_IOMGR 1 #define GRPC_CFSTREAM_TCP 1 #define GRPC_CFSTREAM_TCP_CLIENT 1 #define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1 @@ -110,6 +110,8 @@ #define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1 #define GRPC_POSIX_SOCKET_SOCKADDR 1 #define GRPC_POSIX_SOCKET_SOCKET_FACTORY 1 +#define GRPC_POSIX_SOCKET_TCP 1 +#define GRPC_POSIX_SOCKET_TCP_SERVER 1 #define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1 #define GRPC_POSIX_SOCKET_UTILS_COMMON 1 #else diff --git a/src/core/lib/iomgr/tcp_cfstream.mm b/src/core/lib/iomgr/tcp_cfstream.cc similarity index 99% rename from src/core/lib/iomgr/tcp_cfstream.mm rename to src/core/lib/iomgr/tcp_cfstream.cc index 04086aef6fc..7705b6dcd1b 100644 --- a/src/core/lib/iomgr/tcp_cfstream.mm +++ b/src/core/lib/iomgr/tcp_cfstream.cc @@ -21,7 +21,7 @@ #ifdef GRPC_CFSTREAM_TCP -#import +#import #import "src/core/lib/iomgr/tcp_cfstream.h" #include diff --git a/src/core/lib/iomgr/tcp_cfstream.h b/src/core/lib/iomgr/tcp_cfstream.h index dedcad49419..9f52f6a5de1 100644 --- a/src/core/lib/iomgr/tcp_cfstream.h +++ b/src/core/lib/iomgr/tcp_cfstream.h @@ -33,7 +33,7 @@ #ifdef GRPC_CFSTREAM -#import +#import #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/endpoint.h" diff --git a/src/core/lib/iomgr/tcp_cfstream_sync.mm b/src/core/lib/iomgr/tcp_cfstream_sync.cc similarity index 99% rename from src/core/lib/iomgr/tcp_cfstream_sync.mm rename to src/core/lib/iomgr/tcp_cfstream_sync.cc index 0c371ea2381..bc5bd0a6006 100644 --- a/src/core/lib/iomgr/tcp_cfstream_sync.mm +++ b/src/core/lib/iomgr/tcp_cfstream_sync.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/port.h" #ifdef GRPC_CFSTREAM -#import +#import #import "src/core/lib/iomgr/tcp_cfstream_sync.h" #include diff --git a/src/core/lib/iomgr/tcp_cfstream_sync.h b/src/core/lib/iomgr/tcp_cfstream_sync.h index ef9d41de269..9e1d8fbed96 100644 --- a/src/core/lib/iomgr/tcp_cfstream_sync.h +++ b/src/core/lib/iomgr/tcp_cfstream_sync.h @@ -24,7 +24,7 @@ #include "src/core/lib/iomgr/port.h" #ifdef GRPC_CFSTREAM -#import +#import #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/lockfree_event.h" diff --git a/src/core/lib/iomgr/tcp_client_cfstream.mm b/src/core/lib/iomgr/tcp_client_cfstream.cc similarity index 99% rename from src/core/lib/iomgr/tcp_client_cfstream.mm rename to src/core/lib/iomgr/tcp_client_cfstream.cc index c2c77bd9caf..61606ffd11c 100644 --- a/src/core/lib/iomgr/tcp_client_cfstream.mm +++ b/src/core/lib/iomgr/tcp_client_cfstream.cc @@ -22,7 +22,7 @@ #ifdef GRPC_CFSTREAM_TCP_CLIENT -#include +#include #include diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template index ff19aa313d6..8704a8a1381 100644 --- a/templates/gRPC-Core.podspec.template +++ b/templates/gRPC-Core.podspec.template @@ -68,14 +68,6 @@ excl = grpc_private_files(libs) return [file for file in out if not file in excl] - def cfstream_private_headers(libs): - out = grpc_lib_files(libs, ("grpc_cfstream",), ("headers",)) - return out - - def cfstream_private_files(libs): - out = grpc_lib_files(libs, ("grpc_cfstream",), ("src", "headers")) - return out - def ruby_multiline_list(files, indent): return (',\n' + indent*' ').join('\'%s\'' % f for f in files) %> @@ -189,8 +181,6 @@ ss.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'GRPC_CFSTREAM=1' } - ss.source_files = ${ruby_multiline_list(cfstream_private_files(filegroups), 22)} - ss.private_header_files = ${ruby_multiline_list(cfstream_private_headers(filegroups), 30)} end s.subspec 'Cronet-Interface' do |ss|