From ea88fc197b83f8f4b5fa165615f5150fa3e63669 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Fri, 19 Aug 2016 00:20:59 -0700 Subject: [PATCH] Remove dependency on node c-ares --- BUILD | 6 +- CMakeLists.txt | 4 +- Makefile | 6 +- binding.gyp | 92 +++++++++++++++++-- build.yaml | 5 +- config.m4 | 2 +- gRPC-Core.podspec | 2 +- grpc.gemspec | 2 +- package.xml | 2 +- .../{dns_resolver.c => dns_resolver_ares.c} | 0 .../credentials/fake/fake_credentials.c | 1 - src/python/grpcio/grpc_core_dependencies.py | 2 +- templates/binding.gyp.template | 51 ++++++++-- tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/sources_and_headers.json | 2 +- vsprojects/vcxproj/grpc/grpc.vcxproj | 2 +- vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 2 +- .../grpc_unsecure/grpc_unsecure.vcxproj | 2 +- .../grpc_unsecure.vcxproj.filters | 2 +- 19 files changed, 149 insertions(+), 38 deletions(-) rename src/core/ext/resolver/dns/c_ares/{dns_resolver.c => dns_resolver_ares.c} (100%) diff --git a/BUILD b/BUILD index 7bb2c80925c..5379cc9503b 100644 --- a/BUILD +++ b/BUILD @@ -486,7 +486,7 @@ cc_library( "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", "src/core/ext/lb_policy/pick_first/pick_first.c", "src/core/ext/lb_policy/round_robin/round_robin.c", - "src/core/ext/resolver/dns/c_ares/dns_resolver.c", + "src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c", "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c", "src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c", "src/core/ext/resolver/dns/native/dns_resolver.c", @@ -1182,7 +1182,7 @@ cc_library( "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", "src/core/ext/client_config/uri_parser.c", - "src/core/ext/resolver/dns/c_ares/dns_resolver.c", + "src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c", "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c", "src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c", "src/core/ext/resolver/dns/native/dns_resolver.c", @@ -1987,7 +1987,7 @@ objc_library( "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", "src/core/ext/lb_policy/pick_first/pick_first.c", "src/core/ext/lb_policy/round_robin/round_robin.c", - "src/core/ext/resolver/dns/c_ares/dns_resolver.c", + "src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c", "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c", "src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c", "src/core/ext/resolver/dns/native/dns_resolver.c", diff --git a/CMakeLists.txt b/CMakeLists.txt index 5542d1eb61a..1c4b0f50e1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -450,7 +450,7 @@ add_library(grpc third_party/nanopb/pb_encode.c src/core/ext/lb_policy/pick_first/pick_first.c src/core/ext/lb_policy/round_robin/round_robin.c - src/core/ext/resolver/dns/c_ares/dns_resolver.c + src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c src/core/ext/resolver/dns/native/dns_resolver.c @@ -901,7 +901,7 @@ add_library(grpc_unsecure src/core/ext/client_config/subchannel_call_holder.c src/core/ext/client_config/subchannel_index.c src/core/ext/client_config/uri_parser.c - src/core/ext/resolver/dns/c_ares/dns_resolver.c + src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c src/core/ext/resolver/dns/native/dns_resolver.c diff --git a/Makefile b/Makefile index 20b11051f23..822138daf32 100644 --- a/Makefile +++ b/Makefile @@ -2753,7 +2753,7 @@ LIBGRPC_SRC = \ third_party/nanopb/pb_encode.c \ src/core/ext/lb_policy/pick_first/pick_first.c \ src/core/ext/lb_policy/round_robin/round_robin.c \ - src/core/ext/resolver/dns/c_ares/dns_resolver.c \ + src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c \ src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c \ src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c \ src/core/ext/resolver/dns/native/dns_resolver.c \ @@ -3452,7 +3452,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ src/core/ext/client_config/uri_parser.c \ - src/core/ext/resolver/dns/c_ares/dns_resolver.c \ + src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c \ src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c \ src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c \ src/core/ext/resolver/dns/native/dns_resolver.c \ @@ -6605,7 +6605,7 @@ PUBLIC_HEADERS_C += \ LIBARES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBARES_SRC)))) $(LIBARES_OBJS): CPPFLAGS += -Ithird_party/c-ares -Isrc/c-ares $(if $(subst Linux,,$(SYSTEM)),,-Isrc/c-ares/config_linux) $(if $(subst Darwin,,$(SYSTEM)),,-Isrc/c-ares/config_darwin) -fvisibility=hidden -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DHAVE_CONFIG_H -$(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion -Wno-invalid-source-encoding +$(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion -Wno-invalid-source-encoding -Wno-pointer-sign $(LIBDIR)/$(CONFIG)/libares.a: $(ZLIB_DEP) $(LIBARES_OBJS) $(E) "[AR] Creating $@" diff --git a/binding.gyp b/binding.gyp index cc942c239bf..4046226f87d 100644 --- a/binding.gyp +++ b/binding.gyp @@ -47,7 +47,8 @@ "include_dirs": [ "third_party/boringssl/include", "third_party/zlib", - "third_party/c-ares" + "third_party/c-ares", + "src/c-ares", ], "defines": [ '_WIN32_WINNT=0x0600', @@ -86,7 +87,8 @@ 'include_dirs': [ '<(node_root_dir)/deps/openssl/openssl/include', '<(node_root_dir)/deps/zlib', - '<(node_root_dir)/deps/cares/include' + "third_party/c-ares", + "src/c-ares" ], 'conditions': [ ['config=="gcov"', { @@ -485,7 +487,6 @@ }] ], 'targets': [ - { 'cflags': [ '-std=c99', @@ -563,7 +564,6 @@ 'type': 'static_library', 'dependencies': [ 'gpr', - 'node_modules/cares/deps/cares/cares.gyp:cares', ], 'sources': [ 'src/core/lib/surface/init.c', @@ -739,7 +739,7 @@ 'third_party/nanopb/pb_encode.c', 'src/core/ext/lb_policy/pick_first/pick_first.c', 'src/core/ext/lb_policy/round_robin/round_robin.c', - 'src/core/ext/resolver/dns/c_ares/dns_resolver.c', + 'src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c', 'src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c', 'src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c', 'src/core/ext/resolver/dns/native/dns_resolver.c', @@ -768,6 +768,86 @@ }] ] }, + { + 'cflags': [ + '-Wall', + '-Werror', + '-Wno-implicit-function-declaration' + ], + 'include_dirs': [ 'src/c-ares' ], + 'target_name': 'ares', + 'product_prefix': 'lib', + 'type': 'static_library', + 'dependencies': [ + ], + 'sources': [ + 'third_party/c-ares/ares__close_sockets.c', + 'third_party/c-ares/ares__get_hostent.c', + 'third_party/c-ares/ares__read_line.c', + 'third_party/c-ares/ares__timeval.c', + 'third_party/c-ares/ares_cancel.c', + 'third_party/c-ares/ares_create_query.c', + 'third_party/c-ares/ares_data.c', + 'third_party/c-ares/ares_destroy.c', + 'third_party/c-ares/ares_expand_name.c', + 'third_party/c-ares/ares_expand_string.c', + 'third_party/c-ares/ares_fds.c', + 'third_party/c-ares/ares_free_hostent.c', + 'third_party/c-ares/ares_free_string.c', + 'third_party/c-ares/ares_getenv.c', + 'third_party/c-ares/ares_gethostbyaddr.c', + 'third_party/c-ares/ares_gethostbyname.c', + 'third_party/c-ares/ares_getnameinfo.c', + 'third_party/c-ares/ares_getopt.c', + 'third_party/c-ares/ares_getsock.c', + 'third_party/c-ares/ares_init.c', + 'third_party/c-ares/ares_library_init.c', + 'third_party/c-ares/ares_llist.c', + 'third_party/c-ares/ares_mkquery.c', + 'third_party/c-ares/ares_nowarn.c', + 'third_party/c-ares/ares_options.c', + 'third_party/c-ares/ares_parse_a_reply.c', + 'third_party/c-ares/ares_parse_aaaa_reply.c', + 'third_party/c-ares/ares_parse_mx_reply.c', + 'third_party/c-ares/ares_parse_naptr_reply.c', + 'third_party/c-ares/ares_parse_ns_reply.c', + 'third_party/c-ares/ares_parse_ptr_reply.c', + 'third_party/c-ares/ares_parse_soa_reply.c', + 'third_party/c-ares/ares_parse_srv_reply.c', + 'third_party/c-ares/ares_parse_txt_reply.c', + 'third_party/c-ares/ares_platform.c', + 'third_party/c-ares/ares_process.c', + 'third_party/c-ares/ares_query.c', + 'third_party/c-ares/ares_search.c', + 'third_party/c-ares/ares_send.c', + 'third_party/c-ares/ares_strcasecmp.c', + 'third_party/c-ares/ares_strdup.c', + 'third_party/c-ares/ares_strerror.c', + 'third_party/c-ares/ares_timeout.c', + 'third_party/c-ares/ares_version.c', + 'third_party/c-ares/ares_writev.c', + 'third_party/c-ares/bitncmp.c', + 'third_party/c-ares/inet_net_pton.c', + 'third_party/c-ares/inet_ntop.c', + 'third_party/c-ares/windows_port.c', + ], + "conditions": [ + ['OS == "mac"', { + 'xcode_settings': { + 'MACOSX_DEPLOYMENT_TARGET': '10.9' + }, + 'include_dirs': [ 'src/c-ares/config_darwin' ], + 'defines': [ 'HAVE_CONFIG_H' ] + }], + ['OS == "linux"', { + 'include_dirs': [ 'src/c-ares/config_linux' ], + 'defines': [ 'HAVE_CONFIG_H' ] + }], + ['OS == "win"', { + 'defines': [ 'CARES_STATICLIB' ] + }] + ] + }, { 'include_dirs': [ " - + diff --git a/src/core/ext/resolver/dns/c_ares/dns_resolver.c b/src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c similarity index 100% rename from src/core/ext/resolver/dns/c_ares/dns_resolver.c rename to src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c diff --git a/src/core/lib/security/credentials/fake/fake_credentials.c b/src/core/lib/security/credentials/fake/fake_credentials.c index 6d3b3e448d8..93c25a61966 100644 --- a/src/core/lib/security/credentials/fake/fake_credentials.c +++ b/src/core/lib/security/credentials/fake/fake_credentials.c @@ -34,7 +34,6 @@ #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/executor.h" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 7eea66b8ca7..1d314331933 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -248,7 +248,7 @@ CORE_SOURCE_FILES = [ 'third_party/nanopb/pb_encode.c', 'src/core/ext/lb_policy/pick_first/pick_first.c', 'src/core/ext/lb_policy/round_robin/round_robin.c', - 'src/core/ext/resolver/dns/c_ares/dns_resolver.c', + 'src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c', 'src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c', 'src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c', 'src/core/ext/resolver/dns/native/dns_resolver.c', diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template index 739c016b1df..c5549e5cad2 100644 --- a/templates/binding.gyp.template +++ b/templates/binding.gyp.template @@ -49,7 +49,8 @@ "include_dirs": [ "third_party/boringssl/include", "third_party/zlib", - "third_party/c-ares" + "third_party/c-ares", + "src/c-ares", ], "defines": [ '_WIN32_WINNT=0x0600', @@ -88,7 +89,8 @@ 'include_dirs': [ '<(node_root_dir)/deps/openssl/openssl/include', '<(node_root_dir)/deps/zlib', - '<(node_root_dir)/deps/cares/include' + "third_party/c-ares", + "src/c-ares" ], 'conditions': [ ['config=="gcov"', { @@ -173,16 +175,9 @@ }] ], 'targets': [ - <% - for lib in libs: - if 'grpc' in lib.transitive_deps or lib.name == 'grpc': - lib.deps.append('node_modules/cares/deps/cares/cares.gyp:cares') - for module in node_modules: - module.deps.append('node_modules/cares/deps/cares/cares.gyp:cares') - %> % for module in node_modules: % for lib in libs: - % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'): + % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z', 'ares'): { 'cflags': [ '-std=c99', @@ -211,6 +206,42 @@ ] }, % endif + % if lib.name == 'ares': + { + 'cflags': [ + '-Wall', + '-Werror', + '-Wno-implicit-function-declaration' + ], + 'include_dirs': [ 'src/c-ares' ], + 'target_name': '${lib.name}', + 'product_prefix': 'lib', + 'type': 'static_library', + 'dependencies': [ + ], + 'sources': [ + % for source in lib.src: + '${source}', + % endfor + ], + "conditions": [ + ['OS == "mac"', { + 'xcode_settings': { + 'MACOSX_DEPLOYMENT_TARGET': '10.9' + }, + 'include_dirs': [ 'src/c-ares/config_darwin' ], + 'defines': [ 'HAVE_CONFIG_H' ] + }], + ['OS == "linux"', { + 'include_dirs': [ 'src/c-ares/config_linux' ], + 'defines': [ 'HAVE_CONFIG_H' ] + }], + ['OS == "win"', { + 'defines': [ 'CARES_STATICLIB' ] + }] + ] + }, + % endif % endfor { 'include_dirs': [ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e882f9a242e..fd5c963ee01 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1124,7 +1124,7 @@ third_party/nanopb/pb_decode.c \ third_party/nanopb/pb_encode.c \ src/core/ext/lb_policy/pick_first/pick_first.c \ src/core/ext/lb_policy/round_robin/round_robin.c \ -src/core/ext/resolver/dns/c_ares/dns_resolver.c \ +src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c \ src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c \ src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c \ src/core/ext/resolver/dns/native/dns_resolver.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index f868d38d15d..80c67e4cb41 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -6299,7 +6299,7 @@ "language": "c", "name": "grpc_resolver_dns_ares", "src": [ - "src/core/ext/resolver/dns/c_ares/dns_resolver.c", + "src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c", "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h", "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c", "src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c", diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index 2cbcf3e2352..f16e284503c 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -808,7 +808,7 @@ - + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index 07155137450..6d9c88ef5fa 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -520,7 +520,7 @@ src\core\ext\lb_policy\round_robin - + src\core\ext\resolver\dns\c_ares diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 7645ae38586..f9f6550bc48 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -699,7 +699,7 @@ - + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index fbe87f7be92..9a23008e245 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -409,7 +409,7 @@ src\core\ext\client_config - + src\core\ext\resolver\dns\c_ares