| OLD | NEW |
| (Empty) |
| 1 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import re | |
| 6 | |
| 7 Import('env') | |
| 8 | |
| 9 env = env.Clone(OPEN_VCDIFF_DIR='open-vcdiff') | |
| 10 | |
| 11 cpppath = [ | |
| 12 '$OPEN_VCDIFF_DIR/src', | |
| 13 ] | |
| 14 | |
| 15 if env.Bit('windows'): | |
| 16 cpppath.append('$OPEN_VCDIFF_DIR/vsprojects') | |
| 17 | |
| 18 if env.Bit('linux'): | |
| 19 cpppath.append('linux') | |
| 20 | |
| 21 env.Prepend(CPPPATH = cpppath) | |
| 22 | |
| 23 input_files = ChromeFileList([ | |
| 24 # TODO(sgk): violate standard indentation so we don't have to | |
| 25 # reindent too much when we remove the explicit MSVSFilter() calls | |
| 26 # in favor of generating the hierarchy to reflect the file system. | |
| 27 MSVSFilter('Header Files', [ | |
| 28 'open-vcdiff/src/blockhash.h', | |
| 29 'open-vcdiff/src/checksum.h', | |
| 30 'open-vcdiff/src/codetable.h', | |
| 31 'open-vcdiff/src/compile_assert.h', | |
| 32 'open-vcdiff/vsprojects/config.h', | |
| 33 'open-vcdiff/src/decodetable.h', | |
| 34 'open-vcdiff/src/encodetable.h', | |
| 35 'open-vcdiff/src/headerparser.h', | |
| 36 'open-vcdiff/src/instruction_map.h', | |
| 37 'open-vcdiff/src/logging.h', | |
| 38 'open-vcdiff/src/google/output_string.h', | |
| 39 'open-vcdiff/src/rolling_hash.h', | |
| 40 'open-vcdiff/vsprojects/stdint.h', | |
| 41 'open-vcdiff/src/testing.h', | |
| 42 'open-vcdiff/src/varint_bigendian.h', | |
| 43 'open-vcdiff/src/google/vcdecoder.h', | |
| 44 'open-vcdiff/src/vcdiff_defs.h', | |
| 45 'open-vcdiff/src/vcdiffengine.h', | |
| 46 'open-vcdiff/src/zconf.h', | |
| 47 'open-vcdiff/src/zlib.h', | |
| 48 ]), | |
| 49 MSVSFilter('Source Files', [ | |
| 50 'open-vcdiff/src/addrcache.cc', | |
| 51 'open-vcdiff/src/adler32.c', | |
| 52 'open-vcdiff/src/blockhash.cc', | |
| 53 'open-vcdiff/src/codetable.cc', | |
| 54 'open-vcdiff/src/decodetable.cc', | |
| 55 'open-vcdiff/src/encodetable.cc', | |
| 56 'open-vcdiff/src/headerparser.cc', | |
| 57 'open-vcdiff/src/instruction_map.cc', | |
| 58 'open-vcdiff/src/logging.cc', | |
| 59 'open-vcdiff/src/varint_bigendian.cc', | |
| 60 'open-vcdiff/src/vcdecoder.cc', | |
| 61 'open-vcdiff/src/vcdiffengine.cc', | |
| 62 ]), | |
| 63 ]) | |
| 64 | |
| 65 env.ChromeLibrary('sdch', input_files) | |
| 66 | |
| 67 if env.Bit('posix'): | |
| 68 | |
| 69 # Generate a target config.h file from a source config.h.in file. | |
| 70 # | |
| 71 # The list of defines has been taken empirically from Autoconf | |
| 72 # (./configure) runs on Mac OS X and Ubuntu Hardy. | |
| 73 | |
| 74 defines = [ | |
| 75 'HAVE_DLFCN_H', | |
| 76 'HAVE_FNMATCH_H', | |
| 77 'HAVE_GETOPT_H', | |
| 78 'HAVE_GETTIMEOFDAY', | |
| 79 'HAVE_INTTYPES_H', | |
| 80 'HAVE_MEMORY_H', | |
| 81 'HAVE_MPROTECT', | |
| 82 'HAVE_PTHREAD', | |
| 83 'HAVE_STDINT_H', | |
| 84 'HAVE_STDLIB_H', | |
| 85 'HAVE_STRINGS_H', | |
| 86 'HAVE_STRING_H', | |
| 87 'HAVE_STRTOLL', | |
| 88 'HAVE_STRTOQ', | |
| 89 'HAVE_SYS_MMAN_H', | |
| 90 'HAVE_SYS_STAT_H', | |
| 91 'HAVE_SYS_TIME_H', | |
| 92 'HAVE_SYS_TYPES_H', | |
| 93 'HAVE_UINT16_T', | |
| 94 'HAVE_UNISTD_H', | |
| 95 'HAVE_U_INT16_T', | |
| 96 'HAVE___ATTRIBUTE__', | |
| 97 ('PACKAGE', '"open-vcdiff"'), | |
| 98 ('PACKAGE_BUGREPORT', '"opensource@google.com"'), | |
| 99 ('PACKAGE_NAME', '"open-vcdiff"'), | |
| 100 ('PACKAGE_STRING', '"open-vcdiff 0.1"'), | |
| 101 ('PACKAGE_TARNAME', '"open-vcdiff"'), | |
| 102 ('PACKAGE_VERSION', '"0.1"'), | |
| 103 ('VERSION', '"0.1"'), | |
| 104 'STDC_HEADERS', | |
| 105 ] | |
| 106 | |
| 107 if env.Bit('linux'): | |
| 108 defines.extend([ | |
| 109 'HAVE_MALLOC_H', | |
| 110 'HAVE_MEMALIGN', | |
| 111 'HAVE_POSIX_MEMALIGN', | |
| 112 ]) | |
| 113 | |
| 114 if env.Bit('mac'): | |
| 115 defines.extend([ | |
| 116 'HAVE_WORKING_KQUEUE', | |
| 117 ]) | |
| 118 | |
| 119 def AutoConfig(target, source, env): | |
| 120 """ | |
| 121 Action to generate a config.h file from an Autotools config.h.in file, | |
| 122 given the list of definitions in the DEFINES construction variable. | |
| 123 | |
| 124 Each entry in DEFINES is either a string, in which case it | |
| 125 will be enabled with a value of 1, or a tuple, in which case | |
| 126 the first element is the #define name and the second its value. | |
| 127 | |
| 128 Any leftover #undef lines get commented out. | |
| 129 """ | |
| 130 contents = open(str(source[0]), 'r').read() | |
| 131 | |
| 132 for d in env['DEFINES']: | |
| 133 if isinstance(d, tuple): | |
| 134 define, value = d | |
| 135 else: | |
| 136 define = d | |
| 137 value = 1 | |
| 138 undef = '^#undef %s$' % re.escape(define) | |
| 139 definition = '#define %s %s' % (define, value) | |
| 140 contents = re.sub(undef, definition, contents) | |
| 141 | |
| 142 undef_re = re.compile(r'^(#undef .*)$', re.M) | |
| 143 contents = undef_re.sub(r'/* \1 */', contents) | |
| 144 | |
| 145 header = '/* src/config.h. Generated by SCons. */\n' | |
| 146 open(str(target[0]), 'w').write(header + contents) | |
| 147 | |
| 148 # varlist['DEFINES'] below makes the target config.h file depend | |
| 149 # on the list of definitions in the passed-in $DEFINES variable. | |
| 150 # | |
| 151 # Comment this out so we use the checked-in config.h in the | |
| 152 # linux subdirectory, but leave it here in case we need | |
| 153 # to ressurect this. | |
| 154 #env.Command('$OPEN_VCDIFF_DIR/src/config.h', | |
| 155 # '$OPEN_VCDIFF_DIR/src/config.h.in', | |
| 156 # Action(AutoConfig, varlist=['DEFINES']), | |
| 157 # DEFINES=defines) | |
| 158 | |
| 159 | |
| 160 p = env.ChromeMSVSProject('sdch.vcproj', | |
| 161 dest='$CHROME_SRC_DIR/sdch/sdch.vcproj', | |
| 162 guid='{F54ABC59-5C00-414A-A9BA-BAF26D1699F0}', | |
| 163 keyword='Win32Proj', | |
| 164 # TODO(sgk): when we can intuit the hierarchy | |
| 165 # from the built targets. | |
| 166 #buildtargets=TODO, | |
| 167 files=input_files, | |
| 168 relative_path_prefix='./', | |
| 169 tools=[ | |
| 170 'VCPreBuildEventTool', | |
| 171 'VCCustomBuildTool', | |
| 172 'VCXMLDataGeneratorTool', | |
| 173 'VCWebServiceProxyGeneratorTool', | |
| 174 'VCMIDLTool', | |
| 175 MSVSTool('VCCLCompilerTool', | |
| 176 AdditionalIncludeDirectories=[ | |
| 177 './open-vcdiff/vsprojects', | |
| 178 '', | |
| 179 ], | |
| 180 DefaultCharIsUnsigned="true"), | |
| 181 'VCManagedResourceCompilerTool', | |
| 182 'VCResourceCompilerTool', | |
| 183 'VCPreLinkEventTool', | |
| 184 'VCLibrarianTool', | |
| 185 'VCALinkTool', | |
| 186 'VCXDCMakeTool', | |
| 187 'VCBscMakeTool', | |
| 188 'VCFxCopTool', | |
| 189 'VCPostBuildEventTool', | |
| 190 ], | |
| 191 ConfigurationType='4') | |
| 192 | |
| 193 | |
| 194 p.AddConfig('Debug|Win32', | |
| 195 InheritedPropertySheets=[ | |
| 196 '$(SolutionDir)../build/debug.vsprops', | |
| 197 '$(SolutionDir)../sdch/using_sdch.vsprops', | |
| 198 ]) | |
| 199 | |
| 200 p.AddConfig('Release|Win32', | |
| 201 InheritedPropertySheets=[ | |
| 202 '$(SolutionDir)../build/release.vsprops', | |
| 203 '$(SolutionDir)../sdch/using_sdch.vsprops', | |
| 204 ]) | |
| OLD | NEW |