blob: 64ac0e200c4fcfa56e6c30f181306b1f47048798 [file] [log] [blame]
# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import re
env = env.Clone(OPEN_VCDIFF_DIR='open-vcdiff')
cpppath = [
if env.Bit('windows'):
env.Prepend(CPPPATH = cpppath)
input_files = [
env.ChromeLibrary('sdch', input_files)
if env.Bit('posix'):
# Generate a target config.h file from a source file.
# The list of defines has been taken empirically from Autoconf
# (./configure) runs on Mac OS X and Ubuntu Hardy.
defines = [
('PACKAGE', '"open-vcdiff"'),
('PACKAGE_NAME', '"open-vcdiff"'),
('PACKAGE_STRING', '"open-vcdiff 0.1"'),
('PACKAGE_TARNAME', '"open-vcdiff"'),
('PACKAGE_VERSION', '"0.1"'),
('VERSION', '"0.1"'),
if env.Bit('linux'):
if env.Bit('mac'):
def AutoConfig(target, source, env):
Action to generate a config.h file from an Autotools 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
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.
Action(AutoConfig, varlist=['DEFINES']),