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@7188 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org
2014-09-16 01:03:29 +00:00
parent b3cbeb31cc
commit 6ae5a6d7fe
13 changed files with 96 additions and 50 deletions

View File

@@ -36,6 +36,7 @@
#include <vector>
#include "webrtc/base/basictypes.h"
#include "webrtc/base/common.h"
#include "webrtc/base/stringencode.h"
namespace webrtc {

View File

@@ -110,11 +110,35 @@ if (rtc_build_ssl == 0) {
}
}
# 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",

View File

@@ -34,9 +34,32 @@
'rtc_base',
],
},
{
# 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',

View File

@@ -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 @@ namespace rtc {
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 escape(char * buffer, size_t buflen,
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 unescape(char * buffer, size_t buflen,
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 @@ const char* unsafe_filename_characters() {
// 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 utf8_encode(char* buffer, size_t buflen, unsigned long value) {
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 @@ size_t html_encode(char * buffer, size_t buflen,
case '\'': escseq = "&#39;"; esclen = 5; break;
case '\"': escseq = "&quot;"; esclen = 6; break;
case '&': escseq = "&amp;"; esclen = 5; break;
default: ASSERT(false);
default: DCHECK(false);
}
if (bufpos + esclen >= buflen) {
break;
@@ -287,7 +287,8 @@ size_t html_encode(char * buffer, size_t buflen,
}
} else {
// Largest value is 0x1FFFFF => &#2097151; (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 @@ size_t html_encode(char * buffer, size_t buflen,
// 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_encode(char * buffer, size_t buflen,
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 @@ size_t xml_encode(char * buffer, size_t buflen,
case '\'': escseq = "&apos;"; esclen = 6; break;
case '\"': escseq = "&quot;"; esclen = 6; break;
case '&': escseq = "&amp;"; esclen = 5; break;
default: ASSERT(false);
default: DCHECK(false);
}
if (bufpos + esclen >= buflen) {
break;
@@ -348,7 +349,7 @@ size_t xml_encode(char * buffer, size_t buflen,
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 @@ size_t xml_decode(char * buffer, size_t buflen,
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(char* buffer, size_t buflen,
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 @@ std::string hex_encode_with_delimiter(const char* source, size_t srclen,
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(char * cbuffer, size_t buflen,
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 @@ std::string s_transform(const std::string& source, Transform t) {
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 tokenize(const std::string& source, char delimiter, char start_mark,
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) {

View File

@@ -15,7 +15,7 @@
#include <sstream>
#include <vector>
#include "webrtc/base/common.h"
#include "webrtc/base/checks.h"
namespace rtc {
@@ -167,7 +167,7 @@ size_t tokenize(const std::string& source, char delimiter, char start_mark,
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 @@ static bool ToString(const T &t, std::string* s) {
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();

View File

@@ -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 @@ int ascii_string_compare(const wchar_t* s1, const char* s2, size_t n,
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 @@ size_t asccpyn(wchar_t* buffer, size_t buflen,
#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,

View File

@@ -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 @@ uint64 TimeNanos() {
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 @@ static struct tm *gmtime_r(const time_t *timep, struct tm *result) {
*result = *tm;
return result;
}
#endif // WEBRTC_WIN
#endif // WEBRTC_WIN
void CurrentTmTime(struct tm *tm, int *microseconds) {
struct timeval timeval;
@@ -132,8 +136,8 @@ void CurrentTmTime(struct tm *tm, int *microseconds) {
}
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;
}

View File

@@ -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.

View File

@@ -113,7 +113,10 @@ source_set("desktop_capture") {
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"]

View File

@@ -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",

View File

@@ -60,6 +60,7 @@
'link_settings': {
'xcode_settings': {
'OTHER_LDFLAGS': [
'-framework Cocoa',
'-framework CoreVideo',
'-framework QTKit',
],

View File

@@ -193,7 +193,7 @@ static_library("system_wrappers") {
]
deps += [
"../base:webrtc_base",
"../base:rtc_base_approved",
]
}

View File

@@ -17,7 +17,7 @@
'../interface',
],
'dependencies': [
'../../base/base.gyp:rtc_base',
'../../base/base.gyp:rtc_base_approved',
],
'direct_dependent_settings': {
'include_dirs': [