Fix Windows UWP (Store) building and add to CI/CD (#627)

When building for UWP (WindowsStore), additional headers are needed and some functions are not available. This also adds AppVeyor CI/CD support to catch these issues in the future.

Fix By: Deal (@halx99) and Brad House (@bradh352)
pull/630/head
Brad House 1 year ago committed by GitHub
parent 320cefe1c7
commit 3db69bbfeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CMakeLists.txt
  2. 91
      appveyor.yml
  3. 1
      configure.ac
  4. 10
      src/lib/ares__addrinfo_localhost.c
  5. 33
      src/lib/ares__hosts_file.c
  6. 3
      src/lib/ares_config.h.cmake
  7. 2
      src/lib/ares_getnameinfo.c
  8. 2
      src/lib/ares_init.c
  9. 7
      src/lib/ares_sysconfig.c
  10. 2
      src/lib/ares_sysconfig_files.c
  11. 8
      src/lib/config-win32.h
  12. 2
      src/tools/CMakeLists.txt
  13. 1
      test/CMakeLists.txt

@ -219,8 +219,6 @@ CHECK_INCLUDE_FILES (sys/uio.h HAVE_SYS_UIO_H)
CHECK_INCLUDE_FILES (time.h HAVE_TIME_H)
CHECK_INCLUDE_FILES (dlfcn.h HAVE_DLFCN_H)
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILES (iphlpapi.h HAVE_IPHLPAPI_H)
# On OpenBSD, you must include sys/types.h before netinet/tcp.h
IF (HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES ("sys/types.h;netinet/tcp.h" HAVE_NETINET_TCP_H)
@ -234,6 +232,8 @@ ENDIF ()
IF (WIN32)
CHECK_INCLUDE_FILES ("winsock2.h;windows.h" HAVE_WINSOCK2_H)
CHECK_INCLUDE_FILES ("winsock2.h;ws2tcpip.h;windows.h" HAVE_WS2TCPIP_H)
CHECK_INCLUDE_FILES ("winsock2.h;iphlpapi.h;windows.h" HAVE_IPHLPAPI_H)
CHECK_INCLUDE_FILES ("winsock2.h;netioapi.h;windows.h" HAVE_NETIOAPI_H)
CHECK_INCLUDE_FILES ("winsock.h;windows.h" HAVE_WINSOCK_H)
CHECK_INCLUDE_FILES (windows.h HAVE_WINDOWS_H)
ENDIF ()

@ -12,6 +12,8 @@ skip_commits:
- .gitignore
- '**/*.md'
- .travis.yml
- .cirrus.yml
- '.github/**'
# List of build configurations to test.
configuration:
@ -21,49 +23,70 @@ configuration:
# CMAKE_EXTRA_OPTIONS: -DOPENSSL_ROOT_DIR=C:/OpenSSL-Win32
environment:
matrix:
# MSVC 2022, UWP (cmake)
- COMPILER: MSVC
BUILDTOOL: CMAKE
TESTTYPE: NONE
MSVC_SETUP_ARG: x64 store 10.0.22621.0
MSVC_SETUP_PATH: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat
CMAKE_EXTRA_OPTIONS: -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -A x64
TESTDIRSUFFIX: Release\
# MinGW via MSYS2 (latest version)
- COMPILER: MINGW
BUILDTOOL: MSYS2-CMAKE
BUILDTOOL: MSYS2
TESTTYPE: MSYS2
MSYSTEM: MINGW64
CHERE_INVOKING: YES
# MSVC 2015, 32-bit x86 (cmake)
# MSVC 2022, 32-bit x86 (cmake)
- COMPILER: MSVC
BUILDTOOL: CMAKE
TESTTYPE: CMAKE
MSVC_SETUP_ARG: x86
MSVC_SETUP_PATH: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat
CMAKE_EXTRA_OPTIONS: -GNinja
# MSVC 2015, 64-bit x86 (cmake)
# MSVC 2022, 64-bit x86 (cmake)
- COMPILER: MSVC
BUILDTOOL: CMAKE
TESTTYPE: CMAKE
MSVC_SETUP_ARG: x64
MSVC_SETUP_PATH: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
CMAKE_EXTRA_OPTIONS: -GNinja
# MinGW, 32-bit x86 (cmake)
- COMPILER: MINGW
BUILDTOOL: CMAKE
TESTTYPE: CMAKE
PATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;%PATH%
CMAKE_EXTRA_OPTIONS: -GNinja
# MinGW, 32-bit x86 (cmake static only)
- COMPILER: MINGW
BUILDTOOL: CMAKESTATIC
BUILDTOOL: CMAKE
TESTTYPE: CMAKE
PATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;%PATH%
CMAKE_EXTRA_OPTIONS: -DCARES_SHARED=OFF -GNinja
# MSVC 2015, 32-bit x86 (nmake)
# MSVC 2022, 32-bit x86 (nmake)
- COMPILER: MSVC
BUILDTOOL: NMAKE
TESTTYPE: NMAKE
MSVC_SETUP_ARG: x86
MSVC_SETUP_PATH: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat
# MSVC 2015, 64-bit x86 (nmake)
# MSVC 2022, 64-bit x86 (nmake)
- COMPILER: MSVC
BUILDTOOL: NMAKE
TESTTYPE: NMAKE
MSVC_SETUP_ARG: x64
MSVC_SETUP_PATH: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
# MinGW, 32-bit x86 (makefiles)
- COMPILER: MINGW
BUILDTOOL: MAKE
TESTTYPE: MAKE
PATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;%PATH%
install:
@ -73,48 +96,38 @@ before_build:
# Setup build environment for the selected compiler (not all compilers need to do anything here).
# -- Visual Studio --
- if "%COMPILER%" == "MSVC" call "%MSVC_SETUP_PATH%" %MSVC_SETUP_ARG%
- if "%BUILDTOOL%" == "MSYS2-CMAKE" C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu"
- if "%BUILDTOOL%" == "MSYS2-CMAKE" C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syu git mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-check mingw-w64-x86_64-ninja"
- if "%BUILDTOOL%" == "MSYS2" C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu"
- if "%BUILDTOOL%" == "MSYS2" C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syu git mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-check mingw-w64-x86_64-ninja"
build_script:
- if "%BUILDTOOL%" == "MSYS2-CMAKE" C:\msys64\usr\bin\bash -lc "cmake -GNinja -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=C:/projects/build-cares/test_install -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_BUILD_TESTS=ON %CMAKE_EXTRA_OPTIONS% ."
- if "%BUILDTOOL%" == "MSYS2-CMAKE" C:\msys64\usr\bin\bash -lc "ninja -v install"
- if "%BUILDTOOL%" == "MSYS2" C:\msys64\usr\bin\bash -lc "cmake -GNinja -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=C:/projects/build-cares/test_install -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_BUILD_TESTS=ON %CMAKE_EXTRA_OPTIONS% ."
- if "%BUILDTOOL%" == "MSYS2" C:\msys64\usr\bin\bash -lc "ninja -v install"
- if "%BUILDTOOL%" == "NMAKE" copy .\include\ares_build.h.dist .\include\ares_build.h
- if "%BUILDTOOL%" == "NMAKE" nmake /NOLOGO /f .\Makefile.msvc
- if "%BUILDTOOL%" == "CMAKE" mkdir C:\projects\build-cares
- if "%BUILDTOOL%" == "CMAKE" cd C:\projects\build-cares
- if "%BUILDTOOL%" == "CMAKE" cmake -GNinja -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=C:\projects\build-cares\test_install -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_BUILD_TESTS=ON %CMAKE_EXTRA_OPTIONS% %APPVEYOR_BUILD_FOLDER%
- if "%BUILDTOOL%" == "CMAKE" ninja -v install
- if "%BUILDTOOL%" == "CMAKESTATIC" mkdir C:\projects\build-cares
- if "%BUILDTOOL%" == "CMAKESTATIC" cd C:\projects\build-cares
- if "%BUILDTOOL%" == "CMAKESTATIC" cmake -GNinja -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=C:\projects\build-cares\test_install -DCARES_SHARED=OFF -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_BUILD_TESTS=ON %CMAKE_EXTRA_OPTIONS% %APPVEYOR_BUILD_FOLDER%
- if "%BUILDTOOL%" == "CMAKESTATIC" ninja -v install
- if "%BUILDTOOL%" == "CMAKE" cmake -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=C:\projects\build-cares\test_install -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_BUILD_TESTS=ON %CMAKE_EXTRA_OPTIONS% -Bbuild
- if "%BUILDTOOL%" == "CMAKE" cmake --build build --config Release
- if "%BUILDTOOL%" == "CMAKE" cmake --install build --config Release
- if "%BUILDTOOL%" == "MAKE" copy .\include\ares_build.h.dist .\include\ares_build.h
- if "%BUILDTOOL%" == "MAKE" mingw32-make.exe -f Makefile.m32 demos
test_script:
# We can't use powershell for tests due to treating stderr as an error
- if "%BUILDTOOL%" == "MSYS2-CMAKE" C:\msys64\usr\bin\bash -lc "./bin/adig.exe www.google.com"
- if "%BUILDTOOL%" == "MSYS2-CMAKE" C:\msys64\usr\bin\bash -lc "./bin/ahost.exe www.google.com"
- if "%BUILDTOOL%" == "MSYS2-CMAKE" C:\msys64\usr\bin\bash -lc "./bin/arestest.exe -4 -v --gtest_filter=-*LiveSearchTXT*:*LiveSearchANY*:*LiveGetLocalhostByAddr*"
- if "%BUILDTOOL%" == "NMAKE" cd test
- if "%BUILDTOOL%" == "NMAKE" nmake /NOLOGO /f .\Makefile.msvc vtest
- if "%BUILDTOOL%" == "NMAKE" nmake /NOLOGO /f .\Makefile.msvc aresfuzz aresfuzzname dnsdump
- if "%BUILDTOOL%" == "NMAKE" .\msvc\arestest\lib-debug\dnsdump.exe fuzzinput\answer_a fuzzinput\answer_aaaa
- if "%BUILDTOOL%" == "MAKE" cd test
- if "%BUILDTOOL%" == "MAKE" mingw32-make.exe -f Makefile.m32
- if "%BUILDTOOL%" == "MAKE" mingw32-make.exe -f Makefile.m32 aresfuzz.exe aresfuzzname.exe dnsdump.exe
- if "%BUILDTOOL%" == "MAKE" .\dnsdump.exe fuzzinput\answer_a fuzzinput\answer_aaaa
- if "%BUILDTOOL%" == "CMAKE" cd C:\projects\build-cares\bin
- if "%BUILDTOOL%" == "CMAKE" .\adig.exe www.google.com
- if "%BUILDTOOL%" == "CMAKE" .\ahost.exe www.google.com
- if "%BUILDTOOL%" == "CMAKE" .\arestest.exe -4 -v --gtest_filter=-*LiveSearchTXT*:*LiveSearchANY*:*LiveGetLocalhostByAddr*
- if "%BUILDTOOL%" == "CMAKE" .\dnsdump.exe "%APPVEYOR_BUILD_FOLDER%\test\fuzzinput\answer_a" "%APPVEYOR_BUILD_FOLDER%\test\fuzzinput\answer_aaaa"
- if "%BUILDTOOL%" == "CMAKESTATIC" cd C:\projects\build-cares\bin
- if "%BUILDTOOL%" == "CMAKESTATIC" .\adig.exe www.google.com
- if "%BUILDTOOL%" == "CMAKESTATIC" .\ahost.exe www.google.com
- if "%BUILDTOOL%" == "CMAKESTATIC" .\arestest.exe -4 -v --gtest_filter=-*LiveSearchTXT*:*LiveSearchANY*:*LiveGetLocalhostByAddr*
- if "%BUILDTOOL%" == "CMAKESTATIC" .\dnsdump.exe "%APPVEYOR_BUILD_FOLDER%\test\fuzzinput\answer_a" "%APPVEYOR_BUILD_FOLDER%\test\fuzzinput\answer_aaaa"
- if "%TESTTYPE%" == "MSYS2" C:\msys64\usr\bin\bash -lc "./bin/adig.exe www.google.com"
- if "%TESTTYPE%" == "MSYS2" C:\msys64\usr\bin\bash -lc "./bin/ahost.exe www.google.com"
- if "%TESTTYPE%" == "MSYS2" C:\msys64\usr\bin\bash -lc "./bin/arestest.exe -4 -v --gtest_filter=-*LiveSearchTXT*:*LiveSearchANY*:*LiveGetLocalhostByAddr*"
- if "%TESTTYPE%" == "NMAKE" cd test
- if "%TESTTYPE%" == "NMAKE" nmake /NOLOGO /f .\Makefile.msvc vtest
- if "%TESTTYPE%" == "NMAKE" nmake /NOLOGO /f .\Makefile.msvc aresfuzz aresfuzzname dnsdump
- if "%TESTTYPE%" == "NMAKE" .\msvc\arestest\lib-debug\dnsdump.exe fuzzinput\answer_a fuzzinput\answer_aaaa
- if "%TESTTYPE%" == "MAKE" cd test
- if "%TESTTYPE%" == "MAKE" mingw32-make.exe -f Makefile.m32
- if "%TESTTYPE%" == "MAKE" mingw32-make.exe -f Makefile.m32 aresfuzz.exe aresfuzzname.exe dnsdump.exe
- if "%TESTTYPE%" == "MAKE" .\dnsdump.exe fuzzinput\answer_a fuzzinput\answer_aaaa
- if "%TESTTYPE%" == "CMAKE" cd build\bin\%TESTDIRSUFFIX%
- if "%TESTTYPE%" == "CMAKE" .\adig.exe www.google.com
- if "%TESTTYPE%" == "CMAKE" .\ahost.exe www.google.com
- if "%TESTTYPE%" == "CMAKE" .\arestest.exe -4 -v --gtest_filter=-*LiveSearchTXT*:*LiveSearchANY*:*LiveGetLocalhostByAddr*
- if "%TESTTYPE%" == "CMAKE" .\dnsdump.exe "%APPVEYOR_BUILD_FOLDER%\test\fuzzinput\answer_a" "%APPVEYOR_BUILD_FOLDER%\test\fuzzinput\answer_aaaa"
#on_finish:
# - cd C:\projects\build-cares\test

@ -571,6 +571,7 @@ AC_CHECK_HEADERS(
sys/uio.h \
assert.h \
iphlpapi.h \
netioapi.h \
netdb.h \
netinet/in.h \
netinet/tcp.h \

@ -39,7 +39,15 @@
#if defined(_WIN32) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
# include <ws2ipdef.h>
# include <iphlpapi.h>
#endif
#if defined(USE_WINSOCK)
# if defined(HAVE_IPHLPAPI_H)
# include <iphlpapi.h>
# endif
# if defined(HAVE_NETIOAPI_H)
# include <netioapi.h>
# endif
#endif
#include "ares.h"

@ -750,31 +750,18 @@ static ares_status_t ares__hosts_path(const ares_channel_t *channel,
if (!path_hosts) {
#ifdef WIN32
char PATH_HOSTS[MAX_PATH];
win_platform platform;
PATH_HOSTS[0] = '\0';
platform = ares__getplatform();
if (platform == WIN_NT) {
char tmp[MAX_PATH];
HKEY hkeyHosts;
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
&hkeyHosts) == ERROR_SUCCESS) {
DWORD dwLength = MAX_PATH;
RegQueryValueExA(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
&dwLength);
ExpandEnvironmentStringsA(tmp, PATH_HOSTS, MAX_PATH);
RegCloseKey(hkeyHosts);
}
} else if (platform == WIN_9X) {
GetWindowsDirectoryA(PATH_HOSTS, MAX_PATH);
} else {
char PATH_HOSTS[MAX_PATH] = "";
char tmp[MAX_PATH];
HKEY hkeyHosts;
DWORD dwLength = sizeof(tmp);
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
&hkeyHosts) != ERROR_SUCCESS) {
return ARES_ENOTFOUND;
}
RegQueryValueExA(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
&dwLength);
ExpandEnvironmentStringsA(tmp, PATH_HOSTS, MAX_PATH);
RegCloseKey(hkeyHosts);
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
#elif defined(WATT32)
const char *PATH_HOSTS = _w32_GetHostsFile();

@ -182,6 +182,9 @@
/* Define to 1 if you have iphlpapi.h */
#cmakedefine HAVE_IPHLPAPI_H
/* Define to 1 if you have netioapi.h */
#cmakedefine HAVE_NETIOAPI_H
/* Define to 1 if you have the <limits.h> header file. */
#cmakedefine HAVE_LIMITS_H

@ -47,7 +47,7 @@
#ifdef HAVE_NET_IF_H
# include <net/if.h>
#endif
#ifdef HAVE_IPHLPAPI_H
#if defined(USE_WINSOCK) && defined(HAVE_IPHLPAPI_H)
# include <iphlpapi.h>
#endif

@ -57,7 +57,7 @@
# include <resolv.h>
#endif
#if defined(USE_WINSOCK)
#if defined(USE_WINSOCK) && defined(HAVE_IPHLPAPI_H)
# include <iphlpapi.h>
#endif

@ -58,7 +58,12 @@
#endif
#if defined(USE_WINSOCK)
# include <iphlpapi.h>
# if defined(HAVE_IPHLPAPI_H)
# include <iphlpapi.h>
# endif
# if defined(HAVE_NETIOAPI_H)
# include <netioapi.h>
# endif
#endif
#include "ares.h"

@ -57,7 +57,7 @@
# include <resolv.h>
#endif
#if defined(USE_WINSOCK)
#if defined(USE_WINSOCK) && defined(HAVE_IPHLPAPI_H)
# include <iphlpapi.h>
#endif

@ -84,6 +84,14 @@
# define HAVE_WS2TCPIP_H 1
#endif
/* Define if you have <iphlpapi.h> header file */
#define HAVE_IPHLPAPI_H 1
/* Define if you have <netioapi.h> header file */
#ifndef __WATCOMC__
# define HAVE_NETIOAPI_H 1
#endif
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1

@ -18,6 +18,7 @@ IF (CARES_BUILD_TOOLS)
SET_TARGET_PROPERTIES (ahost PROPERTIES
C_STANDARD 90
)
TARGET_COMPILE_DEFINITIONS (ahost PRIVATE HAVE_CONFIG_H=1)
TARGET_LINK_LIBRARIES (ahost PRIVATE ${PROJECT_NAME})
IF (CARES_INSTALL)
@ -38,6 +39,7 @@ IF (CARES_BUILD_TOOLS)
SET_TARGET_PROPERTIES (adig PROPERTIES
C_STANDARD 90
)
TARGET_COMPILE_DEFINITIONS (adig PRIVATE HAVE_CONFIG_H=1)
TARGET_LINK_LIBRARIES (adig PRIVATE ${PROJECT_NAME})
IF (CARES_INSTALL)

@ -35,7 +35,6 @@ add_library(gmock STATIC
)
target_include_directories(gmock PUBLIC SYSTEM ${GMOCK_DIR})
target_link_libraries(gmock PRIVATE ${CMAKE_THREAD_LIBS_INIT})
# test targets
transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")

Loading…
Cancel
Save