Separate building and enabling libevent.

We're now ready https://codereview.webrtc.org/1984503002/ downstream,
so make sure we can enable libevent but still choose which libevent
implementation to use. This follows the common pattern where an enable_
flag controls whether we should use the feature at all, whereas build_
controls if we should use the dependency from our DEPS file or
something else.

NOTRY=True

Review-Url: https://codereview.webrtc.org/1980003002
Cr-Commit-Position: refs/heads/master@{#12772}
This commit is contained in:
phoglund 2016-05-17 03:44:28 -07:00 committed by Commit bot
parent d98f6e000a
commit ff274394fe
5 changed files with 56 additions and 36 deletions

View File

@ -122,6 +122,10 @@ config("common_config") {
}
}
if (rtc_enable_libevent) {
defines += [ "WEBRTC_BUILD_LIBEVENT" ]
}
if (current_cpu == "arm64") {
defines += [ "WEBRTC_ARCH_ARM64" ]
defines += [ "WEBRTC_HAS_NEON" ]

View File

@ -148,11 +148,7 @@ static_library("rtc_base_approved") {
"systeminfo.cc",
"systeminfo.h",
"task_queue.h",
"task_queue_gcd.cc",
"task_queue_libevent.cc",
"task_queue_posix.cc",
"task_queue_posix.h",
"task_queue_win.cc",
"template_util.h",
"thread_annotations.h",
"thread_checker.h",
@ -179,21 +175,25 @@ static_library("rtc_base_approved") {
]
}
if (!is_win && !is_mac && !is_ios && !is_nacl) {
if (rtc_build_libevent) {
deps += [ "//base/third_party/libevent" ]
defines += [ "WEBRTC_BUILD_LIBEVENT" ]
}
if (is_mac || is_ios || is_win || is_nacl) {
sources -= [ "task_queue_libevent.cc" ]
}
if (is_linux || is_android || is_win || is_nacl) {
sources -= [ "task_queue_gcd.cc" ]
}
if (is_nacl) {
sources -= [ "task_queue_posix.cc" ]
if (rtc_enable_libevent) {
sources += [
"task_queue_libevent.cc",
"task_queue_posix.cc",
]
} else {
# If not libevent, fall back to the other task queues.
if (is_mac || is_ios) {
sources += [
"task_queue_gcd.cc",
"task_queue_posix.cc",
]
}
if (is_win) {
sources += [ "task_queue_win.cc" ]
}
}
}

View File

@ -84,11 +84,7 @@
'systeminfo.cc',
'systeminfo.h',
'task_queue.h',
'task_queue_libevent.cc',
'task_queue_gcd.cc',
'task_queue_posix.cc',
'task_queue_posix.h',
'task_queue_win.cc',
'template_util.h',
'thread_annotations.h',
'thread_checker.h',
@ -121,16 +117,25 @@
'dependencies': [
'<(DEPTH)/base/third_party/libevent/libevent.gyp:libevent',
],
}, {
'sources!': [ 'task_queue_libevent.cc' ],
'conditions': [
['OS=="linux" or OS=="android"', {
'sources!': [ 'task_queue_posix.cc' ],
}],
],
}],
['build_libevent==1 or OS=="linux" or OS=="android" or OS=="win"', {
'sources!': [ 'task_queue_gcd.cc' ],
['enable_libevent==1', {
'sources': [
'task_queue_libevent.cc',
'task_queue_posix.cc',
],
}, {
# If not libevent, fall back to the other task queues.
'conditions': [
['OS=="mac" or OS=="ios"', {
'sources': [
'task_queue_gcd.cc',
'task_queue_posix.cc',
],
}],
['OS=="win"', {
'sources': [ 'task_queue_win.cc' ],
}]
],
}],
['OS=="mac" and build_with_chromium==0', {
'all_dependent_settings': {

View File

@ -19,9 +19,7 @@
# Enable to use the Mozilla internal settings.
'build_with_mozilla%': 0,
'build_for%': '',
},
'build_for%': '<(build_for)',
'build_with_chromium%': '<(build_with_chromium)',
'build_with_mozilla%': '<(build_with_mozilla%)',
'include_opus%': 1,
@ -45,18 +43,21 @@
}],
# Controls whether we use libevent on posix platforms.
# TODO(tommi): Remove the 'build_for' condition once libevent is more
# widely available in posix configurations.
['OS=="win" or OS=="mac" or OS=="ios" or build_for!=""', {
# TODO(phoglund): should arguably be controlled by platform #ifdefs
# in the code instead.
['OS=="win" or OS=="mac" or OS=="ios"', {
'build_libevent%': 0,
'enable_libevent%': 0,
}, {
'build_libevent%': 1,
'enable_libevent%': 1,
}],
],
},
'build_with_chromium%': '<(build_with_chromium)',
'build_with_mozilla%': '<(build_with_mozilla)',
'build_libevent%': '<(build_libevent)',
'enable_libevent%': '<(enable_libevent)',
'webrtc_root%': '<(webrtc_root)',
'apk_tests_path%': '<(apk_tests_path)',
'modules_java_gyp_path%': '<(modules_java_gyp_path)',
@ -69,6 +70,7 @@
'build_with_chromium%': '<(build_with_chromium)',
'build_with_mozilla%': '<(build_with_mozilla)',
'build_libevent%': '<(build_libevent)',
'enable_libevent%': '<(enable_libevent)',
'webrtc_root%': '<(webrtc_root)',
'apk_tests_path%': '<(apk_tests_path)',
'test_runner_path': '<(DEPTH)/webrtc/build/android/test_runner.py',
@ -332,7 +334,7 @@
}],
],
}],
['build_libevent==1', {
['enable_libevent==1', {
'defines': [
'WEBRTC_BUILD_LIBEVENT',
],

View File

@ -59,6 +59,15 @@ declare_args() {
rtc_include_tests = false
rtc_restrict_logging = true
# Enable libevent task queues on platforms that support it.
if (is_win || is_mac || is_ios || is_nacl) {
rtc_enable_libevent = false
rtc_build_libevent = false
} else {
rtc_enable_libevent = true
rtc_build_libevent = true
}
if (is_ios) {
rtc_build_libjpeg = false
rtc_enable_protobuf = false