diff options
author | sgk@google.com <sgk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-30 01:37:05 +0000 |
---|---|---|
committer | sgk@google.com <sgk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-30 01:37:05 +0000 |
commit | 44fd14c5ade3ff22063382c63409ba18bcb5d50a (patch) | |
tree | d3cf83ec7e689f54832629ebf8af913c0639f121 /sdch | |
parent | cc510c17f62f0f1654b51d6edd055976dbf16a6e (diff) | |
download | chromium_src-44fd14c5ade3ff22063382c63409ba18bcb5d50a.zip chromium_src-44fd14c5ade3ff22063382c63409ba18bcb5d50a.tar.gz chromium_src-44fd14c5ade3ff22063382c63409ba18bcb5d50a.tar.bz2 |
Get open-vcdiff building on Linux and Mac (in SCons) using
captured values for generating a config.h file.
Builds base/sdch_{filter,manager}.cc on all platforms and links
the 'sdch' library.
Add sdch to the SCons configuration loaded on Mac and Linux.
Removes platform #ifs in net/base/filter.cc initialization code
(reverting r2740).
B=2662
Review URL: http://codereview.chromium.org/5204
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2710 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sdch')
-rw-r--r-- | sdch/SConscript | 102 |
1 files changed, 97 insertions, 5 deletions
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) |