Skip to content

Commit bd31ef3

Browse files
committed
fix: workaround for compilation errors on macOS
1 parent 380045d commit bd31ef3

File tree

2 files changed

+87
-1
lines changed

2 files changed

+87
-1
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ http_archive(
111111
"-p1",
112112
],
113113
patches = [
114-
"@mediapipe//third_party:zlib.diff",
114+
"@//third_party:zlib.patch",
115115
],
116116
sha256 = "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30",
117117
strip_prefix = "zlib-1.2.13",

third_party/zlib.patch

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
diff --git a/contrib/minizip/ioapi.h b/contrib/minizip/ioapi.h
2+
index ae9ca7e..a5e0d07 100644
3+
--- a/contrib/minizip/ioapi.h
4+
+++ b/contrib/minizip/ioapi.h
5+
@@ -21,7 +21,7 @@
6+
#ifndef _ZLIBIOAPI64_H
7+
#define _ZLIBIOAPI64_H
8+
9+
-#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
10+
+#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!defined(__ANDROID__))
11+
12+
// Linux needs this to support file operation on files larger then 4+GB
13+
// But might need better if/def to select just the platforms that needs them.
14+
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c
15+
index 0dc9b50..f233a74 100644
16+
--- a/contrib/minizip/miniunz.c
17+
+++ b/contrib/minizip/miniunz.c
18+
@@ -12,7 +12,7 @@
19+
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
20+
*/
21+
22+
-#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
23+
+#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!defined(__ANDROID__))
24+
#ifndef __USE_FILE_OFFSET64
25+
#define __USE_FILE_OFFSET64
26+
#endif
27+
@@ -27,7 +27,7 @@
28+
#endif
29+
#endif
30+
31+
-#ifdef __APPLE__
32+
+#if defined(__APPLE__) || defined(IOAPI_NO_64)
33+
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
34+
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
35+
#define FTELLO_FUNC(stream) ftello(stream)
36+
@@ -51,6 +51,7 @@
37+
# include <direct.h>
38+
# include <io.h>
39+
#else
40+
+# include <sys/stat.h>
41+
# include <unistd.h>
42+
# include <utime.h>
43+
#endif
44+
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c
45+
index e8561b1..cb6327f 100644
46+
--- a/contrib/minizip/minizip.c
47+
+++ b/contrib/minizip/minizip.c
48+
@@ -13,7 +13,7 @@
49+
*/
50+
51+
52+
-#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
53+
+#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!defined(__ANDROID__))
54+
#ifndef __USE_FILE_OFFSET64
55+
#define __USE_FILE_OFFSET64
56+
#endif
57+
@@ -28,7 +28,7 @@
58+
#endif
59+
#endif
60+
61+
-#ifdef __APPLE__
62+
+#if defined(__APPLE__) || defined(IOAPI_NO_64)
63+
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
64+
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
65+
#define FTELLO_FUNC(stream) ftello(stream)
66+
diff --git a/zutil.h b/zutil.h
67+
index 0bc7f4e..3a1b6a6 100644
68+
--- a/zutil.h
69+
+++ b/zutil.h
70+
@@ -142,10 +142,12 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
71+
# ifndef Z_SOLO
72+
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
73+
# include <unix.h> /* for fdopen */
74+
-# else
75+
-# ifndef fdopen
76+
-# define fdopen(fd,mode) NULL /* No fdopen() */
77+
-# endif
78+
+//
79+
+// FIXME: This is just a workaround to avoid compilation errors. Maybe we should check the compiler version.
80+
+// # else
81+
+// # ifndef fdopen
82+
+// # define fdopen(fd,mode) NULL /* No fdopen() */
83+
+// # endif
84+
# endif
85+
# endif
86+
#endif

0 commit comments

Comments
 (0)