diff options
-rw-r--r-- | build/SConscript.main | 2 | ||||
-rw-r--r-- | net/SConscript | 8 | ||||
-rw-r--r-- | net/base/filter.cc | 9 | ||||
-rw-r--r-- | sdch/SConscript | 102 |
4 files changed, 102 insertions, 19 deletions
diff --git a/build/SConscript.main b/build/SConscript.main index c038741..8e42e9c 100644 --- a/build/SConscript.main +++ b/build/SConscript.main @@ -309,6 +309,7 @@ elif env['PLATFORM'] == 'posix': 'chrome', 'googleurl', 'net', + 'sdch', 'skia', 'testing', 'third_party', @@ -354,6 +355,7 @@ elif env['PLATFORM'] == 'darwin': #'breakpad', 'googleurl', 'net', + 'sdch', 'skia', 'testing', 'third_party', diff --git a/net/SConscript b/net/SConscript index c8f879d..28f730b 100644 --- a/net/SConscript +++ b/net/SConscript @@ -48,6 +48,8 @@ input_files = [ 'base/net_module.cc', 'base/net_util.cc', 'base/registry_controlled_domain.cc', + 'base/sdch_filter.cc', + 'base/sdch_manager.cc', 'base/upload_data.cc', 'base/x509_certificate.cc', 'disk_cache/backend_impl.cc', @@ -91,8 +93,6 @@ if env['PLATFORM'] == 'win32': 'base/directory_lister.cc', 'base/dns_resolution_observer.cc', 'base/listen_socket.cc', - 'base/sdch_filter.cc', - 'base/sdch_manager.cc', 'base/ssl_client_socket.cc', 'base/ssl_config_service.cc', 'base/tcp_client_socket.cc', @@ -177,6 +177,7 @@ env_tests.Prepend( 'base', 'googleurl', 'gtest', + 'sdch', env_tests['ICU_LIBS'], # TODO(sgk): '$ICU_LIBS' when scons is fixed 'modp_b64', 'zlib', @@ -210,9 +211,6 @@ if env['PLATFORM'] == 'win32': '/ignore:4199', '/nxcompat', ], - LIBS =[ - 'sdch', - ], ) if env['PLATFORM'] in ('posix', 'darwin'): diff --git a/net/base/filter.cc b/net/base/filter.cc index 701b9c6..c59e7f0 100644 --- a/net/base/filter.cc +++ b/net/base/filter.cc @@ -7,10 +7,7 @@ #include "base/string_util.h" #include "net/base/gzip_filter.h" #include "net/base/bzip2_filter.h" -#if defined(OS_WIN) || defined(OS_MACOSX) -// TODO(port): remove #ifdef when sdch works on all platforms. #include "net/base/sdch_filter.h" -#endif namespace { @@ -85,11 +82,8 @@ Filter* Filter::SingleFilter(const std::string& filter_type, } else if (LowerCaseEqualsASCII(filter_type, kBZip2) || LowerCaseEqualsASCII(filter_type, kXBZip2)) { type_id = FILTER_TYPE_BZIP2; -#if defined(OS_WIN) || defined(OS_MACOSX) - // TODO(port): remove #ifdef when sdch works on all platforms. } else if (LowerCaseEqualsASCII(filter_type, kSdch)) { type_id = FILTER_TYPE_SDCH; -#endif } else { // Note we also consider "identity" and "uncompressed" UNSUPPORTED as // filter should be disabled in such cases. @@ -116,8 +110,6 @@ Filter* Filter::SingleFilter(const std::string& filter_type, } break; } -#if defined(OS_WIN) || defined(OS_MACOSX) - // TODO(port): remove #ifdef when sdch works on all platforms. case FILTER_TYPE_SDCH: { scoped_ptr<SdchFilter> sdch_filter(new SdchFilter()); if (sdch_filter->InitBuffer(buffer_size)) { @@ -127,7 +119,6 @@ Filter* Filter::SingleFilter(const std::string& filter_type, } break; } -#endif default: { break; } diff --git a/sdch/SConscript b/sdch/SConscript index c6c57fb..dbb0e55 100644 --- a/sdch/SConscript +++ b/sdch/SConscript @@ -2,16 +2,20 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import re + Import('env') env = env.Clone(OPEN_VCDIFF_DIR='open-vcdiff') -env.Prepend( - CPPPATH = [ +cpppath = [ '$OPEN_VCDIFF_DIR/src', - '$OPEN_VCDIFF_DIR/vsprojects', - ], -) +] + +if env['PLATFORM'] == 'win32': + cpppath.append('$OPEN_VCDIFF_DIR/vsprojects') + +env.Prepend(CPPPATH = cpppath) input_files = [ '$OPEN_VCDIFF_DIR/src/addrcache.cc', @@ -28,3 +32,91 @@ input_files = [ ] env.ChromeStaticLibrary('sdch', input_files) + +if env['PLATFORM'] in ('posix', 'darwin'): + + # Generate a target config.h file from a source config.h.in file. + # + # The list of defines has been taken empirically from Autoconf + # (./configure) runs on Mac OS X and Ubuntu Hardy. + + defines = [ + 'HAVE_DLFCN_H', + 'HAVE_FNMATCH_H', + 'HAVE_GETOPT_H', + 'HAVE_GETTIMEOFDAY', + 'HAVE_INTTYPES_H', + 'HAVE_MEMORY_H', + 'HAVE_MPROTECT', + 'HAVE_PTHREAD', + 'HAVE_STDINT_H', + 'HAVE_STDLIB_H', + 'HAVE_STRINGS_H', + 'HAVE_STRING_H', + 'HAVE_STRTOLL', + 'HAVE_STRTOQ', + 'HAVE_SYS_MMAN_H', + 'HAVE_SYS_STAT_H', + 'HAVE_SYS_TIME_H', + 'HAVE_SYS_TYPES_H', + 'HAVE_UINT16_T', + 'HAVE_UNISTD_H', + 'HAVE_U_INT16_T', + 'HAVE___ATTRIBUTE__', + ('PACKAGE', '"open-vcdiff"'), + ('PACKAGE_BUGREPORT', '"opensource@google.com"'), + ('PACKAGE_NAME', '"open-vcdiff"'), + ('PACKAGE_STRING', '"open-vcdiff 0.1"'), + ('PACKAGE_TARNAME', '"open-vcdiff"'), + ('PACKAGE_VERSION', '"0.1"'), + ('VERSION', '"0.1"'), + 'STDC_HEADERS', + ] + + if env['PLATFORM'] == 'posix': + defines.extend([ + 'HAVE_MALLOC_H', + 'HAVE_MEMALIGN', + 'HAVE_POSIX_MEMALIGN', + ]) + + if env['PLATFORM'] == 'darwin': + defines.extend([ + 'HAVE_WORKING_KQUEUE', + ]) + + def AutoConfig(target, source, env): + """ + Action to generate a config.h file from an Autotools config.h.in file, + given the list of definitions in the DEFINES construction variable. + + Each entry in DEFINES is either a string, in which case it + will be enabled with a value of 1, or a tuple, in which case + the first element is the #define name and the second its value. + + Any leftover #undef lines get commented out. + """ + contents = open(str(source[0]), 'r').read() + + for d in env['DEFINES']: + if isinstance(d, tuple): + define, value = d + else: + define = d + value = 1 + undef = '^#undef %s$' % re.escape(define) + definition = '#define %s %s' % (define, value) + contents = re.sub(undef, definition, contents) + + undef_re = re.compile(r'^(#undef .*)$', re.M) + contents = undef_re.sub(r'/* \1 */', contents) + + header = '/* src/config.h. Generated by SCons. */\n' + open(str(target[0]), 'w').write(header + contents) + + # varlist['DEFINES'] below makes the target config.h file depend + # on the list of definitions in the passed-in $DEFINES variable. + env.Command('$OPEN_VCDIFF_DIR/src/config.h', + '$OPEN_VCDIFF_DIR/src/config.h.in', + Action(AutoConfig, varlist=['DEFINES']), + DEFINES=defines) |