Skip to content

Commit

Permalink
Build c-ares without running ./configure
Browse files Browse the repository at this point in the history
  • Loading branch information
y-zeng committed Aug 12, 2016
1 parent d790dd6 commit f64bf28
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
[submodule "third_party/c-ares"]
path = third_party/c-ares
url = https://github.com/c-ares/c-ares.git
branch = cares-1_11_0
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1252,8 +1252,6 @@ $(LIBDIR)/$(CONFIG)/c-ares/libcares.a: third_party/c-ares/configure
$(Q)$(MAKE) -C third_party/c-ares
$(Q)mkdir -p $(LIBDIR)/$(CONFIG)/c-ares
$(Q)cp third_party/c-ares/.libs/libcares.a $(LIBDIR)/$(CONFIG)
# $(Q)[ -f third_party/c-ares/.libs/libcares.2.dylib ] && cp third_party/c-ares/.libs/libcares.2.dylib $(LIBDIR)/$(CONFIG)/c-ares
# $(Q)[ -f third_party/c-ares/.libs/libcares.dylib ] && cp third_party/c-ares/.libs/libcares.dylib $(LIBDIR)/$(CONFIG)/c-ares

$(OBJDIR)/$(CONFIG)/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.o: third_party/c-ares/configure
$(OBJDIR)/$(CONFIG)/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.o: third_party/c-ares/configure
Expand Down Expand Up @@ -6615,8 +6613,10 @@ 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) -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

$(LIBDIR)/$(CONFIG)/libares.a: $(ZLIB_DEP) $(LIBARES_OBJS) $(CARES_DEP)
$(LIBDIR)/$(CONFIG)/libares.a: $(ZLIB_DEP) third_party/c-ares/configure $(LIBARES_OBJS) $(CARES_DEP)
$(E) "[AR] Creating $@"
$(Q) mkdir -p `dirname $@`
$(Q) rm -f $(LIBDIR)/$(CONFIG)/libares.a
Expand Down
9 changes: 4 additions & 5 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3375,11 +3375,10 @@ configs:
timeout_multiplier: 1.5
defaults:
ares:
CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas
-Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
-DHAVE_CONFIG_H
CPPFLAGS: -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM
-D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
CFLAGS: -Wno-sign-conversion -Wno-invalid-source-encoding
CPPFLAGS: -Ithird_party/c-ares -Isrc/c-ares $(if $(subst Linux,,$(SYSTEM)),,-Isrc/c-ares/config_linux)
-fvisibility=hidden -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0
-DNOMINMAX -DHAVE_CONFIG_H
boringssl:
CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas
-Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare $(NO_W_EXTRA_SEMI)
Expand Down
14 changes: 8 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@
CORE_INCLUDE = ('include', '.',)
BORINGSSL_INCLUDE = (os.path.join('third_party', 'boringssl', 'include'),)
ZLIB_INCLUDE = (os.path.join('third_party', 'zlib'),)
CARES_INCLUDE = (os.path.join('third_party', 'c-ares'), os.path.join('src', 'c-ares'),)
if "linux" in sys.platform:
CARES_INCLUDE += (os.path.join('src', 'c-ares', 'config_linux'),)
if "darwin" in sys.platform:
CARES_INCLUDE += (os.path.join('src', 'c-ares', 'config_darwin'),)
CARES_INCLUDE = (
os.path.join('third_party', 'c-ares'), os.path.join('src', 'c-ares'),)
if 'linux' in sys.platform:
CARES_INCLUDE += (os.path.join('src', 'c-ares', 'config_linux'),)
if 'darwin' in sys.platform:
CARES_INCLUDE += (os.path.join('src', 'c-ares', 'config_darwin'),)

# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
Expand Down Expand Up @@ -134,7 +135,8 @@
CORE_C_FILES = tuple(grpc_core_dependencies.CORE_SOURCE_FILES)

EXTENSION_INCLUDE_DIRECTORIES = (
(PYTHON_STEM,) + CORE_INCLUDE + BORINGSSL_INCLUDE + ZLIB_INCLUDE + CARES_INCLUDE)
(PYTHON_STEM,) + CORE_INCLUDE + BORINGSSL_INCLUDE + ZLIB_INCLUDE +
CARES_INCLUDE)

EXTENSION_LIBRARIES = ()
if "linux" in sys.platform:
Expand Down
3 changes: 1 addition & 2 deletions src/c-ares/gen_build_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ def ares_build(x):
gen_ares_build(x)
return 'third_party/c-ares/ares_build.h'



out['libs'] = [{
'name': 'ares',
'defaults': 'ares',
'build': 'private',
'language': 'c',
'secure': 'no',
Expand Down
5 changes: 3 additions & 2 deletions templates/Makefile.template
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,6 @@
$(Q)$(MAKE) -C third_party/c-ares
$(Q)mkdir -p $(LIBDIR)/$(CONFIG)/c-ares
$(Q)cp third_party/c-ares/.libs/libcares.a $(LIBDIR)/$(CONFIG)
# $(Q)[ -f third_party/c-ares/.libs/libcares.2.dylib ] && cp third_party/c-ares/.libs/libcares.2.dylib $(LIBDIR)/$(CONFIG)/c-ares
# $(Q)[ -f third_party/c-ares/.libs/libcares.dylib ] && cp third_party/c-ares/.libs/libcares.dylib $(LIBDIR)/$(CONFIG)/c-ares

$(OBJDIR)/$(CONFIG)/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.o: third_party/c-ares/configure
$(OBJDIR)/$(CONFIG)/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.o: third_party/c-ares/configure
Expand Down Expand Up @@ -1499,6 +1497,9 @@
% if lib.name != 'z':
$(ZLIB_DEP) \
% endif
% if lib.name == 'ares':
third_party/c-ares/configure \
% endif
% endif
% if lib.language == 'c++':
$(PROTOBUF_DEP)\
Expand Down
2 changes: 1 addition & 1 deletion third_party/c-ares
Submodule c-ares updated 94 files
+0 −1 .travis.yml
+0 −9 AUTHORS
+1 −1 Makefile.dj
+7 −6 Makefile.m32
+71 −7 Makefile.msvc
+62 −6 RELEASE-NOTES
+1 −1 acountry.c
+2 −2 ahost.c
+2 −4 appveyor.yml
+1 −1 ares_get_servers.3
+0 −1 ares_getnameinfo.c
+8 −9 ares_init.c
+2 −1 ares_library_init.c
+1 −1 ares_save_options.3
+1 −1 ares_set_servers.3
+1 −1 ares_set_servers_csv.3
+1 −1 ares_set_sortlist.3
+3 −3 ares_version.h
+1 −24 configure.ac
+0 −74 msvc_ver.inc
+1 −4 test/.gitignore
+2 −5 test/Makefile.am
+0 −3 test/Makefile.inc
+0 −48 test/Makefile.m32
+64 −4 test/Makefile.msvc
+4 −25 test/ares-fuzz.cc
+2 −3 test/ares-test-fuzz.cc
+0 −20 test/ares-test-init.cc
+2 −4 test/ares-test-live.cc
+1 −5 test/ares-test-main.cc
+6 −29 test/ares-test-mock.cc
+1 −1 test/ares-test.cc
+0 −35 test/dns-dump.cc
+0 −3 test/dns-proto.cc
+0 −3 test/fuzzcheck.sh
+ test/fuzzinput/004a216d3cff18b0c5c6b68b807f1529
+ test/fuzzinput/00539467ca159b36aea95e61f9729115
+ test/fuzzinput/00e846db8f43f2f507cd1666ed5a753e
+ test/fuzzinput/0177b7566f08c013699eaea9a77abeb3
+ test/fuzzinput/020a4fa317715bfdb236ed13751e6b65
+ test/fuzzinput/0310f2e81bea31f4fe3f330872a877dd
+ test/fuzzinput/0449be67df1730b2d0887d412a9b7cc4
+ test/fuzzinput/0449dd14f7aa94bf0d716bfe09b287a8
+ test/fuzzinput/04c93cdf7208979aa4df80a3a0d5a2d8
+ test/fuzzinput/0567e7171e08e75f3f91c4ca74c17adc
+ test/fuzzinput/05ba948578a397e9cbc6a7b3e78622fa
+ test/fuzzinput/060afe5ed25f3e2e86167e545f27edca
+ test/fuzzinput/06d47d3681493f1b1d41236f460d896f
+ test/fuzzinput/0724a810b0e131c2fddb6de9003b9064
+ test/fuzzinput/0b5279148826f5b962bcf1896bdb4ede
+ test/fuzzinput/114048c0f6b10bdc67ce9166405d195e
+ test/fuzzinput/11b8464a0ef8735d202955c34c36b0c7
+ test/fuzzinput/11cb626f1668c7b41954ce7d768fe528
+ test/fuzzinput/14b133bf18125b75a1976fa63a1df6b7
+ test/fuzzinput/153c6b3afa8faa03c8bc28f936a6d4cf
+ test/fuzzinput/182cad2a342ed7317b7c21a5d17020d1
+ test/fuzzinput/1c61a61bb7057b52c5b15188345a5238
+ test/fuzzinput/1dbe2cf62ed2e4fa1c3cb473f08710b5
+ test/fuzzinput/21199be504fcfece5c7096ee0dbba507
+ test/fuzzinput/21891480074b5635dbbe7137bdcabccd
+ test/fuzzinput/233aea42e15aa73e131eefabf16088c9
+ test/fuzzinput/24660d4e7ac7aa21d600ea7a3d198bbb
+ test/fuzzinput/25589deb55c08429345f289d1c9b0254
+ test/fuzzinput/2573bd823e4da11f727a17f8e1f35c26
+ test/fuzzinput/276f12da56866273e76059ad0e7be97e
+ test/fuzzinput/29198a2e380cb19babec9e02116d213e
+ test/fuzzinput/2c94ba9434b1a1b9396fc5364f101363
+ test/fuzzinput/2d578c357dc2f5e02dc55cddb30641d1
+ test/fuzzinput/2dff6cc5a223e67fde9e5e79af456992
+ test/fuzzinput/2f103b1f9477f2d8934bd84328d51c75
+ test/fuzzinput/31cd3a8413de13d9624adbb1613784bf
+ test/fuzzinput/36415bdf1d180098fe6234b4186e69f3
+ test/fuzzinput/3a04a80f0242e8dff0cd732e7c4767da
+ test/fuzzinput/44d0f973b7b0fb3e4a07770c943dcd5a
+ test/fuzzinput/50bc00daa0ddcd6cfb2b5d9f62c81f47
+ test/fuzzinput/51ed2d1fb77b3078b54e94e85606b7df
+ test/fuzzinput/5c5e0e899cf2e7d053a9e45fb76f6e5a
+ test/fuzzinput/70152ed033f139443fbfb1b858bb3b1b
+ test/fuzzinput/7030ca2b24e5a7f9dd8f62096a48eb33
+ test/fuzzinput/71eec1a0ef2d25bb9e2ef17f23be7e9e
+ test/fuzzinput/7a6b0177210ea4ef40b254daf99393c5
+ test/fuzzinput/7f1567733711ffb61839621af0cbfa33
+ test/fuzzinput/850c6d57c5bb7be8205fc2438d14d7e5
+ test/fuzzinput/a5c8cd2784a5792b9e91c2d7895b3b34
+ test/fuzzinput/a9135cdc7151d023300ff194bad90af9
+ test/fuzzinput/af2597e8ac7dec1e8b4a47518312912a
+ test/fuzzinput/b3f53ef826b831bb09dd25c7f5960249
+ test/fuzzinput/cda0f8751f5c4993974c2b549d29bcc8
+ test/fuzzinput/ce6c26c0e469339873d0e7f616ab0945
+ test/fuzzinput/e4dd7e7c2dd4ed7c2e17a6af5d04f9c9
+ test/fuzzinput/ed50ed8ee36230a5a69746ad830437e5
+ test/fuzzinput/f1b900d50806021953321c3b604ee497
+ test/fuzzinput/f89f6c8176b564a7dd646f14305573ce
+ test/fuzzinput/f9ad508d2dbd08d3aaaabc7d1174677d
2 changes: 2 additions & 0 deletions tools/buildgen/plugins/expand_bin_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ def mako_plugin(dictionary):
tgt['ci_platforms'] = sorted(tgt.get('ci_platforms', tgt['platforms']))
tgt['boringssl'] = tgt.get('boringssl', False)
tgt['zlib'] = tgt.get('zlib', False)
tgt['ares'] = tgt.get('ares', False)
tgt['gtest'] = tgt.get('gtest', False)

libs = dictionary.get('libs')
for lib in libs:
lib['boringssl'] = lib.get('boringssl', False)
lib['zlib'] = lib.get('zlib', False)
lib['ares'] = lib.get('ares', False)
1 change: 1 addition & 0 deletions tools/buildgen/plugins/expand_filegroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def uniquify(lst):
'language': 'c',
'boringssl': False,
'zlib': False,
'ares': False,
}


Expand Down
4 changes: 3 additions & 1 deletion tools/distrib/check_copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@
if args.precommit:
FILE_LIST_COMMAND = 'git status -z | grep -Poz \'(?<=^[MARC][MARCD ] )[^\s]+\''
else:
FILE_LIST_COMMAND = 'git ls-tree -r --name-only -r HEAD | grep -v ^third_party/'
FILE_LIST_COMMAND = 'git ls-tree -r --name-only -r HEAD | ' \
'grep -v ^third_party/ |' \
'grep -v "\(ares_config.h\|ares_build.h\)"'

def load(name):
with open(name) as f:
Expand Down

0 comments on commit f64bf28

Please sign in to comment.