webrtc-mac.patch 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. From bd27c327f72ea231353983aa35a0c3e6ae8055d5 Mon Sep 17 00:00:00 2001
  2. From: David Fifield <david@bamsoftware.com>
  3. Date: Mon, 26 Jun 2017 11:26:55 -0700
  4. Subject: [PATCH 1/8] Disable assertions that prevent cross-compiling for mac.
  5. ---
  6. config/BUILDCONFIG.gn | 4 ++--
  7. toolchain/mac/BUILD.gn | 2 +-
  8. 2 files changed, 3 insertions(+), 3 deletions(-)
  9. diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
  10. index d055e705..78a2023a 100644
  11. --- a/build/config/BUILDCONFIG.gn
  12. +++ b/build/config/BUILDCONFIG.gn
  13. @@ -232,8 +232,8 @@ if (target_os == "android") {
  14. } else if (target_os == "ios") {
  15. _default_toolchain = "//build/toolchain/mac:ios_clang_$target_cpu"
  16. } else if (target_os == "mac") {
  17. - assert(host_os == "mac", "Mac cross-compiles are unsupported.")
  18. - _default_toolchain = host_toolchain
  19. + # assert(host_os == "mac", "Mac cross-compiles are unsupported.")
  20. + _default_toolchain = "//build/toolchain/mac:clang_$host_cpu"
  21. } else if (target_os == "win") {
  22. # On Windows we use the same toolchain for host and target by default.
  23. assert(target_os == host_os, "Win cross-compiles only work on win hosts.")
  24. diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn
  25. index b417e76a..5f48927d 100644
  26. --- a/build/toolchain/mac/BUILD.gn
  27. +++ b/build/toolchain/mac/BUILD.gn
  28. @@ -14,7 +14,7 @@ if (is_ios) {
  29. import("//build/config/mac/mac_sdk.gni")
  30. import("//build/config/mac/symbols.gni")
  31. -assert(host_os == "mac")
  32. +# assert(host_os == "mac")
  33. import("//build/toolchain/cc_wrapper.gni")
  34. import("//build/toolchain/clang_static_analyzer.gni")
  35. --
  36. 2.11.0
  37. From a58bb43ea406939fcc978aa808714d04802074ac Mon Sep 17 00:00:00 2001
  38. From: David Fifield <david@bamsoftware.com>
  39. Date: Mon, 26 Jun 2017 11:29:14 -0700
  40. Subject: [PATCH 2/8] Hardcode cross-compiling flags in config/mac/BUILD.gn.
  41. The build system doesn't provide a general way to set flags externally.
  42. "No way to provide extra CFLAGS/CXXFLAGS/LDFLAGS"
  43. https://bugs.chromium.org/p/chromium/issues/detail?id=595653
  44. ---
  45. config/mac/BUILD.gn | 5 +++++
  46. 1 file changed, 5 insertions(+)
  47. diff --git a/build/config/mac/BUILD.gn b/build/config/mac/BUILD.gn
  48. index 84180e6a..2054b46f 100644
  49. --- a/build/config/mac/BUILD.gn
  50. +++ b/build/config/mac/BUILD.gn
  51. @@ -83,6 +83,11 @@ config("runtime_library") {
  52. "-isysroot",
  53. sysroot,
  54. "-mmacosx-version-min=$mac_deployment_target",
  55. + "-target",
  56. + "x86_64-apple-darwin11",
  57. + "-Wno-unknown-warning-option",
  58. + "-B",
  59. + "/var/tmp/dist/macosx-toolchain/cctools/bin",
  60. ]
  61. asmflags = common_flags
  62. --
  63. 2.11.0
  64. From 4c57d854280a0f0a4f55cba0457ae44f6369ca08 Mon Sep 17 00:00:00 2001
  65. From: David Fifield <david@bamsoftware.com>
  66. Date: Mon, 26 Jun 2017 11:30:28 -0700
  67. Subject: [PATCH 3/8] Port build/config/mac/plist_util.py to biplist.
  68. So as not to require the plutil command. plutil was only being used to
  69. convert between XML and binary plist formats, because versions of the
  70. plistlib module before Python 3.4 only support the XML format. The
  71. biplist library handles both formats natively.
  72. FAILED: gen/webrtc/examples/AppRTCMobile_info_plist_merged.plist
  73. python ../../build/config/mac/plist_util.py merge -f=xml1 -o=gen/webrtc/examples/AppRTCMobile_info_plist_merged.plist ../../build/config/mac/BuildInfo.plist ../../webrtc/examples/objc/AppRTCMobile/mac/Info.plist
  74. Traceback (most recent call last):
  75. File "../../build/config/mac/plist_util.py", line 254, in <module>
  76. sys.exit(Main())
  77. File "../../build/config/mac/plist_util.py", line 250, in Main
  78. args.func(args)
  79. File "../../build/config/mac/plist_util.py", line 207, in _Execute
  80. data = MergePList(data, LoadPList(filename))
  81. File "../../build/config/mac/plist_util.py", line 121, in LoadPList
  82. subprocess.check_call(['plutil', '-convert', 'xml1', '-o', name, path])
  83. File "/usr/lib/python2.7/subprocess.py", line 535, in check_call
  84. retcode = call(*popenargs, **kwargs)
  85. File "/usr/lib/python2.7/subprocess.py", line 522, in call
  86. return Popen(*popenargs, **kwargs).wait()
  87. File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
  88. errread, errwrite)
  89. File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
  90. raise child_exception
  91. OSError: [Errno 2] No such file or directory
  92. ---
  93. config/mac/plist_util.py | 4 +++-
  94. 1 file changed, 3 insertions(+), 1 deletion(-)
  95. diff --git a/build/config/mac/plist_util.py b/build/config/mac/plist_util.py
  96. index 0928fa13..898edc1a 100644
  97. --- a/build/config/mac/plist_util.py
  98. +++ b/build/config/mac/plist_util.py
  99. @@ -3,7 +3,7 @@
  100. # found in the LICENSE file.
  101. import argparse
  102. -import plistlib
  103. +import biplist
  104. import os
  105. import re
  106. import subprocess
  107. @@ -116,6 +116,7 @@ def Interpolate(plist, substitutions):
  108. def LoadPList(path):
  109. """Loads Plist at |path| and returns it as a dictionary."""
  110. + return biplist.readPlist(path)
  111. fd, name = tempfile.mkstemp()
  112. try:
  113. subprocess.check_call(['plutil', '-convert', 'xml1', '-o', name, path])
  114. @@ -127,6 +128,7 @@ def LoadPList(path):
  115. def SavePList(path, format, data):
  116. """Saves |data| as a Plist to |path| in the specified |format|."""
  117. + return biplist.writePlist(data, path, {"xml1": False, "binary1": True}[format]) # doesn't handle "json" format
  118. fd, name = tempfile.mkstemp()
  119. try:
  120. with os.fdopen(fd, 'w') as f:
  121. --
  122. 2.11.0
  123. From 62a6fa6376194ce673c220eef19fefeebe58fee1 Mon Sep 17 00:00:00 2001
  124. From: David Fifield <david@bamsoftware.com>
  125. Date: Mon, 26 Jun 2017 11:41:16 -0700
  126. Subject: [PATCH 5/8] Include <sys/socket.h> in macifaddrs_converter.cc.
  127. Without this, when built against MacOSX10.7.sdk, there are errors:
  128. In file included from ../../webrtc/base/macifaddrs_converter.cc:13:
  129. /home/debian/build/MacOSX10.7.sdk/usr/include/net/if.h:300:19: error: field has incomplete type 'struct sockaddr'
  130. struct sockaddr ifru_addr;
  131. Related references:
  132. https://trac.macports.org/ticket/49012
  133. https://trac.macports.org/browser/trunk/dports/gnome/gstreamer1/files/patch-struct-sockadr.diff?rev=140712
  134. ---
  135. webrtc/base/macifaddrs_converter.cc | 1 +
  136. 1 file changed, 1 insertion(+)
  137. diff --git a/webrtc/base/macifaddrs_converter.cc b/webrtc/base/macifaddrs_converter.cc
  138. index 2ad070e8e..1995f1940 100644
  139. --- a/webrtc/base/macifaddrs_converter.cc
  140. +++ b/webrtc/base/macifaddrs_converter.cc
  141. @@ -10,6 +10,7 @@
  142. #include <memory>
  143. +#include <sys/socket.h>
  144. #include <net/if.h>
  145. #include <sys/ioctl.h>
  146. #include <unistd.h>
  147. --
  148. 2.11.0
  149. From e6a421534723408fb1292ce25051a1970f750a4a Mon Sep 17 00:00:00 2001
  150. From: David Fifield <david@bamsoftware.com>
  151. Date: Mon, 26 Jun 2017 11:42:34 -0700
  152. Subject: [PATCH 6/8] Provide definitions of NS_ENUM and NS_OPTIONS.
  153. ---
  154. webrtc/sdk/objc/Framework/Headers/WebRTC/RTCMacros.h | 13 +++++++++++++
  155. 1 file changed, 13 insertions(+)
  156. diff --git a/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCMacros.h b/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCMacros.h
  157. index f9f15c37d..277676d85 100644
  158. --- a/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCMacros.h
  159. +++ b/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCMacros.h
  160. @@ -25,4 +25,17 @@
  161. #define RTC_FWD_DECL_OBJC_CLASS(classname) typedef struct objc_object classname
  162. #endif
  163. +// http://iamthewalr.us/blog/2012/11/ns_enum-and-ns_options/
  164. +#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
  165. +#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
  166. +#if (__cplusplus)
  167. +#define NS_OPTIONS(_type, _name) _type _name; enum : _type
  168. +#else
  169. +#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
  170. +#endif
  171. +#else
  172. +#define NS_ENUM(_type, _name) _type _name; enum
  173. +#define NS_OPTIONS(_type, _name) _type _name; enum
  174. +#endif
  175. +
  176. #endif // WEBRTC_BASE_OBJC_RTC_MACROS_H_
  177. --
  178. 2.11.0
  179. From baf5ddbd1e1281cd7c4cdda709e2ea7e07903727 Mon Sep 17 00:00:00 2001
  180. From: David Fifield <david@bamsoftware.com>
  181. Date: Mon, 26 Jun 2017 11:43:05 -0700
  182. Subject: [PATCH 7/8] Replace firstObject with objectAtIndex:0.
  183. firstObject doesn't exist in our version of the SDK.
  184. The two method calls are not exactly the same; on an empty array,
  185. firstObject returns nil while objectAtIndex:0 raises an exception. Let's
  186. hope that doesn't matter.
  187. ---
  188. webrtc/modules/video_capture/objc/rtc_video_capture_objc.mm | 2 +-
  189. 1 file changed, 1 insertion(+), 1 deletion(-)
  190. diff --git a/webrtc/modules/video_capture/objc/rtc_video_capture_objc.mm b/webrtc/modules/video_capture/objc/rtc_video_capture_objc.mm
  191. index 182056228..93bea08f9 100644
  192. --- a/webrtc/modules/video_capture/objc/rtc_video_capture_objc.mm
  193. +++ b/webrtc/modules/video_capture/objc/rtc_video_capture_objc.mm
  194. @@ -176,7 +176,7 @@ using namespace webrtc::videocapturemodule;
  195. }
  196. - (AVCaptureVideoDataOutput*)currentOutput {
  197. - return [[_captureSession outputs] firstObject];
  198. + return [[_captureSession outputs] objectAtIndex:0];
  199. }
  200. - (void)startCaptureInBackgroundWithOutput:
  201. --
  202. 2.11.0
  203. From 0b5f86af5bc4b7697ee60adf7e1e057a023438e0 Mon Sep 17 00:00:00 2001
  204. From: David Fifield <david@bamsoftware.com>
  205. Date: Mon, 26 Jun 2017 11:43:51 -0700
  206. Subject: [PATCH 8/8] Disable the desktop_capture module.
  207. It's causing an error related to CoreGraphics.h and hopefully we don't
  208. need it.
  209. ---
  210. webrtc/modules/BUILD.gn | 1 -
  211. 1 file changed, 1 deletion(-)
  212. diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn
  213. index e750a8109..590f34275 100644
  214. --- a/webrtc/modules/BUILD.gn
  215. +++ b/webrtc/modules/BUILD.gn
  216. @@ -18,7 +18,6 @@ group("modules") {
  217. "audio_processing",
  218. "bitrate_controller",
  219. "congestion_controller",
  220. - "desktop_capture",
  221. "media_file",
  222. "pacing",
  223. "remote_bitrate_estimator",
  224. --
  225. 2.11.0