Allow export of Obj-C symbols without C++ ones.

This is useful when building the .framework which doesn't need to
export C++ symbols.

Bug: webrtc:12408
Change-Id: Ied775811a72a06b9ad678c9fb549bca286dd7f37
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227089
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34613}
This commit is contained in:
Mirko Bonadei 2021-07-30 22:32:55 +02:00 committed by WebRTC LUCI CQ
parent 8e70299dd9
commit 5f0784563c
4 changed files with 19 additions and 6 deletions

View file

@ -121,6 +121,9 @@ config("common_inherited_config") {
if (rtc_enable_symbol_export || is_component_build) {
defines = [ "WEBRTC_ENABLE_SYMBOL_EXPORT" ]
}
if (rtc_enable_objc_symbol_export) {
defines = [ "WEBRTC_ENABLE_OBJC_SYMBOL_EXPORT" ]
}
if (build_with_mozilla) {
defines += [ "WEBRTC_MOZILLA_BUILD" ]

View file

@ -11,13 +11,13 @@
#ifndef SDK_OBJC_BASE_RTCMACROS_H_
#define SDK_OBJC_BASE_RTCMACROS_H_
#ifdef WEBRTC_ENABLE_SYMBOL_EXPORT
#ifdef WEBRTC_ENABLE_OBJC_SYMBOL_EXPORT
#if defined(WEBRTC_LIBRARY_IMPL)
#define RTC_OBJC_EXPORT __attribute__((visibility("default")))
#endif
#endif // WEBRTC_ENABLE_SYMBOL_EXPORT
#endif // WEBRTC_ENABLE_OBJC_SYMBOL_EXPORT
#ifndef RTC_OBJC_EXPORT
#define RTC_OBJC_EXPORT

View file

@ -183,7 +183,7 @@ def BuildWebRTC(output_dir, target_environment, target_arch, flavor,
gn_args.append('enable_ios_bitcode=' +
('true' if use_bitcode else 'false'))
gn_args.append('use_goma=' + ('true' if use_goma else 'false'))
gn_args.append('rtc_enable_symbol_export=true')
gn_args.append('rtc_enable_objc_symbol_export=true')
args_string = ' '.join(gn_args + extra_gn_args)
logging.info('Building WebRTC with args: %s', args_string)

View file

@ -35,10 +35,22 @@ if (is_mac) {
import("//build/config/mac/rules.gni")
}
# This declare_args is separated from the next one because args declared
# in this one, can be read from the next one (args defined in the same
# declare_args cannot be referenced in that scope).
declare_args() {
# Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
# expand to code that will manage symbols visibility.
rtc_enable_symbol_export = false
}
declare_args() {
# Setting this to true will make RTC_OBJC_EXPORT expand to code that will
# manage symbols visibility. By default, Obj-C/Obj-C++ symbols are exported
# if C++ symbols are but setting this arg to true while keeping
# rtc_enable_symbol_export=false will only export RTC_OBJC_EXPORT
# annotated symbols.
rtc_enable_objc_symbol_export = rtc_enable_symbol_export
# Setting this to true will define WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT which
# will tell the pre-processor to remove the default definition of symbols
@ -320,9 +332,7 @@ webrtc_root = get_path_info(".", "abspath")
# It sets defines, include paths and compilation warnings accordingly,
# both for WebRTC stand-alone builds and for the scenario when WebRTC
# native code is built as part of Chromium.
rtc_common_configs = [
webrtc_root + ":common_config",
]
rtc_common_configs = [ webrtc_root + ":common_config" ]
if (is_mac || is_ios) {
rtc_common_configs += [ "//build/config/compiler:enable_arc" ]