From a3c4e7fe7b3e593bdd461adb8010af70cfaf95b9 Mon Sep 17 00:00:00 2001 From: Jesse Date: Tue, 24 May 2016 22:36:37 +0200 Subject: [PATCH] build: refactor building bundled c-ares Don't use Makefiles nor vcbuild.bat, integrate the build with the extension iteself. Adapted by @saghul --- deps/c-ares/Makefile | 95 ---- deps/c-ares/Makefile.msvc | 88 ---- deps/c-ares/config-mingw.mk | 35 -- deps/c-ares/config-unix.mk | 70 --- deps/c-ares/src/config_cygwin/ares_config.h | 512 -------------------- deps/c-ares/vcbuild.bat | 56 --- setup_cares.py | 175 +++---- 7 files changed, 77 insertions(+), 954 deletions(-) delete mode 100644 deps/c-ares/Makefile delete mode 100644 deps/c-ares/Makefile.msvc delete mode 100644 deps/c-ares/config-mingw.mk delete mode 100644 deps/c-ares/config-unix.mk delete mode 100644 deps/c-ares/src/config_cygwin/ares_config.h delete mode 100644 deps/c-ares/vcbuild.bat diff --git a/deps/c-ares/Makefile b/deps/c-ares/Makefile deleted file mode 100644 index e61492f..0000000 --- a/deps/c-ares/Makefile +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright Joyent, Inc. and other Node contributors. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. - -uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') - -ifdef MSVC -uname_S := MINGW -endif - -CPPFLAGS += -Isrc - -CARES_OBJS = -CARES_OBJS += src/ares__close_sockets.o -CARES_OBJS += src/ares__get_hostent.o -CARES_OBJS += src/ares__read_line.o -CARES_OBJS += src/ares__timeval.o -CARES_OBJS += src/ares_cancel.o -CARES_OBJS += src/ares_create_query.o -CARES_OBJS += src/ares_data.o -CARES_OBJS += src/ares_destroy.o -CARES_OBJS += src/ares_expand_name.o -CARES_OBJS += src/ares_expand_string.o -CARES_OBJS += src/ares_fds.o -CARES_OBJS += src/ares_free_hostent.o -CARES_OBJS += src/ares_free_string.o -CARES_OBJS += src/ares_gethostbyaddr.o -CARES_OBJS += src/ares_gethostbyname.o -CARES_OBJS += src/ares_getnameinfo.o -CARES_OBJS += src/ares_getopt.o -CARES_OBJS += src/ares_getsock.o -CARES_OBJS += src/ares_init.o -CARES_OBJS += src/ares_library_init.o -CARES_OBJS += src/ares_llist.o -CARES_OBJS += src/ares_nowarn.o -CARES_OBJS += src/ares_options.o -CARES_OBJS += src/ares_parse_a_reply.o -CARES_OBJS += src/ares_parse_aaaa_reply.o -CARES_OBJS += src/ares_parse_mx_reply.o -CARES_OBJS += src/ares_parse_naptr_reply.o -CARES_OBJS += src/ares_parse_ns_reply.o -CARES_OBJS += src/ares_parse_ptr_reply.o -CARES_OBJS += src/ares_parse_soa_reply.o -CARES_OBJS += src/ares_parse_srv_reply.o -CARES_OBJS += src/ares_parse_txt_reply.o -CARES_OBJS += src/ares_process.o -CARES_OBJS += src/ares_query.o -CARES_OBJS += src/ares_search.o -CARES_OBJS += src/ares_send.o -CARES_OBJS += src/ares_strcasecmp.o -CARES_OBJS += src/ares_strdup.o -CARES_OBJS += src/ares_strerror.o -CARES_OBJS += src/ares_timeout.o -CARES_OBJS += src/ares_version.o -CARES_OBJS += src/ares_writev.o -CARES_OBJS += src/bitncmp.o -CARES_OBJS += src/inet_net_pton.o -CARES_OBJS += src/inet_ntop.o - -ifneq (,$(findstring MINGW,$(uname_S))) -include config-mingw.mk -else -include config-unix.mk -endif - -all: libcares.a - -$(CARES_OBJS): %.o: %.c - $(CC) -o $*.o -c $(CFLAGS) $(CPPFLAGS) $< -DHAVE_CONFIG_H - - -.PHONY: clean distclean - -clean: - $(RM) -f src/*.o *.a - -distclean: - $(RM) -f src/*.o *.a - diff --git a/deps/c-ares/Makefile.msvc b/deps/c-ares/Makefile.msvc deleted file mode 100644 index ab4ce82..0000000 --- a/deps/c-ares/Makefile.msvc +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright Joyent, Inc. and other Node contributors. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. - -AR=lib.exe -CFLAGS = -MD -Isrc -Isrc\config_win32 -DHAVE_CONFIG_H - -CARES_OBJS = \ - src\ares__close_sockets.obj \ - src\ares__get_hostent.obj \ - src\ares__read_line.obj \ - src\ares__timeval.obj \ - src\ares_cancel.obj \ - src\ares_create_query.obj \ - src\ares_data.obj \ - src\ares_destroy.obj \ - src\ares_expand_name.obj \ - src\ares_expand_string.obj \ - src\ares_fds.obj \ - src\ares_free_hostent.obj \ - src\ares_free_string.obj \ - src\ares_gethostbyaddr.obj \ - src\ares_gethostbyname.obj \ - src\ares_getnameinfo.obj \ - src\ares_getopt.obj \ - src\ares_getsock.obj \ - src\ares_init.obj \ - src\ares_library_init.obj \ - src\ares_llist.obj \ - src\ares_nowarn.obj \ - src\ares_options.obj \ - src\ares_parse_a_reply.obj \ - src\ares_parse_aaaa_reply.obj \ - src\ares_parse_mx_reply.obj \ - src\ares_parse_naptr_reply.obj \ - src\ares_parse_ns_reply.obj \ - src\ares_parse_ptr_reply.obj \ - src\ares_parse_soa_reply.obj \ - src\ares_parse_srv_reply.obj \ - src\ares_parse_txt_reply.obj \ - src\ares_process.obj \ - src\ares_query.obj \ - src\ares_search.obj \ - src\ares_send.obj \ - src\ares_strcasecmp.obj \ - src\ares_strdup.obj \ - src\ares_strerror.obj \ - src\ares_timeout.obj \ - src\ares_version.obj \ - src\ares_writev.obj \ - src\bitncmp.obj \ - src\inet_net_pton.obj \ - src\inet_ntop.obj \ - src\windows_port.obj \ - src\ares_platform.obj - -all: cares.lib - -.c.obj: - $(CC) $(CFLAGS) -Fo$@ -c $< - -cares.lib: $(CARES_OBJS) - $(AR) /nodefaultlib /out:$@ $(CARES_OBJS) - -.PHONY: clean distclean - -clean: - del src\*.obj *.lib - -distclean: - del src\*.obj *.lib - diff --git a/deps/c-ares/config-mingw.mk b/deps/c-ares/config-mingw.mk deleted file mode 100644 index 3444148..0000000 --- a/deps/c-ares/config-mingw.mk +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright Joyent, Inc. and other Node contributors. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. - -# Use make -f Makefile.gcc PREFIX=i686-w64-mingw32- -# for cross compilation -CC = $(PREFIX)gcc -AR = $(PREFIX)ar -E=.exe - -CFLAGS += $(CPPFLAGS) -g --std=gnu89 -D_WIN32_WINNT=0x0600 -Isrc/config_win32 -LINKFLAGS+=-lm - -CARES_OBJS += src/windows_port.o -CARES_OBJS += src/ares_platform.o - -libcares.a: $(CARES_OBJS) - $(AR) rcs libcares.a $^ - diff --git a/deps/c-ares/config-unix.mk b/deps/c-ares/config-unix.mk deleted file mode 100644 index c1d28c5..0000000 --- a/deps/c-ares/config-unix.mk +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright Joyent, Inc. and other Node contributors. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. - -E= -CSTDFLAG=--std=c89 -pedantic -Wall -Wextra -Wno-unused-parameter -CFLAGS += -g -CPPFLAGS += -Iares -LINKFLAGS=-lm - -CPPFLAGS += -D_LARGEFILE_SOURCE -CPPFLAGS += -D_FILE_OFFSET_BITS=64 - -ifeq (SunOS,$(uname_S)) -CPPFLAGS += -Isrc/config_sunos -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 -LINKFLAGS+=-lsocket -lnsl -lkstat -endif - -ifeq (Darwin,$(uname_S)) -CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 -Isrc/config_darwin -endif - -ifeq (Linux,$(uname_S)) -CSTDFLAG += -D_GNU_SOURCE -CPPFLAGS += -Isrc/config_linux -LINKFLAGS+=-ldl -lrt -endif - -ifeq (FreeBSD,$(uname_S)) -CPPFLAGS += -Isrc/config_freebsd -LINKFLAGS+=-lkvm -endif - -ifeq (DragonFly,$(uname_S)) -CPPFLAGS += -Isrc/config_freebsd -endif - -ifeq (NetBSD,$(uname_S)) -CPPFLAGS += -Isrc/config_netbsd -endif - -ifeq (OpenBSD,$(uname_S)) -CPPFLAGS += -Isrc/config_openbsd -endif - -ifneq (,$(findstring CYGWIN,$(uname_S))) -# We drop the --std=c89, it hides CLOCK_MONOTONIC on cygwin -CSTDFLAG = -D_GNU_SOURCE -CPPFLAGS += -Isrc/config_cygwin -endif - -libcares.a: $(CARES_OBJS) - $(AR) rcs libcares.a $^ - diff --git a/deps/c-ares/src/config_cygwin/ares_config.h b/deps/c-ares/src/config_cygwin/ares_config.h deleted file mode 100644 index 592a245..0000000 --- a/deps/c-ares/src/config_cygwin/ares_config.h +++ /dev/null @@ -1,512 +0,0 @@ -/* ares_config.h. Generated from ares_config.h.in by configure. */ -/* ares_config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -/* #undef AC_APPLE_UNIVERSAL_BUILD */ - -/* define this if ares is built for a big endian system */ -/* #undef ARES_BIG_ENDIAN */ - -/* when building as static part of libcurl */ -/* #undef BUILDING_LIBCURL */ - -/* when building c-ares library */ -/* #undef CARES_BUILDING_LIBRARY */ - -/* when not building a shared library */ -/* #undef CARES_STATICLIB */ - -/* Define to 1 to enable hiding of library internal symbols. */ -#define CARES_SYMBOL_HIDING 1 - -/* Definition to make a library symbol externally visible. */ -#define CARES_SYMBOL_SCOPE_EXTERN __attribute__ ((visibility ("default"))) - -/* if a /etc/inet dir is being used */ -/* #undef ETC_INET */ - -/* Define to the type qualifier of arg 1 for getnameinfo. */ -#define GETNAMEINFO_QUAL_ARG1 const - -/* Define to the type of arg 1 for getnameinfo. */ -#define GETNAMEINFO_TYPE_ARG1 struct sockaddr * - -/* Define to the type of arg 2 for getnameinfo. */ -#define GETNAMEINFO_TYPE_ARG2 socklen_t - -/* Define to the type of args 4 and 6 for getnameinfo. */ -#define GETNAMEINFO_TYPE_ARG46 int - -/* Define to the type of arg 7 for getnameinfo. */ -#define GETNAMEINFO_TYPE_ARG7 int - -/* Specifies the number of arguments to getservbyport_r */ -/* #undef GETSERVBYPORT_R_ARGS */ - -/* Specifies the size of the buffer to pass to getservbyport_r */ -/* #undef GETSERVBYPORT_R_BUFSIZE */ - -/* Define to 1 if you have AF_INET6. */ -#define HAVE_AF_INET6 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ARPA_INET_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ARPA_NAMESER_COMPAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ARPA_NAMESER_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ASSERT_H 1 - -/* Define to 1 if you have the `bitncmp' function. */ -/* #undef HAVE_BITNCMP */ - -/* Define to 1 if bool is an available type. */ -#define HAVE_BOOL_T 1 - -/* Define to 1 if you have the clock_gettime function and monotonic timer. */ -/* #undef HAVE_CLOCK_GETTIME_MONOTONIC */ - -/* Define to 1 if you have the closesocket function. */ -/* #undef HAVE_CLOSESOCKET */ - -/* Define to 1 if you have the CloseSocket camel case function. */ -/* #undef HAVE_CLOSESOCKET_CAMEL */ - -/* Define to 1 if you have the connect function. */ -#define HAVE_CONNECT 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define to 1 if you have the fcntl function. */ -#define HAVE_FCNTL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have a working fcntl O_NONBLOCK function. */ -#define HAVE_FCNTL_O_NONBLOCK 1 - -/* Define to 1 if you have the freeaddrinfo function. */ -#define HAVE_FREEADDRINFO 1 - -/* Define to 1 if you have a working getaddrinfo function. */ -#define HAVE_GETADDRINFO 1 - -/* Define to 1 if the getaddrinfo function is threadsafe. */ -/* #undef HAVE_GETADDRINFO_THREADSAFE */ - -/* Define to 1 if you have the gethostbyaddr function. */ -#define HAVE_GETHOSTBYADDR 1 - -/* Define to 1 if you have the gethostbyname function. */ -#define HAVE_GETHOSTBYNAME 1 - -/* Define to 1 if you have the gethostname function. */ -#define HAVE_GETHOSTNAME 1 - -/* Define to 1 if you have the getnameinfo function. */ -#define HAVE_GETNAMEINFO 1 - -/* Define to 1 if you have the getservbyport_r function. */ -/* #undef HAVE_GETSERVBYPORT_R */ - -/* Define to 1 if you have the `gettimeofday' function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define to 1 if you have the `if_indextoname' function. */ -#define HAVE_IF_INDEXTONAME 1 - -/* Define to 1 if you have the `inet_net_pton' function. */ -/* #undef HAVE_INET_NET_PTON */ - -/* Define to 1 if inet_net_pton supports IPv6. */ -/* #undef HAVE_INET_NET_PTON_IPV6 */ - -/* Define to 1 if you have a IPv6 capable working inet_ntop function. */ -#define HAVE_INET_NTOP 1 - -/* Define to 1 if you have a IPv6 capable working inet_pton function. */ -#define HAVE_INET_PTON 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the ioctl function. */ -#define HAVE_IOCTL 1 - -/* Define to 1 if you have the ioctlsocket function. */ -/* #undef HAVE_IOCTLSOCKET */ - -/* Define to 1 if you have the IoctlSocket camel case function. */ -/* #undef HAVE_IOCTLSOCKET_CAMEL */ - -/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. - */ -/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */ - -/* Define to 1 if you have a working ioctlsocket FIONBIO function. */ -/* #undef HAVE_IOCTLSOCKET_FIONBIO */ - -/* Define to 1 if you have a working ioctl FIONBIO function. */ -#define HAVE_IOCTL_FIONBIO 1 - -/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */ -#define HAVE_IOCTL_SIOCGIFADDR 1 - -/* Define to 1 if you have the `resolve' library (-lresolve). */ -/* #undef HAVE_LIBRESOLVE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* if your compiler supports LL */ -#define HAVE_LL 1 - -/* Define to 1 if the compiler supports the 'long long' data type. */ -#define HAVE_LONGLONG 1 - -/* Define to 1 if you have the malloc.h header file. */ -#define HAVE_MALLOC_H 1 - -/* Define to 1 if you have the memory.h header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the MSG_NOSIGNAL flag. */ -#define HAVE_MSG_NOSIGNAL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_NETDB_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_NETINET_IN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_NETINET_TCP_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_NET_IF_H 1 - -/* Define to 1 if you have PF_INET6. */ -#define HAVE_PF_INET6 1 - -/* Define to 1 if you have the recv function. */ -#define HAVE_RECV 1 - -/* Define to 1 if you have the recvfrom function. */ -#define HAVE_RECVFROM 1 - -/* Define to 1 if you have the send function. */ -#define HAVE_SEND 1 - -/* Define to 1 if you have the setsockopt function. */ -#define HAVE_SETSOCKOPT 1 - -/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */ -/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define to 1 if sig_atomic_t is an available typedef. */ -#define HAVE_SIG_ATOMIC_T 1 - -/* Define to 1 if sig_atomic_t is already defined as volatile. */ -/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */ - -/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */ -#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1 - -/* Define to 1 if you have the socket function. */ -#define HAVE_SOCKET 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SOCKET_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDBOOL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define to 1 if you have the strcmpi function. */ -/* #undef HAVE_STRCMPI */ - -/* Define to 1 if you have the strdup function. */ -#define HAVE_STRDUP 1 - -/* Define to 1 if you have the stricmp function. */ -/* #undef HAVE_STRICMP */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the strncasecmp function. */ -#define HAVE_STRNCASECMP 1 - -/* Define to 1 if you have the strncmpi function. */ -/* #undef HAVE_STRNCMPI */ - -/* Define to 1 if you have the strnicmp function. */ -/* #undef HAVE_STRNICMP */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STROPTS_H */ - -/* Define to 1 if you have struct addrinfo. */ -#define HAVE_STRUCT_ADDRINFO 1 - -/* Define to 1 if you have struct in6_addr. */ -#define HAVE_STRUCT_IN6_ADDR 1 - -/* Define to 1 if you have struct sockaddr_in6. */ -#define HAVE_STRUCT_SOCKADDR_IN6 1 - -/* if struct sockaddr_storage is defined */ -#define HAVE_STRUCT_SOCKADDR_STORAGE 1 - -/* Define to 1 if you have the timeval struct. */ -#define HAVE_STRUCT_TIMEVAL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SOCKET_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_UIO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the windows.h header file. */ -/* #undef HAVE_WINDOWS_H */ - -/* Define to 1 if you have the winsock2.h header file. */ -/* #undef HAVE_WINSOCK2_H */ - -/* Define to 1 if you have the winsock.h header file. */ -/* #undef HAVE_WINSOCK_H */ - -/* Define to 1 if you have the writev function. */ -#define HAVE_WRITEV 1 - -/* Define to 1 if you have the ws2tcpip.h header file. */ -/* #undef HAVE_WS2TCPIP_H */ - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Define to 1 if you are building a native Windows target. */ -/* #undef NATIVE_WINDOWS */ - -/* Define to 1 if you need the malloc.h header file even with stdlib.h */ -/* #undef NEED_MALLOC_H */ - -/* Define to 1 if you need the memory.h header file even with stdlib.h */ -/* #undef NEED_MEMORY_H */ - -/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */ -/* #undef NEED_REENTRANT */ - -/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */ -/* #undef NEED_THREAD_SAFE */ - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - -/* cpu-machine-OS */ -#define OS "i686-pc-cygwin" - -/* Name of package */ -#define PACKAGE "c-ares" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "c-ares mailing list => http://cool.haxx.se/mailman/listinfo/c-ares" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "c-ares" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "c-ares 1.7.1" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "c-ares" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "1.7.1" - -/* a suitable file/device to read random data from */ -#define RANDOM_FILE "/dev/urandom" - -/* Define to the type of arg 1 for recvfrom. */ -#define RECVFROM_TYPE_ARG1 int - -/* Define to the type pointed by arg 2 for recvfrom. */ -#define RECVFROM_TYPE_ARG2 void - -/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */ -#define RECVFROM_TYPE_ARG2_IS_VOID 1 - -/* Define to the type of arg 3 for recvfrom. */ -#define RECVFROM_TYPE_ARG3 size_t - -/* Define to the type of arg 4 for recvfrom. */ -#define RECVFROM_TYPE_ARG4 int - -/* Define to the type pointed by arg 5 for recvfrom. */ -#define RECVFROM_TYPE_ARG5 struct sockaddr - -/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */ -/* #undef RECVFROM_TYPE_ARG5_IS_VOID */ - -/* Define to the type pointed by arg 6 for recvfrom. */ -#define RECVFROM_TYPE_ARG6 socklen_t - -/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */ -/* #undef RECVFROM_TYPE_ARG6_IS_VOID */ - -/* Define to the function return type for recvfrom. */ -#define RECVFROM_TYPE_RETV int - -/* Define to the type of arg 1 for recv. */ -#define RECV_TYPE_ARG1 int - -/* Define to the type of arg 2 for recv. */ -#define RECV_TYPE_ARG2 void * - -/* Define to the type of arg 3 for recv. */ -#define RECV_TYPE_ARG3 size_t - -/* Define to the type of arg 4 for recv. */ -#define RECV_TYPE_ARG4 int - -/* Define to the function return type for recv. */ -#define RECV_TYPE_RETV int - -/* Define as the return type of signal handlers (`int' or `void'). */ -#define RETSIGTYPE void - -/* Define to the type qualifier of arg 2 for send. */ -#define SEND_QUAL_ARG2 const - -/* Define to the type of arg 1 for send. */ -#define SEND_TYPE_ARG1 int - -/* Define to the type of arg 2 for send. */ -#define SEND_TYPE_ARG2 void * - -/* Define to the type of arg 3 for send. */ -#define SEND_TYPE_ARG3 size_t - -/* Define to the type of arg 4 for send. */ -#define SEND_TYPE_ARG4 int - -/* Define to the function return type for send. */ -#define SEND_TYPE_RETV int - -/* The size of `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* The size of `size_t', as computed by sizeof. */ -#define SIZEOF_SIZE_T 4 - -/* The size of `struct in6_addr', as computed by sizeof. */ -#define SIZEOF_STRUCT_IN6_ADDR 16 - -/* The size of `struct in_addr', as computed by sizeof. */ -#define SIZEOF_STRUCT_IN_ADDR 4 - -/* The size of `time_t', as computed by sizeof. */ -#define SIZEOF_TIME_T 4 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define to disable non-blocking sockets. */ -/* #undef USE_BLOCKING_SOCKETS */ - -/* Version number of package */ -#define VERSION "1.7.1" - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -/* # undef WORDS_BIGENDIAN */ -# endif -#endif - -/* Define to 1 if OS is AIX. */ -#ifndef _ALL_SOURCE -/* # undef _ALL_SOURCE */ -#endif - -/* Number of bits in a file offset, on hosts where this is settable. */ -/* #undef _FILE_OFFSET_BITS */ - -/* Define for large files, on AIX-style hosts. */ -/* #undef _LARGE_FILES */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Type to use in place of in_addr_t when system does not provide it. */ -/* #undef in_addr_t */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ - -/* the signed version of size_t */ -/* #undef ssize_t */ - -#define HAVE_GETENV 1 diff --git a/deps/c-ares/vcbuild.bat b/deps/c-ares/vcbuild.bat deleted file mode 100644 index e88907b..0000000 --- a/deps/c-ares/vcbuild.bat +++ /dev/null @@ -1,56 +0,0 @@ -@echo off - -cd %~dp0 - -if /i "%1"=="help" goto help -if /i "%1"=="--help" goto help -if /i "%1"=="-help" goto help -if /i "%1"=="/help" goto help -if /i "%1"=="?" goto help -if /i "%1"=="-?" goto help -if /i "%1"=="--?" goto help -if /i "%1"=="/?" goto help - -@rem Process arguments. -set target=Build - -:next-arg -if "%1"=="" goto args-done -if /i "%1"=="clean" set target=Clean&goto arg-ok -:arg-ok -shift -goto next-arg -:args-done - -if defined WindowsSDKDir goto select-target -if defined VCINSTALLDIR goto select-target - -@rem Look for Visual Studio 2008 -if not defined VS90COMNTOOLS goto vc-set-notfound -if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound -call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% -goto select-target - -:vc-set-notfound -echo Warning: Visual Studio not found - -:select-target -if "%target%"=="Build" goto compile -if "%target%"=="Clean" goto clean - -:compile -nmake /f Makefile.msvc -goto exit - -:clean -nmake /f Makefile.msvc clean -goto exit - -:help -echo vcbuild.bat [clean] -echo Examples: -echo vcbuild.bat : builds c-ares -echo vcbuild.bat clean : cleans the build -goto exit - -:exit diff --git a/setup_cares.py b/setup_cares.py index 0a57f05..97c4cc6 100644 --- a/setup_cares.py +++ b/setup_cares.py @@ -1,120 +1,99 @@ -import errno import os -import subprocess import sys -from distutils import log from distutils.command.build_ext import build_ext -from distutils.errors import DistutilsError -def exec_process(cmdline, silent=True, catch_enoent=True, input=None, **kwargs): - """Execute a subprocess and returns the returncode, stdout buffer and stderr buffer. - Optionally prints stdout and stderr while running.""" - try: - sub = subprocess.Popen(args=cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) - stdout, stderr = sub.communicate(input=input) +cares_sources = [ + 'deps/c-ares/src/ares__close_sockets.c', + 'deps/c-ares/src/ares__get_hostent.c', + 'deps/c-ares/src/ares__read_line.c', + 'deps/c-ares/src/ares__timeval.c', + 'deps/c-ares/src/ares_cancel.c', + 'deps/c-ares/src/ares_create_query.c', + 'deps/c-ares/src/ares_data.c', + 'deps/c-ares/src/ares_destroy.c', + 'deps/c-ares/src/ares_expand_name.c', + 'deps/c-ares/src/ares_expand_string.c', + 'deps/c-ares/src/ares_fds.c', + 'deps/c-ares/src/ares_free_hostent.c', + 'deps/c-ares/src/ares_free_string.c', + 'deps/c-ares/src/ares_gethostbyaddr.c', + 'deps/c-ares/src/ares_gethostbyname.c', + 'deps/c-ares/src/ares_getnameinfo.c', + 'deps/c-ares/src/ares_getopt.c', + 'deps/c-ares/src/ares_getsock.c', + 'deps/c-ares/src/ares_init.c', + 'deps/c-ares/src/ares_library_init.c', + 'deps/c-ares/src/ares_llist.c', + 'deps/c-ares/src/ares_mkquery.c', + 'deps/c-ares/src/ares_nowarn.c', + 'deps/c-ares/src/ares_options.c', + 'deps/c-ares/src/ares_parse_a_reply.c', + 'deps/c-ares/src/ares_parse_aaaa_reply.c', + 'deps/c-ares/src/ares_parse_mx_reply.c', + 'deps/c-ares/src/ares_parse_naptr_reply.c', + 'deps/c-ares/src/ares_parse_ns_reply.c', + 'deps/c-ares/src/ares_parse_ptr_reply.c', + 'deps/c-ares/src/ares_parse_soa_reply.c', + 'deps/c-ares/src/ares_parse_srv_reply.c', + 'deps/c-ares/src/ares_parse_txt_reply.c', + 'deps/c-ares/src/ares_process.c', + 'deps/c-ares/src/ares_query.c', + 'deps/c-ares/src/ares_search.c', + 'deps/c-ares/src/ares_send.c', + 'deps/c-ares/src/ares_strcasecmp.c', + 'deps/c-ares/src/ares_strdup.c', + 'deps/c-ares/src/ares_strerror.c', + 'deps/c-ares/src/ares_timeout.c', + 'deps/c-ares/src/ares_version.c', + 'deps/c-ares/src/ares_writev.c', + 'deps/c-ares/src/bitncmp.c', + 'deps/c-ares/src/inet_net_pton.c', + 'deps/c-ares/src/inet_ntop.c', +] - if type(stdout) != type(""): - # decode on Python 3 - # do nothing on Python 2 (it just doesn't care about encoding anyway) - stdout = stdout.decode(sys.getdefaultencoding(), "replace") - stderr = stderr.decode(sys.getdefaultencoding(), "replace") - - returncode = sub.returncode - if not silent: - sys.stdout.write(stdout) - sys.stderr.write(stderr) - except OSError as e: - if e.errno == errno.ENOENT and catch_enoent: - raise DistutilsError('"%s" is not present on this system' % cmdline[0]) - else: - raise - if returncode != 0: - raise DistutilsError('Got return value %d while executing "%s", stderr output was:\n%s' % (returncode, " ".join(cmdline), stderr.rstrip("\n"))) - return stdout - - -def exec_make(cmdline, *args, **kwargs): - assert isinstance(cmdline, list) - makes = ["make"] - if "bsd" in sys.platform: - makes.insert(0, "gmake") - for make in makes: - if "bsd" in sys.platform and make == "make": - log.warn("Running plain make on BSD-derived system. It will likely fail. Consider installing GNU make from the ports collection.") - try: - return exec_process([make] + cmdline, *args, catch_enoent=False, **kwargs) - except OSError as e: - if e.errno != errno.ENOENT: - raise - raise DistutilsError('"make" is not present on this system') +if sys.platform == 'win32': + cares_sources += ['deps/c-ares/src/windows_port.c', + 'deps/c-ares/src/ares_platform.c'] class cares_build_ext(build_ext): cares_dir = os.path.join('deps', 'c-ares') - user_options = build_ext.user_options - user_options.extend([ - ("cares-clean-compile", None, "Clean c-ares tree before compilation"), - ]) - boolean_options = build_ext.boolean_options - boolean_options.extend(["cares-clean-compile"]) - - def initialize_options(self): - build_ext.initialize_options(self) - self.cares_clean_compile = 0 - def build_extensions(self): - if self.compiler.compiler_type == 'mingw32': - # Dirty hack to avoid linking with more than one C runtime when using MinGW - self.compiler.dll_libraries = [lib for lib in self.compiler.dll_libraries if not lib.startswith('msvcr')] - self.force = self.cares_clean_compile - if self.compiler.compiler_type == 'msvc': - self.cares_lib = os.path.join(self.cares_dir, 'cares.lib') - else: - self.cares_lib = os.path.join(self.cares_dir, 'libcares.a') - self.build_cares() - # Set compiler options - if self.compiler.compiler_type == 'mingw32': - self.compiler.add_library_dir(self.cares_dir) - self.compiler.add_library('cares') - self.extensions[0].extra_objects = [self.cares_lib] + self.compiler.define_macro('HAVE_CONFIG_H', 1) self.compiler.add_include_dir(os.path.join(self.cares_dir, 'src')) + if sys.platform != 'win32': + self.compiler.define_macro('_LARGEFILE_SOURCE', 1) + self.compiler.define_macro('_FILE_OFFSET_BITS', 64) if sys.platform.startswith('linux'): + self.compiler.add_include_dir(os.path.join(self.cares_dir, 'src/config_linux')) + self.compiler.add_library('dl') self.compiler.add_library('rt') + elif sys.platform == 'darwin': + self.compiler.add_include_dir(os.path.join(self.cares_dir, 'src/config_darwin')) + self.compiler.define_macro('_DARWIN_USE_64_BIT_INODE', 1) + elif sys.platform.startswith('freebsd'): + self.compiler.add_include_dir(os.path.join(self.cares_dir, 'src/config_freebsd')) + self.compiler.add_library('kvm') + elif sys.platform.startswith('dragonfly'): + self.compiler.add_include_dir(os.path.join(self.cares_dir, 'src/config_freebsd')) + elif sys.platform.startswith('netbsd'): + self.compiler.add_include_dir(os.path.join(self.cares_dir, 'src/config_netbsd')) + elif sys.platform.startswith('openbsd'): + self.compiler.add_include_dir(os.path.join(self.cares_dir, 'src/config_openbsd')) + elif sys.platform.startswith('sunos'): + self.compiler.add_library('socket') + self.compiler.add_library('nsl') + self.compiler.add_library('lkstat') elif sys.platform == 'win32': - if self.compiler.compiler_type == 'msvc': - self.extensions[0].extra_link_args = ['/NODEFAULTLIB:libcmt'] - self.compiler.add_library('advapi32') + self.compiler.add_include_dir(os.path.join(self.cares_dir, 'src/config_win32')) + self.extensions[0].extra_link_args = ['/NODEFAULTLIB:libcmt'] + self.compiler.add_library('advapi32') self.compiler.add_library('iphlpapi') self.compiler.add_library('psapi') self.compiler.add_library('ws2_32') + self.extensions[0].sources += cares_sources build_ext.build_extensions(self) - - def build_cares(self): - #self.debug_mode = bool(self.debug) or hasattr(sys, 'gettotalrefcount') - win32_msvc = self.compiler.compiler_type == 'msvc' - def build(): - cflags = '-fPIC' - env = os.environ.copy() - env['CFLAGS'] = ' '.join(x for x in (cflags, env.get('CFLAGS', None)) if x) - log.info('Building c-ares...') - if win32_msvc: - exec_process('cmd.exe /C vcbuild.bat', cwd=self.cares_dir, env=env, shell=True, silent=False) - else: - exec_make(['libcares.a'], cwd=self.cares_dir, env=env, silent=False) - def clean(): - if win32_msvc: - exec_process('cmd.exe /C vcbuild.bat clean', cwd=self.cares_dir, shell=True) - else: - exec_make(['clean'], cwd=self.cares_dir) - if self.cares_clean_compile: - clean() - if not os.path.exists(self.cares_lib): - log.info('c-ares needs to be compiled.') - build() - else: - log.info('No need to build c-ares.') -