mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Merge GN templates for iOS and MacOS framework creation
The two GN templates are nearly identical, so merge them to reduce maintenance. Bug: webrtc:13949 Change-Id: I5f53ade5f9d09ce6f23a6cb29c9d39df4485a237 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258380 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Commit-Queue: Daniel.L (Byoungchan) Lee <daniel.l@hpcnt.com> Cr-Commit-Position: refs/heads/main@{#36495}
This commit is contained in:
parent
145fdbf3b2
commit
26b23b8fcc
2 changed files with 60 additions and 99 deletions
|
@ -1244,7 +1244,7 @@ if (is_ios || is_mac) {
|
|||
}
|
||||
|
||||
if (is_ios) {
|
||||
ios_framework_bundle_with_umbrella_header("framework_objc") {
|
||||
apple_framework_bundle_with_umbrella_header("framework_objc") {
|
||||
info_plist = "objc/Info.plist"
|
||||
output_name = "WebRTC"
|
||||
|
||||
|
@ -1381,7 +1381,7 @@ if (is_ios || is_mac) {
|
|||
"CoreMedia.framework",
|
||||
]
|
||||
|
||||
configs += [
|
||||
configs = [
|
||||
"..:common_objc",
|
||||
":used_from_extension",
|
||||
]
|
||||
|
@ -1397,7 +1397,7 @@ if (is_ios || is_mac) {
|
|||
}
|
||||
|
||||
if (is_mac) {
|
||||
mac_framework_bundle_with_umbrella_header("mac_framework_objc") {
|
||||
apple_framework_bundle_with_umbrella_header("mac_framework_objc") {
|
||||
info_plist = "objc/Info.plist"
|
||||
output_name = "WebRTC"
|
||||
|
||||
|
|
103
webrtc.gni
103
webrtc.gni
|
@ -960,14 +960,13 @@ template("rtc_shared_library") {
|
|||
}
|
||||
}
|
||||
|
||||
if (is_ios) {
|
||||
# TODO: Generate module.modulemap file to enable use in Swift
|
||||
# projects. See "mac_framework_bundle_with_umbrella_header".
|
||||
template("ios_framework_bundle_with_umbrella_header") {
|
||||
if (is_mac || is_ios) {
|
||||
template("apple_framework_bundle_with_umbrella_header") {
|
||||
forward_variables_from(invoker, [ "output_name" ])
|
||||
this_target_name = target_name
|
||||
umbrella_header_path =
|
||||
"$target_gen_dir/$output_name.framework/WebRTC/$output_name.h"
|
||||
modulemap_path = "$target_gen_dir/Modules/module.modulemap"
|
||||
|
||||
action_foreach("create_bracket_include_headers_$target_name") {
|
||||
script = "//tools_webrtc/apple/copy_framework_header.py"
|
||||
|
@ -985,58 +984,7 @@ if (is_ios) {
|
|||
]
|
||||
}
|
||||
|
||||
ios_framework_bundle(target_name) {
|
||||
forward_variables_from(invoker, "*", [ "public_headers" ])
|
||||
public_headers = get_target_outputs(
|
||||
":create_bracket_include_headers_$this_target_name")
|
||||
deps += [
|
||||
":copy_umbrella_header_$target_name",
|
||||
":create_bracket_include_headers_$target_name",
|
||||
]
|
||||
}
|
||||
|
||||
action("umbrella_header_$target_name") {
|
||||
public_headers = get_target_outputs(
|
||||
":create_bracket_include_headers_$this_target_name")
|
||||
|
||||
script = "//tools_webrtc/ios/generate_umbrella_header.py"
|
||||
|
||||
outputs = [ umbrella_header_path ]
|
||||
args = [
|
||||
"--out",
|
||||
rebase_path(umbrella_header_path, root_build_dir),
|
||||
"--sources",
|
||||
] + public_headers
|
||||
deps = [ ":create_bracket_include_headers_$this_target_name" ]
|
||||
}
|
||||
|
||||
if (target_environment == "catalyst") {
|
||||
# Catalyst frameworks use the same layout as regular Mac frameworks.
|
||||
headers_dir = "Versions/A/Headers"
|
||||
} else {
|
||||
headers_dir = "Headers"
|
||||
}
|
||||
copy("copy_umbrella_header_$target_name") {
|
||||
sources = [ umbrella_header_path ]
|
||||
outputs =
|
||||
[ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
|
||||
|
||||
deps = [ ":umbrella_header_$target_name" ]
|
||||
}
|
||||
}
|
||||
|
||||
set_defaults("ios_framework_bundle_with_umbrella_header") {
|
||||
configs = default_shared_library_configs
|
||||
}
|
||||
}
|
||||
|
||||
if (is_mac) {
|
||||
template("mac_framework_bundle_with_umbrella_header") {
|
||||
forward_variables_from(invoker, [ "output_name" ])
|
||||
this_target_name = target_name
|
||||
umbrella_header_path = "$target_gen_dir/umbrella_header/$output_name.h"
|
||||
modulemap_path = "$target_gen_dir/Modules/module.modulemap"
|
||||
|
||||
mac_framework_bundle(target_name) {
|
||||
forward_variables_from(invoker, "*", [ "configs" ])
|
||||
if (defined(invoker.configs)) {
|
||||
|
@ -1065,22 +1013,34 @@ if (is_mac) {
|
|||
":umbrella_header_$this_target_name",
|
||||
]
|
||||
}
|
||||
}
|
||||
if (is_ios) {
|
||||
ios_framework_bundle(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
"*",
|
||||
[
|
||||
"configs",
|
||||
"public_headers",
|
||||
])
|
||||
if (defined(invoker.configs)) {
|
||||
configs += invoker.configs
|
||||
}
|
||||
public_headers = get_target_outputs(
|
||||
":create_bracket_include_headers_$this_target_name")
|
||||
|
||||
action_foreach("create_bracket_include_headers_$this_target_name") {
|
||||
script = "//tools_webrtc/apple/copy_framework_header.py"
|
||||
sources = invoker.sources
|
||||
output_name = invoker.output_name
|
||||
outputs = [
|
||||
"$target_gen_dir/$output_name.framework/WebRTC/{{source_file_part}}",
|
||||
]
|
||||
args = [
|
||||
"--input",
|
||||
"{{source}}",
|
||||
"--output",
|
||||
rebase_path(target_gen_dir, root_build_dir) +
|
||||
"/$output_name.framework/WebRTC/{{source_file_part}}",
|
||||
deps += [
|
||||
":copy_umbrella_header_$this_target_name",
|
||||
":create_bracket_include_headers_$this_target_name",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (is_mac || target_environment == "catalyst") {
|
||||
# Catalyst frameworks use the same layout as regular Mac frameworks.
|
||||
headers_dir = "Versions/A/Headers"
|
||||
} else {
|
||||
headers_dir = "Headers"
|
||||
}
|
||||
|
||||
bundle_data("copy_framework_headers_$this_target_name") {
|
||||
sources = get_target_outputs(
|
||||
|
@ -1122,11 +1082,12 @@ if (is_mac) {
|
|||
deps = [ ":create_bracket_include_headers_$this_target_name" ]
|
||||
}
|
||||
|
||||
bundle_data("copy_umbrella_header_$this_target_name") {
|
||||
copy("copy_umbrella_header_$target_name") {
|
||||
sources = [ umbrella_header_path ]
|
||||
outputs = [ "{{bundle_contents_dir}}/Headers/$output_name.h" ]
|
||||
outputs =
|
||||
[ "$root_out_dir/$output_name.framework/$headers_dir/$output_name.h" ]
|
||||
|
||||
deps = [ ":umbrella_header_$this_target_name" ]
|
||||
deps = [ ":umbrella_header_$target_name" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue