Generate umbrella header for macOS framework.

Similarly to how it is done for iOS.

Bug: webrtc:9627
Change-Id: I7e4e3495d28a0a098531250bfdcf93d272e27b9d
Reviewed-on: https://webrtc-review.googlesource.com/98162
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Anders Carlsson <andersc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24594}
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 8a58a20..b5fd104 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -1345,116 +1345,97 @@
     }
 
     if (is_mac) {
-      mac_framework_header_files = [
-        "objc/base/RTCCodecSpecificInfo.h",
-        "objc/base/RTCEncodedImage.h",
-        "objc/base/RTCI420Buffer.h",
-        "objc/base/RTCLogging.h",
-        "objc/base/RTCMacros.h",
-        "objc/base/RTCMutableI420Buffer.h",
-        "objc/base/RTCMutableYUVPlanarBuffer.h",
-        "objc/base/RTCRtpFragmentationHeader.h",
-        "objc/base/RTCVideoCapturer.h",
-        "objc/base/RTCVideoCodecInfo.h",
-        "objc/base/RTCVideoDecoder.h",
-        "objc/base/RTCVideoDecoderFactory.h",
-        "objc/base/RTCVideoEncoder.h",
-        "objc/base/RTCVideoEncoderFactory.h",
-        "objc/base/RTCVideoEncoderQpThresholds.h",
-        "objc/base/RTCVideoEncoderSettings.h",
-        "objc/base/RTCVideoFrame.h",
-        "objc/base/RTCVideoFrameBuffer.h",
-        "objc/base/RTCVideoRenderer.h",
-        "objc/base/RTCYUVPlanarBuffer.h",
-        "objc/components/capturer/RTCCameraVideoCapturer.h",
-        "objc/components/capturer/RTCFileVideoCapturer.h",
-        "objc/components/renderer/metal/RTCMTLNSVideoView.h",
-        "objc/components/renderer/opengl/RTCNSGLVideoView.h",
-        "objc/components/renderer/opengl/RTCVideoViewShading.h",
-        "objc/components/video_codec/RTCCodecSpecificInfoH264.h",
-        "objc/components/video_codec/RTCDefaultVideoDecoderFactory.h",
-        "objc/components/video_codec/RTCDefaultVideoEncoderFactory.h",
-        "objc/components/video_codec/RTCH264ProfileLevelId.h",
-        "objc/components/video_codec/RTCVideoDecoderFactoryH264.h",
-        "objc/components/video_codec/RTCVideoDecoderH264.h",
-        "objc/components/video_codec/RTCVideoEncoderFactoryH264.h",
-        "objc/components/video_codec/RTCVideoEncoderH264.h",
-        "objc/components/video_frame_buffer/RTCCVPixelBuffer.h",
-        "objc/helpers/RTCDispatcher.h",
-        "objc/api/peerconnection/RTCAudioSource.h",
-        "objc/api/peerconnection/RTCAudioTrack.h",
-        "objc/api/peerconnection/RTCConfiguration.h",
-        "objc/api/peerconnection/RTCDataChannel.h",
-        "objc/api/peerconnection/RTCDataChannelConfiguration.h",
-        "objc/api/peerconnection/RTCFieldTrials.h",
-        "objc/api/peerconnection/RTCIceCandidate.h",
-        "objc/api/peerconnection/RTCIceServer.h",
-        "objc/api/peerconnection/RTCIntervalRange.h",
-        "objc/api/peerconnection/RTCLegacyStatsReport.h",
-        "objc/api/peerconnection/RTCMediaConstraints.h",
-        "objc/api/peerconnection/RTCMediaSource.h",
-        "objc/api/peerconnection/RTCMediaStream.h",
-        "objc/api/peerconnection/RTCMediaStreamTrack.h",
-        "objc/api/peerconnection/RTCMetrics.h",
-        "objc/api/peerconnection/RTCMetricsSampleInfo.h",
-        "objc/api/peerconnection/RTCPeerConnection.h",
-        "objc/api/peerconnection/RTCPeerConnectionFactory.h",
-        "objc/api/peerconnection/RTCPeerConnectionFactoryOptions.h",
-        "objc/api/peerconnection/RTCRtcpParameters.h",
-        "objc/api/peerconnection/RTCRtpCodecParameters.h",
-        "objc/api/peerconnection/RTCRtpEncodingParameters.h",
-        "objc/api/peerconnection/RTCRtpHeaderExtension.h",
-        "objc/api/peerconnection/RTCRtpParameters.h",
-        "objc/api/peerconnection/RTCRtpReceiver.h",
-        "objc/api/peerconnection/RTCRtpSender.h",
-        "objc/api/peerconnection/RTCRtpTransceiver.h",
-        "objc/api/peerconnection/RTCDtmfSender.h",
-        "objc/api/peerconnection/RTCSSLAdapter.h",
-        "objc/api/peerconnection/RTCSessionDescription.h",
-        "objc/api/peerconnection/RTCTracing.h",
-        "objc/api/peerconnection/RTCCertificate.h",
-        "objc/api/peerconnection/RTCVideoSource.h",
-        "objc/api/peerconnection/RTCVideoTrack.h",
-        "objc/api/video_codec/RTCVideoDecoderVP8.h",
-        "objc/api/video_codec/RTCVideoDecoderVP9.h",
-        "objc/api/video_codec/RTCVideoEncoderVP8.h",
-        "objc/api/video_codec/RTCVideoEncoderVP9.h",
-        "objc/api/video_frame_buffer/RTCNativeI420Buffer.h",
-        "objc/api/video_frame_buffer/RTCNativeMutableI420Buffer.h",
-      ]
-      if (!build_with_chromium) {
-        mac_framework_header_files += [
-          "objc/api/logging/RTCCallbackLogger.h",
-          "objc/api/peerconnection/RTCFileLogger.h",
-        ]
-      }
-
-      bundle_data("framework_headers") {
-        # TODO(andersc): Generate umbrella header
-        sources = mac_framework_header_files
-        outputs = [
-          "{{bundle_contents_dir}}/Headers/{{source_file_part}}",
-        ]
-      }
-
-      mac_framework_bundle("mac_framework_objc") {
+      mac_framework_bundle_with_umbrella_header("mac_framework_objc") {
         info_plist = "objc/Info.plist"
         output_name = "WebRTC"
-        framework_version = "A"
-        framework_contents = [ "Headers" ]
 
-        sources = mac_framework_header_files
-
-        ldflags = [
-          "-all_load",
-          "-install_name",
-          "@rpath/$output_name.framework/$output_name",
+        sources = [
+          "objc/api/peerconnection/RTCAudioSource.h",
+          "objc/api/peerconnection/RTCAudioTrack.h",
+          "objc/api/peerconnection/RTCCertificate.h",
+          "objc/api/peerconnection/RTCConfiguration.h",
+          "objc/api/peerconnection/RTCDataChannel.h",
+          "objc/api/peerconnection/RTCDataChannelConfiguration.h",
+          "objc/api/peerconnection/RTCDtmfSender.h",
+          "objc/api/peerconnection/RTCFieldTrials.h",
+          "objc/api/peerconnection/RTCIceCandidate.h",
+          "objc/api/peerconnection/RTCIceServer.h",
+          "objc/api/peerconnection/RTCIntervalRange.h",
+          "objc/api/peerconnection/RTCLegacyStatsReport.h",
+          "objc/api/peerconnection/RTCMediaConstraints.h",
+          "objc/api/peerconnection/RTCMediaSource.h",
+          "objc/api/peerconnection/RTCMediaStream.h",
+          "objc/api/peerconnection/RTCMediaStreamTrack.h",
+          "objc/api/peerconnection/RTCMetrics.h",
+          "objc/api/peerconnection/RTCMetricsSampleInfo.h",
+          "objc/api/peerconnection/RTCPeerConnection.h",
+          "objc/api/peerconnection/RTCPeerConnectionFactory.h",
+          "objc/api/peerconnection/RTCPeerConnectionFactoryOptions.h",
+          "objc/api/peerconnection/RTCRtcpParameters.h",
+          "objc/api/peerconnection/RTCRtpCodecParameters.h",
+          "objc/api/peerconnection/RTCRtpEncodingParameters.h",
+          "objc/api/peerconnection/RTCRtpHeaderExtension.h",
+          "objc/api/peerconnection/RTCRtpParameters.h",
+          "objc/api/peerconnection/RTCRtpReceiver.h",
+          "objc/api/peerconnection/RTCRtpSender.h",
+          "objc/api/peerconnection/RTCRtpTransceiver.h",
+          "objc/api/peerconnection/RTCSSLAdapter.h",
+          "objc/api/peerconnection/RTCSessionDescription.h",
+          "objc/api/peerconnection/RTCTracing.h",
+          "objc/api/peerconnection/RTCVideoSource.h",
+          "objc/api/peerconnection/RTCVideoTrack.h",
+          "objc/api/video_codec/RTCVideoDecoderVP8.h",
+          "objc/api/video_codec/RTCVideoDecoderVP9.h",
+          "objc/api/video_codec/RTCVideoEncoderVP8.h",
+          "objc/api/video_codec/RTCVideoEncoderVP9.h",
+          "objc/api/video_frame_buffer/RTCNativeI420Buffer.h",
+          "objc/api/video_frame_buffer/RTCNativeMutableI420Buffer.h",
+          "objc/base/RTCCodecSpecificInfo.h",
+          "objc/base/RTCEncodedImage.h",
+          "objc/base/RTCI420Buffer.h",
+          "objc/base/RTCLogging.h",
+          "objc/base/RTCMacros.h",
+          "objc/base/RTCMutableI420Buffer.h",
+          "objc/base/RTCMutableYUVPlanarBuffer.h",
+          "objc/base/RTCRtpFragmentationHeader.h",
+          "objc/base/RTCVideoCapturer.h",
+          "objc/base/RTCVideoCodecInfo.h",
+          "objc/base/RTCVideoDecoder.h",
+          "objc/base/RTCVideoDecoderFactory.h",
+          "objc/base/RTCVideoEncoder.h",
+          "objc/base/RTCVideoEncoderFactory.h",
+          "objc/base/RTCVideoEncoderQpThresholds.h",
+          "objc/base/RTCVideoEncoderSettings.h",
+          "objc/base/RTCVideoFrame.h",
+          "objc/base/RTCVideoFrameBuffer.h",
+          "objc/base/RTCVideoRenderer.h",
+          "objc/base/RTCYUVPlanarBuffer.h",
+          "objc/components/capturer/RTCCameraVideoCapturer.h",
+          "objc/components/capturer/RTCFileVideoCapturer.h",
+          "objc/components/renderer/metal/RTCMTLNSVideoView.h",
+          "objc/components/renderer/opengl/RTCNSGLVideoView.h",
+          "objc/components/renderer/opengl/RTCVideoViewShading.h",
+          "objc/components/video_codec/RTCCodecSpecificInfoH264.h",
+          "objc/components/video_codec/RTCDefaultVideoDecoderFactory.h",
+          "objc/components/video_codec/RTCDefaultVideoEncoderFactory.h",
+          "objc/components/video_codec/RTCH264ProfileLevelId.h",
+          "objc/components/video_codec/RTCVideoDecoderFactoryH264.h",
+          "objc/components/video_codec/RTCVideoDecoderH264.h",
+          "objc/components/video_codec/RTCVideoEncoderFactoryH264.h",
+          "objc/components/video_codec/RTCVideoEncoderH264.h",
+          "objc/components/video_frame_buffer/RTCCVPixelBuffer.h",
+          "objc/helpers/RTCDispatcher.h",
         ]
+        if (!build_with_chromium) {
+          sources += [
+            "objc/api/logging/RTCCallbackLogger.h",
+            "objc/api/peerconnection/RTCFileLogger.h",
+          ]
+        }
 
         deps = [
           ":base_objc",
           ":default_codec_factory_objc",
-          ":framework_headers",
           ":native_api",
           ":native_video",
           ":peerconnectionfactory_base_objc",
@@ -1484,7 +1465,7 @@
           "OpenGL.framework",
         ]
 
-        configs += [ "..:common_objc" ]
+        configs = [ "..:common_objc" ]
 
         public_configs = [ ":common_config_objc" ]
       }
diff --git a/sdk/objc/components/renderer/metal/RTCMTLNSVideoView.h b/sdk/objc/components/renderer/metal/RTCMTLNSVideoView.h
index 8d377e2..891b377 100644
--- a/sdk/objc/components/renderer/metal/RTCMTLNSVideoView.h
+++ b/sdk/objc/components/renderer/metal/RTCMTLNSVideoView.h
@@ -10,7 +10,7 @@
 
 #import <Cocoa/Cocoa.h>
 
-#import "base/RTCVideoRenderer.h"
+#import "RTCVideoRenderer.h"
 
 NS_AVAILABLE_MAC(10.11)
 
diff --git a/sdk/objc/components/renderer/opengl/RTCNSGLVideoView.h b/sdk/objc/components/renderer/opengl/RTCNSGLVideoView.h
index 14c64b4..ad47705 100644
--- a/sdk/objc/components/renderer/opengl/RTCNSGLVideoView.h
+++ b/sdk/objc/components/renderer/opengl/RTCNSGLVideoView.h
@@ -14,8 +14,8 @@
 
 #import <AppKit/NSOpenGLView.h>
 
+#import "RTCVideoRenderer.h"
 #import "RTCVideoViewShading.h"
-#import "base/RTCVideoRenderer.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
diff --git a/webrtc.gni b/webrtc.gni
index 67f2b5d..58631dd 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -30,6 +30,10 @@
   import("//build/config/ios/rules.gni")
 }
 
+if (is_mac) {
+  import("//build/config/mac/rules.gni")
+}
+
 declare_args() {
   # WARNING: This argument doesn't have any effect on the WebRTC build until
   # https://webrtc-review.googlesource.com/c/src/+/94766 will land.
@@ -682,6 +686,68 @@
   }
 }
 
+if (is_mac) {
+  template("mac_framework_bundle_with_umbrella_header") {
+    forward_variables_from(invoker, [ "output_name" ])
+    umbrella_header_path =
+        "$target_gen_dir/$output_name.framework/Headers/$output_name.h"
+
+    mac_framework_bundle(target_name) {
+      forward_variables_from(invoker, "*", [])
+
+      framework_version = "A"
+      framework_contents = [ "Headers" ]
+
+      ldflags = [
+        "-all_load",
+        "-install_name",
+        "@rpath/$output_name.framework/$output_name",
+      ]
+
+      deps += [
+        ":copy_framework_headers_$target_name",
+        ":copy_umbrella_header_$target_name",
+      ]
+    }
+
+    copy("copy_framework_headers_$target_name") {
+      forward_variables_from(invoker, [ "sources" ])
+
+      outputs = [
+        "$root_out_dir/$output_name.framework/Headers/{{source_file_part}}",
+      ]
+    }
+
+    action("umbrella_header_$target_name") {
+      forward_variables_from(invoker, [ "sources" ])
+
+      script = "//tools_webrtc/ios/generate_umbrella_header.py"
+
+      outputs = [
+        umbrella_header_path,
+      ]
+      args = [
+               "--out",
+               rebase_path(umbrella_header_path, root_build_dir),
+               "--sources",
+             ] + sources
+    }
+
+    copy("copy_umbrella_header_$target_name") {
+      sources = [
+        umbrella_header_path,
+      ]
+      outputs = [
+        "$root_out_dir/$output_name.framework/Headers/$output_name.h",
+      ]
+
+      deps = [
+        ":umbrella_header_$target_name",
+      ]
+    }
+  }
+}
+
 if (is_android) {
   template("rtc_android_library") {
     android_library(target_name) {