From ff274394fed4b54d9fbe977ab64d71ecef522880 Mon Sep 17 00:00:00 2001 From: phoglund Date: Tue, 17 May 2016 03:44:28 -0700 Subject: [PATCH] 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} --- webrtc/BUILD.gn | 4 ++++ webrtc/base/BUILD.gn | 34 +++++++++++++++++----------------- webrtc/base/base.gyp | 31 ++++++++++++++++++------------- webrtc/build/common.gypi | 14 ++++++++------ webrtc/build/webrtc.gni | 9 +++++++++ 5 files changed, 56 insertions(+), 36 deletions(-) diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn index e1aeb45720..3a2556b917 100644 --- a/webrtc/BUILD.gn +++ b/webrtc/BUILD.gn @@ -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" ] diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn index aefcfc5a49..1e868b504e 100644 --- a/webrtc/base/BUILD.gn +++ b/webrtc/base/BUILD.gn @@ -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" ] + } } } diff --git a/webrtc/base/base.gyp b/webrtc/base/base.gyp index 4564504aab..9e55efc807 100644 --- a/webrtc/base/base.gyp +++ b/webrtc/base/base.gyp @@ -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': { diff --git a/webrtc/build/common.gypi b/webrtc/build/common.gypi index 4006d1745a..31777b123f 100644 --- a/webrtc/build/common.gypi +++ b/webrtc/build/common.gypi @@ -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', ], diff --git a/webrtc/build/webrtc.gni b/webrtc/build/webrtc.gni index 8e1b9521f7..2a072793bc 100644 --- a/webrtc/build/webrtc.gni +++ b/webrtc/build/webrtc.gni @@ -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