Generate module.modulemap file when building Mac Framework
Without this file, the Framework can't be used by Swift projects. Bug: webrtc:9142 Change-Id: I8803ec8b194dc116e133257e205f4620bb34a692 Reviewed-on: https://webrtc-review.googlesource.com/c/103340 Commit-Queue: Patrik Höglund <phoglund@webrtc.org> Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Reviewed-by: Anders Carlsson <andersc@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25047}
This commit is contained in:

committed by
Commit Bot

parent
e6708f31a0
commit
d2fb1bfeba
1
AUTHORS
1
AUTHORS
@ -98,3 +98,4 @@ Miguel Paris <mparisdiaz@gmail.com>
|
||||
Vewd Software AS <*@vewd.com>
|
||||
Highfive, Inc. <*@highfive.com>
|
||||
CoSMo Software Consulting, Pte Ltd <*@cosmosoftware.io>
|
||||
Tuple, LLC <*@tuple.app>
|
||||
|
32
tools_webrtc/ios/generate_modulemap.py
Normal file
32
tools_webrtc/ios/generate_modulemap.py
Normal file
@ -0,0 +1,32 @@
|
||||
# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
def GenerateModulemap():
|
||||
parser = argparse.ArgumentParser(description='Generate modulemap')
|
||||
parser.add_argument("-o", "--out", type=str, help="Output file.")
|
||||
parser.add_argument("-n", "--name", type=str, help="Name of binary.")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.out, "w") as outfile:
|
||||
module_template = 'framework module %s {\n' \
|
||||
' umbrella header "%s.h"\n' \
|
||||
'\n' \
|
||||
' export *\n' \
|
||||
' module * { export * }\n' \
|
||||
'}\n' % (args.name, args.name)
|
||||
outfile.write(module_template)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(GenerateModulemap())
|
||||
|
36
webrtc.gni
36
webrtc.gni
@ -649,6 +649,8 @@ 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") {
|
||||
forward_variables_from(invoker, [ "output_name" ])
|
||||
umbrella_header_path =
|
||||
@ -699,12 +701,17 @@ if (is_mac) {
|
||||
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, "*", [])
|
||||
|
||||
framework_version = "A"
|
||||
framework_contents = [ "Headers" ]
|
||||
framework_contents = [
|
||||
"Headers",
|
||||
"Modules",
|
||||
"Resources",
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
"-all_load",
|
||||
@ -714,7 +721,9 @@ if (is_mac) {
|
||||
|
||||
deps += [
|
||||
":copy_framework_headers_$this_target_name",
|
||||
":copy_modulemap_$this_target_name",
|
||||
":copy_umbrella_header_$this_target_name",
|
||||
":modulemap_$this_target_name",
|
||||
":umbrella_header_$this_target_name",
|
||||
]
|
||||
}
|
||||
@ -727,6 +736,31 @@ if (is_mac) {
|
||||
]
|
||||
}
|
||||
|
||||
action("modulemap_$this_target_name") {
|
||||
script = "//tools_webrtc/ios/generate_modulemap.py"
|
||||
args = [
|
||||
"--out",
|
||||
rebase_path(modulemap_path, root_build_dir),
|
||||
"--name",
|
||||
output_name,
|
||||
]
|
||||
outputs = [
|
||||
modulemap_path,
|
||||
]
|
||||
}
|
||||
|
||||
bundle_data("copy_modulemap_$this_target_name") {
|
||||
sources = [
|
||||
modulemap_path,
|
||||
]
|
||||
outputs = [
|
||||
"{{bundle_contents_dir}}/Modules/module.modulemap",
|
||||
]
|
||||
deps = [
|
||||
":modulemap_$this_target_name",
|
||||
]
|
||||
}
|
||||
|
||||
action("umbrella_header_$this_target_name") {
|
||||
forward_variables_from(invoker, [ "sources" ])
|
||||
|
||||
|
Reference in New Issue
Block a user