Add a target for the approved subset of rtc_base.
rtc_base drags in a bunch of unwieldly dependencies (e.g. nss and
json) not required for standalone webrtc (aka rtc/media). The root of
the problem appears to be that MessageQueue depends on a socket server.
(And since common.h -> logging.h -> thread.h -> messagequeue.h, this
dependency spreads quickly.)
This starts a new target for a "purified" subset of rtc_base. It adds
the files which are already being used, replacing the use of common.h
with checks.h. desktop_capture is a lost cause, and retains its
dependency on the full rtc_base.
The hope is that as additional components are desired they will be
cleaned and added to rtc_base_approved.
BUG=3806
R=andresp@webrtc.org, henrike@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/22649004
git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@7188 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 4e14ab1..17cd3af 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -110,11 +110,35 @@
}
}
+# The subset of rtc_base approved for use outside of libjingle.
+static_library("rtc_base_approved") {
+ configs += [ "..:common_config" ]
+ direct_dependent_configs = [ "..:common_inherited_config" ]
+
+ sources = [
+ "checks.cc",
+ "checks.h",
+ "exp_filter.cc",
+ "exp_filter.h",
+ "md5.cc",
+ "md5.h",
+ "md5digest.h",
+ "stringencode.cc",
+ "stringencode.h",
+ "stringutils.cc",
+ "stringutils.h",
+ "timeutils.cc",
+ "timeutils.h",
+ ]
+}
+
static_library("webrtc_base") {
cflags = []
cflags_cc = []
libs = []
- deps= []
+ deps = [
+ ":rtc_base_approved",
+ ]
configs += [
"..:common_config",
diff --git a/base/base.gyp b/base/base.gyp
index 58c4994..f5fad01 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -35,8 +35,31 @@
],
},
{
+ # The subset of rtc_base approved for use outside of libjingle.
+ 'target_name': 'rtc_base_approved',
+ 'type': 'static_library',
+ 'sources': [
+ 'checks.cc',
+ 'checks.h',
+ 'exp_filter.cc',
+ 'exp_filter.h',
+ 'md5.cc',
+ 'md5.h',
+ 'md5digest.h',
+ 'stringencode.cc',
+ 'stringencode.h',
+ 'stringutils.cc',
+ 'stringutils.h',
+ 'timeutils.cc',
+ 'timeutils.h',
+ ],
+ },
+ {
'target_name': 'rtc_base',
'type': 'static_library',
+ 'dependencies': [
+ 'rtc_base_approved',
+ ],
'defines': [
'FEATURE_ENABLE_SSL',
'LOGGING=1',
@@ -75,11 +98,9 @@
'byteorder.h',
'callback.h',
'callback.h.pump',
- 'checks.cc',
- 'checks.h',
+ 'constructormagic.h',
'common.cc',
'common.h',
- 'constructormagic.h',
'cpumonitor.cc',
'cpumonitor.h',
'crc32.cc',
@@ -94,8 +115,6 @@
'diskcache_win32.h',
'event.cc',
'event.h',
- 'exp_filter.cc',
- 'exp_filter.h',
'filelock.cc',
'filelock.h',
'fileutils.cc',
@@ -154,9 +173,6 @@
'macwindowpicker.cc',
'macwindowpicker.h',
'mathutils.h',
- 'md5.cc',
- 'md5.h',
- 'md5digest.h',
'messagedigest.cc',
'messagedigest.h',
'messagehandler.cc',
@@ -261,10 +277,6 @@
'stream.cc',
'stream.h',
'stringdigest.h',
- 'stringencode.cc',
- 'stringencode.h',
- 'stringutils.cc',
- 'stringutils.h',
'systeminfo.cc',
'systeminfo.h',
'task.cc',
@@ -280,8 +292,6 @@
'thread_checker.h',
'thread_checker_impl.cc',
'thread_checker_impl.h',
- 'timeutils.cc',
- 'timeutils.h',
'timing.cc',
'timing.h',
'transformadapter.cc',
diff --git a/base/stringencode.cc b/base/stringencode.cc
index 1e0a149..52b75da 100644
--- a/base/stringencode.cc
+++ b/base/stringencode.cc
@@ -14,7 +14,7 @@
#include <stdlib.h>
#include "webrtc/base/basictypes.h"
-#include "webrtc/base/common.h"
+#include "webrtc/base/checks.h"
#include "webrtc/base/stringutils.h"
namespace rtc {
@@ -26,7 +26,7 @@
size_t escape(char * buffer, size_t buflen,
const char * source, size_t srclen,
const char * illegal, char escape) {
- ASSERT(NULL != buffer); // TODO: estimate output size
+ DCHECK(buffer); // TODO: estimate output size
if (buflen <= 0)
return 0;
@@ -48,7 +48,7 @@
size_t unescape(char * buffer, size_t buflen,
const char * source, size_t srclen,
char escape) {
- ASSERT(NULL != buffer); // TODO: estimate output size
+ DCHECK(buffer); // TODO: estimate output size
if (buflen <= 0)
return 0;
@@ -67,7 +67,7 @@
size_t encode(char * buffer, size_t buflen,
const char * source, size_t srclen,
const char * illegal, char escape) {
- ASSERT(NULL != buffer); // TODO: estimate output size
+ DCHECK(buffer); // TODO: estimate output size
if (buflen <= 0)
return 0;
@@ -118,9 +118,9 @@
// all operating systems, unless one system is overly restrictive.
#if defined(WEBRTC_WIN)
return "\\/:*?\"<>|";
-#else // !WEBRTC_WIN
+#else // !WEBRTC_WIN
// TODO
- ASSERT(false);
+ DCHECK(false);
return "";
#endif // !WEBRTC_WIN
}
@@ -257,7 +257,7 @@
size_t html_encode(char * buffer, size_t buflen,
const char * source, size_t srclen) {
- ASSERT(NULL != buffer); // TODO: estimate output size
+ DCHECK(buffer); // TODO: estimate output size
if (buflen <= 0)
return 0;
@@ -275,7 +275,7 @@
case '\'': escseq = "'"; esclen = 5; break;
case '\"': escseq = """; esclen = 6; break;
case '&': escseq = "&"; esclen = 5; break;
- default: ASSERT(false);
+ default: DCHECK(false);
}
if (bufpos + esclen >= buflen) {
break;
@@ -287,7 +287,8 @@
}
} else {
// Largest value is 0x1FFFFF => � (10 characters)
- char escseq[11];
+ const size_t kEscseqSize = 11;
+ char escseq[kEscseqSize];
unsigned long val;
if (size_t vallen = utf8_decode(&source[srcpos], srclen - srcpos, &val)) {
srcpos += vallen;
@@ -295,7 +296,7 @@
// Not a valid utf8 sequence, just use the raw character.
val = static_cast<unsigned char>(source[srcpos++]);
}
- size_t esclen = sprintfn(escseq, ARRAY_SIZE(escseq), "&#%lu;", val);
+ size_t esclen = sprintfn(escseq, kEscseqSize, "&#%lu;", val);
if (bufpos + esclen >= buflen) {
break;
}
@@ -309,13 +310,13 @@
size_t html_decode(char * buffer, size_t buflen,
const char * source, size_t srclen) {
- ASSERT(NULL != buffer); // TODO: estimate output size
+ DCHECK(buffer); // TODO: estimate output size
return xml_decode(buffer, buflen, source, srclen);
}
size_t xml_encode(char * buffer, size_t buflen,
const char * source, size_t srclen) {
- ASSERT(NULL != buffer); // TODO: estimate output size
+ DCHECK(buffer); // TODO: estimate output size
if (buflen <= 0)
return 0;
@@ -331,7 +332,7 @@
case '\'': escseq = "'"; esclen = 6; break;
case '\"': escseq = """; esclen = 6; break;
case '&': escseq = "&"; esclen = 5; break;
- default: ASSERT(false);
+ default: DCHECK(false);
}
if (bufpos + esclen >= buflen) {
break;
@@ -348,7 +349,7 @@
size_t xml_decode(char * buffer, size_t buflen,
const char * source, size_t srclen) {
- ASSERT(NULL != buffer); // TODO: estimate output size
+ DCHECK(buffer); // TODO: estimate output size
if (buflen <= 0)
return 0;
@@ -410,7 +411,7 @@
static const char HEX[] = "0123456789abcdef";
char hex_encode(unsigned char val) {
- ASSERT(val < 16);
+ DCHECK_LT(val, 16);
return (val < 16) ? HEX[val] : '!';
}
@@ -435,7 +436,7 @@
size_t hex_encode_with_delimiter(char* buffer, size_t buflen,
const char* csource, size_t srclen,
char delimiter) {
- ASSERT(NULL != buffer); // TODO: estimate output size
+ DCHECK(buffer); // TODO: estimate output size
if (buflen == 0)
return 0;
@@ -475,7 +476,7 @@
char* buffer = STACK_ARRAY(char, kBufferSize);
size_t length = hex_encode_with_delimiter(buffer, kBufferSize,
source, srclen, delimiter);
- ASSERT(srclen == 0 || length > 0);
+ DCHECK(srclen == 0 || length > 0);
return std::string(buffer, length);
}
@@ -487,7 +488,7 @@
size_t hex_decode_with_delimiter(char* cbuffer, size_t buflen,
const char* source, size_t srclen,
char delimiter) {
- ASSERT(NULL != cbuffer); // TODO: estimate output size
+ DCHECK(cbuffer); // TODO: estimate output size
if (buflen == 0)
return 0;
@@ -551,7 +552,7 @@
size_t tokenize(const std::string& source, char delimiter,
std::vector<std::string>* fields) {
- ASSERT(NULL != fields);
+ DCHECK(fields);
fields->clear();
size_t last = 0;
for (size_t i = 0; i < source.length(); ++i) {
@@ -608,7 +609,7 @@
size_t split(const std::string& source, char delimiter,
std::vector<std::string>* fields) {
- ASSERT(NULL != fields);
+ DCHECK(fields);
fields->clear();
size_t last = 0;
for (size_t i = 0; i < source.length(); ++i) {
diff --git a/base/stringencode.h b/base/stringencode.h
index b6c666f..2e69a9c 100644
--- a/base/stringencode.h
+++ b/base/stringencode.h
@@ -15,7 +15,7 @@
#include <sstream>
#include <vector>
-#include "webrtc/base/common.h"
+#include "webrtc/base/checks.h"
namespace rtc {
@@ -167,7 +167,7 @@
template <class T>
static bool ToString(const T &t, std::string* s) {
- ASSERT(NULL != s);
+ DCHECK(s);
std::ostringstream oss;
oss << std::boolalpha << t;
*s = oss.str();
@@ -176,7 +176,7 @@
template <class T>
static bool FromString(const std::string& s, T* t) {
- ASSERT(NULL != t);
+ DCHECK(t);
std::istringstream iss(s);
iss >> std::boolalpha >> *t;
return !iss.fail();
diff --git a/base/stringutils.cc b/base/stringutils.cc
index 041708d..cb99c25 100644
--- a/base/stringutils.cc
+++ b/base/stringutils.cc
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "webrtc/base/checks.h"
#include "webrtc/base/stringutils.h"
-#include "webrtc/base/common.h"
namespace rtc {
@@ -57,7 +57,7 @@
if (n-- == 0) return 0;
c1 = transformation(*s1);
// Double check that characters are not UTF-8
- ASSERT(static_cast<unsigned char>(*s2) < 128);
+ DCHECK_LT(static_cast<unsigned char>(*s2), 128);
// Note: *s2 gets implicitly promoted to wchar_t
c2 = transformation(*s2);
if (c1 != c2) return (c1 < c2) ? -1 : 1;
@@ -80,14 +80,14 @@
#if _DEBUG
// Double check that characters are not UTF-8
for (size_t pos = 0; pos < srclen; ++pos)
- ASSERT(static_cast<unsigned char>(source[pos]) < 128);
+ DCHECK_LT(static_cast<unsigned char>(source[pos]), 128);
#endif // _DEBUG
std::copy(source, source + srclen, buffer);
buffer[srclen] = 0;
return srclen;
}
-#endif // WEBRTC_WIN
+#endif // WEBRTC_WIN
void replace_substrs(const char *search,
size_t search_len,
diff --git a/base/timeutils.cc b/base/timeutils.cc
index dcf83e3..64dae2f 100644
--- a/base/timeutils.cc
+++ b/base/timeutils.cc
@@ -18,12 +18,14 @@
#endif
#if defined(WEBRTC_WIN)
+#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
+#endif
#include <windows.h>
#include <mmsystem.h>
#endif
-#include "webrtc/base/common.h"
+#include "webrtc/base/checks.h"
#include "webrtc/base/timeutils.h"
#define EFFICIENT_IMPLEMENTATION 1
@@ -39,7 +41,9 @@
if (timebase.denom == 0) {
// Get the timebase if this is the first time we run.
// Recommended by Apple's QA1398.
- VERIFY(KERN_SUCCESS == mach_timebase_info(&timebase));
+ if (mach_timebase_info(&timebase) != KERN_SUCCESS) {
+ DCHECK(false);
+ }
}
// Use timebase to convert absolute time tick units into nanoseconds.
ticks = mach_absolute_time() * timebase.numer / timebase.denom;
@@ -118,7 +122,7 @@
*result = *tm;
return result;
}
-#endif // WEBRTC_WIN
+#endif // WEBRTC_WIN
void CurrentTmTime(struct tm *tm, int *microseconds) {
struct timeval timeval;
@@ -132,8 +136,8 @@
}
uint32 TimeAfter(int32 elapsed) {
- ASSERT(elapsed >= 0);
- ASSERT(static_cast<uint32>(elapsed) < HALF);
+ DCHECK_GE(elapsed, 0);
+ DCHECK_LT(static_cast<uint32>(elapsed), HALF);
return Time() + elapsed;
}
diff --git a/base/window.h b/base/window.h
index d961026..9f4381a 100644
--- a/base/window.h
+++ b/base/window.h
@@ -11,6 +11,7 @@
#ifndef WEBRTC_BASE_WINDOW_H_
#define WEBRTC_BASE_WINDOW_H_
+#include "webrtc/base/basictypes.h"
#include "webrtc/base/stringencode.h"
// Define platform specific window types.
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index f42ceec..10219b5 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -113,7 +113,10 @@
configs -= [ "//build/config/clang:find_bad_constructs" ]
}
- deps = ["../../system_wrappers"]
+ deps = [
+ "../../system_wrappers",
+ "../../base:webrtc_base",
+ ]
if (use_desktop_capture_differ_sse2) {
deps += [":desktop_capture_differ_sse2"]
diff --git a/modules/desktop_capture/desktop_capture.gypi b/modules/desktop_capture/desktop_capture.gypi
index a0195d6..df6c4bc 100644
--- a/modules/desktop_capture/desktop_capture.gypi
+++ b/modules/desktop_capture/desktop_capture.gypi
@@ -13,6 +13,7 @@
'type': 'static_library',
'dependencies': [
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
+ '<(webrtc_root)/base/base.gyp:rtc_base',
],
'sources': [
"desktop_and_cursor_composer.cc",
diff --git a/modules/video_capture/video_capture.gypi b/modules/video_capture/video_capture.gypi
index 5bdb158..3e83ab3 100644
--- a/modules/video_capture/video_capture.gypi
+++ b/modules/video_capture/video_capture.gypi
@@ -60,6 +60,7 @@
'link_settings': {
'xcode_settings': {
'OTHER_LDFLAGS': [
+ '-framework Cocoa',
'-framework CoreVideo',
'-framework QTKit',
],
diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn
index 67c4754..76a0f34 100644
--- a/system_wrappers/BUILD.gn
+++ b/system_wrappers/BUILD.gn
@@ -193,7 +193,7 @@
]
deps += [
- "../base:webrtc_base",
+ "../base:rtc_base_approved",
]
}
diff --git a/system_wrappers/source/system_wrappers.gyp b/system_wrappers/source/system_wrappers.gyp
index 610f6b0..82addeb 100644
--- a/system_wrappers/source/system_wrappers.gyp
+++ b/system_wrappers/source/system_wrappers.gyp
@@ -17,7 +17,7 @@
'../interface',
],
'dependencies': [
- '../../base/base.gyp:rtc_base',
+ '../../base/base.gyp:rtc_base_approved',
],
'direct_dependent_settings': {
'include_dirs': [