diff --git a/BUILD.gn b/BUILD.gn index 418408b7fa..3f06fa9da4 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -83,12 +83,21 @@ if (!build_with_chromium) { } } +config("library_impl_config") { + # Build targets that contain WebRTC implementation need this macro to + # be defined in order to correctly export symbols when is_component_build + # is true. + # For more info see: rtc_base/build/rtc_export.h. + defines = [ "WEBRTC_LIBRARY_IMPL" ] +} + # Contains the defines and includes in common.gypi that are duplicated both as # target_defaults and direct_dependent_settings. config("common_inherited_config") { defines = [] cflags = [] ldflags = [] + if (build_with_mozilla) { defines += [ "WEBRTC_MOZILLA_BUILD" ] } diff --git a/rtc_base/build/BUILD.gn b/rtc_base/build/BUILD.gn new file mode 100644 index 0000000000..8635ad5518 --- /dev/null +++ b/rtc_base/build/BUILD.gn @@ -0,0 +1,15 @@ +# 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("../../webrtc.gni") + +rtc_source_set("rtc_export") { + sources = [ + "rtc_export.h", + ] +} diff --git a/rtc_base/build/rtc_export.h b/rtc_base/build/rtc_export.h new file mode 100644 index 0000000000..b3636fcec9 --- /dev/null +++ b/rtc_base/build/rtc_export.h @@ -0,0 +1,43 @@ +/* + * 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. + */ + +#ifndef RTC_BASE_BUILD_RTC_EXPORT_H_ +#define RTC_BASE_BUILD_RTC_EXPORT_H_ + +// RTC_EXPORT is used to mark symbols as exported or imported when WebRTC is +// built or used as a shared library. +// When WebRTC is built as a static library the RTC_EXPORT macro expands to +// nothing. + +#ifdef COMPONENT_BUILD + +#ifdef WEBRTC_WIN + +#ifdef WEBRTC_LIBRARY_IMPL +#define RTC_EXPORT __declspec(dllexport) +#else +#define RTC_EXPORT __declspec(dllimport) +#endif + +#else // WEBRTC_WIN + +#if __has_attribute(visibility) && defined(WEBRTC_LIBRARY_IMPL) +#define RTC_EXPORT __attribute__((visibility("default"))) +#endif + +#endif // WEBRTC_WIN + +#endif // COMPONENT_BUILD + +#ifndef RTC_EXPORT +#define RTC_EXPORT +#endif + +#endif // RTC_BASE_BUILD_RTC_EXPORT_H_ diff --git a/webrtc.gni b/webrtc.gni index 150599f8e9..dc0c7b5c00 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -279,6 +279,7 @@ rtc_common_inherited_config = webrtc_root + ":common_inherited_config" rtc_remove_configs = [] rtc_add_configs = rtc_common_configs rtc_prod_configs = [ webrtc_root + ":rtc_prod_config" ] +rtc_library_impl_config = [ webrtc_root + ":library_impl_config" ] set_defaults("rtc_test") { configs = rtc_add_configs @@ -444,6 +445,7 @@ template("rtc_source_set") { } configs += invoker.configs + configs += rtc_library_impl_config configs -= rtc_remove_configs configs -= invoker.suppressed_configs public_configs = [ @@ -552,6 +554,7 @@ template("rtc_static_library") { } configs += invoker.configs + configs += rtc_library_impl_config configs -= rtc_remove_configs configs -= invoker.suppressed_configs public_configs = [