Skip to content

Commit e4644bd

Browse files
authored
[libxml2] Fix compilation on iOS (microsoft#42695)
1 parent bda3f46 commit e4644bd

File tree

5 files changed

+95
-1
lines changed

5 files changed

+95
-1
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 0a279c8..8e771ee 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -136,7 +136,7 @@ if (NOT MSVC)
6+
check_include_files(fcntl.h HAVE_FCNTL_H)
7+
check_function_exists(fpclass HAVE_FPCLASS)
8+
check_function_exists(ftime HAVE_FTIME)
9+
- check_function_exists(getentropy HAVE_GETENTROPY)
10+
+ check_symbol_exists(getentropy "sys/random.h" HAVE_GETENTROPY)
11+
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
12+
check_library_exists(history append_history "" HAVE_LIBHISTORY)
13+
check_library_exists(readline readline "" HAVE_LIBREADLINE)
14+
@@ -149,7 +149,6 @@ if (NOT MSVC)
15+
check_function_exists(stat HAVE_STAT)
16+
check_include_files(stdint.h HAVE_STDINT_H)
17+
check_include_files(sys/mman.h HAVE_SYS_MMAN_H)
18+
- check_include_files(sys/random.h HAVE_SYS_RANDOM_H)
19+
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
20+
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
21+
check_include_files(sys/stat.h HAVE_SYS_STAT_H)
22+
diff --git a/config.h.cmake.in b/config.h.cmake.in
23+
index 2f4aeba..79f1cdb 100644
24+
--- a/config.h.cmake.in
25+
+++ b/config.h.cmake.in
26+
@@ -69,9 +69,6 @@
27+
/* Define to 1 if you have the <sys/mman.h> header file. */
28+
#cmakedefine HAVE_SYS_MMAN_H 1
29+
30+
-/* Define to 1 if you have the <sys/random.h> header file. */
31+
-#cmakedefine HAVE_SYS_RANDOM_H 1
32+
-
33+
/* Define to 1 if you have the <sys/select.h> header file. */
34+
#cmakedefine HAVE_SYS_SELECT_H 1
35+
36+
diff --git a/configure.ac b/configure.ac
37+
index 48cd2f0..0f09c61 100644
38+
--- a/configure.ac
39+
+++ b/configure.ac
40+
@@ -304,7 +304,6 @@ AC_CHECK_HEADERS([stdint.h])
41+
AC_CHECK_HEADERS([fcntl.h unistd.h sys/stat.h])
42+
AC_CHECK_HEADERS([sys/mman.h])
43+
AC_CHECK_HEADERS([sys/time.h sys/timeb.h])
44+
-AC_CHECK_HEADERS([sys/random.h])
45+
AC_CHECK_HEADERS([dl.h dlfcn.h])
46+
AC_CHECK_HEADERS([glob.h])
47+
AM_CONDITIONAL(WITH_GLOB, test "$ac_cv_header_glob_h" = "yes")
48+
@@ -317,9 +316,7 @@ AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */
49+
# undef /**/ HAVE_MMAP
50+
#endif])
51+
52+
-AC_CHECK_DECL([getentropy],
53+
- [AC_DEFINE([HAVE_GETENTROPY], [1], [getentropy])], [],
54+
- [#include <sys/random.h>])
55+
+AC_CHECK_DECLS([getentropy], [], [], [#include <sys/random.h>])
56+
57+
dnl
58+
dnl Checks for inet libraries
59+
diff --git a/dict.c b/dict.c
60+
index 49e1c6b..46bb4d4 100644
61+
--- a/dict.c
62+
+++ b/dict.c
63+
@@ -928,13 +928,11 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
64+
#define WIN32_LEAN_AND_MEAN
65+
#include <windows.h>
66+
#include <bcrypt.h>
67+
-#elif defined(HAVE_GETENTROPY)
68+
+#elif HAVE_GETENTROPY
69+
#ifdef HAVE_UNISTD_H
70+
#include <unistd.h>
71+
#endif
72+
- #ifdef HAVE_SYS_RANDOM_H
73+
- #include <sys/random.h>
74+
- #endif
75+
+ #include <sys/random.h>
76+
#else
77+
#include <time.h>
78+
#endif
79+
@@ -965,7 +963,7 @@ xmlInitRandom(void) {
80+
"error code %lu\n", GetLastError());
81+
abort();
82+
}
83+
-#elif defined(HAVE_GETENTROPY)
84+
+#elif HAVE_GETENTROPY
85+
while (1) {
86+
if (getentropy(globalRngState, sizeof(globalRngState)) == 0)
87+
break;

ports/libxml2/portfile.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ vcpkg_from_github(
1919
PATCHES
2020
disable-docs.patch
2121
fix_cmakelist.patch
22+
fix_ios_compilation.patch
2223
${FIX_COMPATIBILITY_PATCH}
2324
${ADD_MISSING_BCRYPT_PATCH}
2425
)

ports/libxml2/vcpkg.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "libxml2",
33
"version": "2.13.5",
4+
"port-version": 1,
45
"description": "Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform).",
56
"homepage": "https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home",
67
"license": "MIT",

versions/baseline.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5438,7 +5438,7 @@
54385438
},
54395439
"libxml2": {
54405440
"baseline": "2.13.5",
5441-
"port-version": 0
5441+
"port-version": 1
54425442
},
54435443
"libxmlmm": {
54445444
"baseline": "0.6.0",

versions/l-/libxml2.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"versions": [
3+
{
4+
"git-tree": "42ed1437607b934471807d0a2830d23d43f22bb1",
5+
"version": "2.13.5",
6+
"port-version": 1
7+
},
38
{
49
"git-tree": "f61ea0a7f998b892dc7eb51f6366867bef1d5353",
510
"version": "2.13.5",

0 commit comments

Comments
 (0)