# This file is generated; do not edit.

import os

Import("env")

env = env.Clone(COMPONENT_NAME='sdch',
                TARGET_NAME='sdch')

configurations = {
    'Debug' : {
        'Append' : dict(
            CCFLAGS = [
                '-Werror',
                '-pthread',
                '-fno-exceptions',
                '-fno-asynchronous-unwind-tables',
                '-fvisibility=hidden',
                '-Wall',
                '-D_FILE_OFFSET_BITS=64',
                '-O0',
                '-g'
            ],
            CPPDEFINES = [
                '__STDC_FORMAT_MACROS',
                'CHROMIUM_BUILD',
                '_DEBUG'
            ],
            CPPPATH = [
                env.Dir('$SRC_DIR/sdch/open-vcdiff/src'),
                env.Dir('$SRC_DIR/sdch/linux')
            ],
            CXXFLAGS = [
                '-fno-rtti',
                '-fno-threadsafe-statics',
                '-fvisibility-inlines-hidden'
            ],
            LINKFLAGS = [
                '-pthread',
                '-rdynamic'
            ],
        ),
        'FilterOut' : dict(
        ),
        'Replace' : dict(
             FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'],
             FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'],
             FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'],
             IMPLICIT_COMMAND_DEPENDENCIES = '0',
             LDMODULECOM = [['$FLOCK_LDMODULE',
  '-o',
  '$TARGET',
  '$_LIBDIRFLAGS',
  '$LDMODULEFLAGS',
  '$SOURCES',
  '-Wl,--start-group',
  '$_LIBFLAGS',
  '-Wl,--end-group']],
             LIBPATH = ['$LIB_DIR'],
             LINKCOM = [['$FLOCK_LINK',
  '-o',
  '$TARGET',
  '$_LIBDIRFLAGS',
  '$LINKFLAGS',
  '$SOURCES',
  '-Wl,--start-group',
  '$_LIBFLAGS',
  '-Wl,--end-group']],
             SHLINKCOM = [['$FLOCK_SHLINK',
  '-o',
  '$TARGET',
  '$_LIBDIRFLAGS',
  '$SHLINKFLAGS',
  '$SOURCES',
  '-Wl,--start-group',
  '$_LIBFLAGS',
  '-Wl,--end-group']],
        ),
        'ImportExternal' : [
             'AS',
             'CC',
             'CXX',
             'LINK',
        ],
        'PropagateExternal' : [
             'AS',
             'CC',
             'CCACHE_DIR',
             'CXX',
             'DISTCC_DIR',
             'DISTCC_HOSTS',
             'HOME',
             'INCLUDE_SERVER_ARGS',
             'INCLUDE_SERVER_PORT',
             'LINK',
             'CHROME_BUILD_TYPE',
             'CHROMIUM_BUILD',
             'OFFICIAL_BUILD',
        ],
    },
    'Release' : {
        'Append' : dict(
            CCFLAGS = [
                '-Werror',
                '-pthread',
                '-fno-exceptions',
                '-fno-asynchronous-unwind-tables',
                '-fvisibility=hidden',
                '-Wall',
                '-D_FILE_OFFSET_BITS=64',
                '-O2',
                '-fno-ident',
                '-fdata-sections',
                '-ffunction-sections'
            ],
            CPPDEFINES = [
                '__STDC_FORMAT_MACROS',
                'CHROMIUM_BUILD',
                'NDEBUG',
                'NVALGRIND'
            ],
            CPPPATH = [
                env.Dir('$SRC_DIR/sdch/open-vcdiff/src'),
                env.Dir('$SRC_DIR/sdch/linux')
            ],
            CXXFLAGS = [
                '-fno-rtti',
                '-fno-threadsafe-statics',
                '-fvisibility-inlines-hidden'
            ],
            LINKFLAGS = [
                '-pthread',
                '-Wl,--gc-sections'
            ],
        ),
        'FilterOut' : dict(
        ),
        'Replace' : dict(
             FLOCK_LDMODULE = ['flock', '$TOP_BUILDDIR/linker.lock', '$LDMODULE'],
             FLOCK_LINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$LINK'],
             FLOCK_SHLINK = ['flock', '$TOP_BUILDDIR/linker.lock', '$SHLINK'],
             IMPLICIT_COMMAND_DEPENDENCIES = '0',
             LDMODULECOM = [['$FLOCK_LDMODULE',
  '-o',
  '$TARGET',
  '$_LIBDIRFLAGS',
  '$LDMODULEFLAGS',
  '$SOURCES',
  '-Wl,--start-group',
  '$_LIBFLAGS',
  '-Wl,--end-group']],
             LIBPATH = ['$LIB_DIR'],
             LINKCOM = [['$FLOCK_LINK',
  '-o',
  '$TARGET',
  '$_LIBDIRFLAGS',
  '$LINKFLAGS',
  '$SOURCES',
  '-Wl,--start-group',
  '$_LIBFLAGS',
  '-Wl,--end-group']],
             SHLINKCOM = [['$FLOCK_SHLINK',
  '-o',
  '$TARGET',
  '$_LIBDIRFLAGS',
  '$SHLINKFLAGS',
  '$SOURCES',
  '-Wl,--start-group',
  '$_LIBFLAGS',
  '-Wl,--end-group']],
        ),
        'ImportExternal' : [
             'AS',
             'CC',
             'CXX',
             'LINK',
        ],
        'PropagateExternal' : [
             'AS',
             'CC',
             'CCACHE_DIR',
             'CXX',
             'DISTCC_DIR',
             'DISTCC_HOSTS',
             'HOME',
             'INCLUDE_SERVER_ARGS',
             'INCLUDE_SERVER_PORT',
             'LINK',
             'CHROME_BUILD_TYPE',
             'CHROMIUM_BUILD',
             'OFFICIAL_BUILD',
        ],
    },
}

config = configurations[env['CONFIG_NAME']]
env.Append(**config['Append'])
env.FilterOut(**config['FilterOut'])
env.Replace(**config['Replace'])

# Scons forces -fPIC for SHCCFLAGS on some platforms.
# Disable that so we can control it from cflags in gyp.
# Note that Scons itself is inconsistent with its -fPIC
# setting. SHCCFLAGS forces -fPIC, and SHCFLAGS does not.
# This will make SHCCFLAGS consistent with SHCFLAGS.
env['SHCCFLAGS'] = ['$CCFLAGS']

for _var in config['ImportExternal']:
  if _var in ARGUMENTS:
    env[_var] = ARGUMENTS[_var]
  elif _var in os.environ:
    env[_var] = os.environ[_var]
for _var in config['PropagateExternal']:
  if _var in ARGUMENTS:
    env[_var] = ARGUMENTS[_var]
  elif _var in os.environ:
    env['ENV'][_var] = os.environ[_var]

env['ENV']['LD_LIBRARY_PATH'] = env.subst('$LIB_DIR')

if ARGUMENTS.get('COVERAGE') not in (None, '0'):
  env.AppendUnique(
            CCFLAGS = [
                '-fprofile-arcs',
                '-ftest-coverage'
            ],
            LINKFLAGS = [
                '-fprofile-arcs'
            ],
  )

if ARGUMENTS.get('PROFILE') not in (None, '0'):
  env.AppendUnique(
            CCFLAGS = [
                '-pg',
                '-g'
            ],
            LINKFLAGS = [
                '-pg'
            ],
  )

if ARGUMENTS.get('SYMBOLS') not in (None, '0'):
  env.AppendUnique(
            CCFLAGS = [
                '-g'
            ],
  )

input_files = [
    'open-vcdiff/src/addrcache.cc',
    'open-vcdiff/src/adler32.c',
    'open-vcdiff/src/blockhash.cc',
    'open-vcdiff/src/blockhash.h',
    'open-vcdiff/src/checksum.h',
    'open-vcdiff/src/codetable.cc',
    'open-vcdiff/src/codetable.h',
    'open-vcdiff/src/compile_assert.h',
    'open-vcdiff/src/decodetable.cc',
    'open-vcdiff/src/decodetable.h',
    'open-vcdiff/src/encodetable.cc',
    'open-vcdiff/src/encodetable.h',
    'open-vcdiff/src/google/output_string.h',
    'open-vcdiff/src/google/vcdecoder.h',
    'open-vcdiff/src/headerparser.cc',
    'open-vcdiff/src/headerparser.h',
    'open-vcdiff/src/instruction_map.cc',
    'open-vcdiff/src/instruction_map.h',
    'open-vcdiff/src/logging.cc',
    'open-vcdiff/src/logging.h',
    'open-vcdiff/src/rolling_hash.h',
    'open-vcdiff/src/testing.h',
    'open-vcdiff/src/varint_bigendian.cc',
    'open-vcdiff/src/varint_bigendian.h',
    'open-vcdiff/src/vcdecoder.cc',
    'open-vcdiff/src/vcdiff_defs.h',
    'open-vcdiff/src/vcdiffengine.cc',
    'open-vcdiff/src/vcdiffengine.h',
    'open-vcdiff/src/zconf.h',
    'open-vcdiff/src/zlib.h',
    'open-vcdiff/vsprojects/config.h',
    'open-vcdiff/vsprojects/stdint.h',
]

target_files = []
prerequisites = []

_result = []
for infile in input_files:
  if env.compilable(infile):
    if (type(infile) == type('')
        and (infile.startswith('$SRC_DIR/sdch/')
             or not os.path.isabs(env.subst(infile)))):
      # Force files below the build directory by replacing all '..'
      # elements in the path with '__':
      base, ext = os.path.splitext(os.path.normpath(infile))
      base = [d == '..' and '__' or d for d in base.split('/')]
      base = os.path.join(*base)
      object = '${OBJ_DIR}/${COMPONENT_NAME}/${TARGET_NAME}/' + base
      if not infile.startswith('$SRC_DIR/sdch/'):
        infile = '$SRC_DIR/sdch/' + infile
      infile = env.StaticObject(object, infile)[0]
    else:
      infile = env.StaticObject(infile)[0]
  _result.append(infile)
input_files = _result

_outputs = env.GypStaticLibrary('sdch', input_files)
target_files.extend(_outputs)

gyp_target = env.Alias('sdch', target_files)
env.Requires(gyp_target, prerequisites)
Return("gyp_target")