annotate SConstruct @ 662:7e18c84ca2b7

Small cleanup of eigen usage in SAI implementation.
author ronw@google.com
date Tue, 16 Jul 2013 19:56:11 +0000
parents 49eef19e4f1d
children
rev   line source
tomwalters@163 1 # Copyright 2006-2010, Willem van Engen, Thomas Walters
tomwalters@163 2 #
tomwalters@163 3 # AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@163 4 # http://www.acousticscale.org/AIMC
tomwalters@163 5 #
tomwalters@163 6 # Licensed under the Apache License, Version 2.0 (the "License");
tomwalters@163 7 # you may not use this file except in compliance with the License.
tomwalters@163 8 # You may obtain a copy of the License at
tomwalters@163 9 #
tomwalters@163 10 # http://www.apache.org/licenses/LICENSE-2.0
tomwalters@163 11 #
tomwalters@163 12 # Unless required by applicable law or agreed to in writing, software
tomwalters@163 13 # distributed under the License is distributed on an "AS IS" BASIS,
tomwalters@163 14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tomwalters@163 15 # See the License for the specific language governing permissions and
tomwalters@163 16 # limitations under the License.
tomwalters@163 17
tomwalters@163 18 ## @author Thomas Walters <tom@acousticscale.org>
tomwalters@163 19 # @author Willem van Engen <cnbh@willem.engen.nl>
tomwalters@163 20 # @date created 2010/02/02
tomwalters@163 21 # @version \$Id$
tomwalters@163 22
tomwalters@163 23 """@package SConstruct
tomwalters@163 24 SConstruct file for the aimc project
tomwalters@163 25
tomwalters@163 26 """
tomwalters@163 27
tomwalters@163 28 import os
tomwalters@163 29 import shutil
tomwalters@163 30
tomwalters@252 31 # Location of libraries / headers on Windows
tomwalters@163 32 windows_libsndfile_location = "C:\\Program Files\\Mega-Nerd\\libsndfile\\"
tomwalters@252 33 windows_cairo_location = "C:\\Program Files\\cairo\\"
tomwalters@163 34
tomwalters@163 35 # Sources common to every version
tomwalters@163 36 common_sources = ['Support/Common.cc',
tomwalters@163 37 'Support/FileList.cc',
tomwalters@163 38 'Support/SignalBank.cc',
tomwalters@163 39 'Support/Parameters.cc',
tomwalters@163 40 'Support/Module.cc',
tomwalters@163 41 'Support/ModuleFactory.cc',
tomwalters@232 42 'Support/ModuleTree.cc',
tomwalters@163 43 'Modules/Input/ModuleFileInput.cc',
tomwalters@163 44 'Modules/BMM/ModuleGammatone.cc',
tomwalters@163 45 'Modules/BMM/ModulePZFC.cc',
tomwalters@163 46 'Modules/NAP/ModuleHCL.cc',
tomwalters@163 47 'Modules/Strobes/ModuleParabola.cc',
tomwalters@163 48 'Modules/Strobes/ModuleLocalMax.cc',
tomwalters@163 49 'Modules/SAI/ModuleSAI.cc',
tomwalters@163 50 'Modules/SSI/ModuleSSI.cc',
tomwalters@163 51 'Modules/Profile/ModuleSlice.cc',
tomwalters@163 52 'Modules/Profile/ModuleScaler.cc',
tomwalters@163 53 'Modules/Output/FileOutputHTK.cc',
tomwalters@187 54 'Modules/Output/FileOutputAIMC.cc',
sness@607 55 'Modules/Output/FileOutputJSON.cc',
tom@514 56 #'Modules/Output/OSCOutput.cc',
tom@245 57 'Modules/Features/ModuleGaussians.cc',
tom@245 58 'Modules/Features/ModuleBoxes.cc',]
tomwalters@235 59 #'Modules/Features/ModuleDCT.cc' ]
tom@514 60
tomwalters@227 61 graphics_sources = [ 'Modules/Output/Graphics/GraphAxisSpec.cc',
tomwalters@227 62 'Modules/Output/Graphics/GraphicsView.cc',
tomwalters@227 63 'Modules/Output/Graphics/GraphicsViewTime.cc',
tomwalters@232 64 'Modules/Output/Graphics/Scale/Scale.cc',
tomwalters@227 65 'Modules/Output/Graphics/Devices/GraphicsOutputDevice.cc',
tomwalters@227 66 'Modules/Output/Graphics/Devices/GraphicsOutputDeviceCairo.cc',
tomwalters@232 67 'Modules/Output/Graphics/Devices/GraphicsOutputDeviceMovie.cc',]
tomwalters@232 68 #'Modules/Output/Graphics/Devices/GraphicsOutputDeviceMovieDirect.cc' ]
tom@514 69 graphics_libraries = [ 'cairo',
tomwalters@232 70 ]
tomwalters@163 71
tomwalters@163 72 # List of currently incative source files which we may want to add back in
tomwalters@163 73 sources_disabled = ['Modules/SNR/ModuleNoise.cc',
tomwalters@187 74 ]
tomwalters@163 75
tomwalters@163 76 # File which contains main()
tomwalters@232 77 #sources = common_sources + graphics_sources + ['Main/AIMCopy_SSI_Features_v3.cc']
tomwalters@163 78 #sources = common_sources + ['Main/AIMCopy_SSI_Features_v4_PZFC.cc']
tomwalters@232 79 sources = common_sources + graphics_sources + ['Main/AIMCopy.cc']
tomwalters@186 80 #sources = common_sources + ['Main/aimc.cc']
tomwalters@163 81
tomwalters@163 82 # Test sources
tomwalters@163 83 test_sources = ['Modules/Profile/ModuleSlice_unittest.cc']
tomwalters@163 84 test_sources += common_sources
tomwalters@163 85
tomwalters@163 86 # Define the command-line options for running scons
tomwalters@163 87 options = Variables()
tom@514 88 options.Add(BoolVariable('mingw',
tomwalters@163 89 'Compile on Windows using mingw rather than msvc',
tomwalters@163 90 False))
tom@514 91 options.Add(BoolVariable('symbols',
tomwalters@163 92 'Add debuging symbols when compiling on gcc',
tomwalters@163 93 False))
tomwalters@163 94
tomwalters@163 95 # Environment variables
tomwalters@163 96 env = Environment(options = options, ENV = os.environ)
tomwalters@163 97 if env['mingw']:
tomwalters@163 98 # SCons Defaults to MSVC if installed on Windows.
tomwalters@163 99 env = Environment(options = opts, ENV = os.environ, tools = ['mingw'])
tomwalters@163 100
tomwalters@163 101 # Platform
tomwalters@163 102 build_platform = env['PLATFORM']
tomwalters@163 103 target_platform = build_platform
tomwalters@163 104
tomwalters@163 105 # Build products location and executable name
tomwalters@163 106 build_dir = os.path.join('build', target_platform + '-release')
tomwalters@186 107 #target_executable = 'aimc'
tomwalters@186 108 target_executable = 'AIMCopy'
tomwalters@163 109 test_executable = 'aimc_tests'
tomwalters@163 110
tomwalters@163 111 # Create build products directory if necessary
tomwalters@163 112 if not os.path.exists(build_dir):
tomwalters@163 113 os.makedirs(build_dir)
tomwalters@163 114 env.SConsignFile(os.path.join(build_dir,'.sconsign'))
tomwalters@163 115
tomwalters@163 116 # Set any platform-specific environment variables and options
tomwalters@163 117 if target_platform == 'win32':
tom@514 118 env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32',
tomwalters@163 119 'WINVER=0x0400', '_CONSOLE'])
tomwalters@163 120 elif target_platform == 'darwin':
tomwalters@163 121 env.AppendUnique(CPPDEFINES = ['_MACOSX'])
tomwalters@163 122
tomwalters@163 123 # Compiler selection based on platform
tomwalters@163 124 # compiler can be one of: gcc msvc
tomwalters@163 125 compiler = 'gcc'
tom@514 126 if (build_platform == 'win32'
tom@514 127 and target_platform == 'win32'
tomwalters@163 128 and not env['mingw']):
tomwalters@163 129 compiler = 'msvc'
tomwalters@163 130
tomwalters@163 131 # Compiler-specific options:
tomwalters@163 132 # Microsoft visual studio
tomwalters@163 133 if compiler == 'msvc':
tomwalters@163 134 env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc'])
tom@514 135 env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE',
tomwalters@163 136 '_RINT_REQUIRED'])
tomwalters@163 137 env.AppendUnique(CPPFLAGS = ['/Ox'])
tomwalters@163 138 env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT'])
tomwalters@163 139
tomwalters@163 140 # GNU compiler collection
tomwalters@163 141 elif compiler == 'gcc':
tomwalters@163 142 env['STRIP'] = 'strip'
tomwalters@163 143 env.AppendUnique(CPPFLAGS = ['-Wall'])
tomwalters@237 144 env.AppendUnique(CPPFLAGS = ['-O1',])# '-fomit-frame-pointer'])
tomwalters@163 145 if env['symbols']:
tomwalters@163 146 env.AppendUnique(CPPFLAGS = ['-g'])
tomwalters@163 147 if env['mingw']:
tomwalters@163 148 if not env['PLATFORM'] == 'win32':
tomwalters@163 149 print('Cross-compilation for Windows is not supported')
tomwalters@163 150 Exit(1)
tomwalters@163 151 else:
tomwalters@163 152 print('Unsupported compiler: ' + compiler)
tomwalters@163 153 Exit(1)
tom@514 154
tom@514 155 # To make a statically-linked version for os 10.4 and up...
tomwalters@163 156 #if build_platform == 'darwin':
tomwalters@163 157 # env.AppendUnique(CPPFLAGS = ['-arch', 'i386'])
tomwalters@163 158 # env.AppendUnique(LINKFLAGS = ['-arch', 'i386'])
tomwalters@163 159 # env.AppendUnique(LINKFLAGS = ['-Wl'])
tomwalters@163 160 # env.AppendUnique(LINKFLAGS = ['-search_paths_first'])
tomwalters@163 161 # env.AppendUnique(MACOSX_DEPLOYMENT_TARGET = ['10.4'])
tomwalters@163 162 # env.AppendUnique(GCC_VERSION = ['4.0'])
tomwalters@163 163 # env.Replace(CC = ['gcc-4.0'])
tomwalters@163 164 # env.Replace(CXX = ['gcc-4.0'])
tomwalters@163 165 # env.AppendUnique(CPPFLAGS = ['-fno-stack-protector','-isysroot', '/Developer/SDKs/MacOSX10.5.sdk', '-mmacosx-version-min=10.4'])
tom@514 166 # deplibs = ['sndfile', 'flac', 'vorbis', 'vorbisenc', 'ogg']
tomwalters@163 167 if not target_platform == 'win32':
tomwalters@163 168 # On windows, utf support is builtin for SimpleIni
tomwalters@163 169 # but not on other platforms
tomwalters@163 170 sources += ['Support/ConvertUTF.c']
tomwalters@163 171
tomwalters@163 172 # Place the build products in the corect place
tomwalters@163 173 env.VariantDir('#' + build_dir, '#', duplicate = 0)
tomwalters@163 174
tomwalters@163 175 # Look for the sources in the correct place
tomwalters@163 176 env.Append(CPPPATH = ['#src'])
tomwalters@163 177
tomwalters@163 178 # Dependencies
tomwalters@163 179 deplibs = ['sndfile']
tomwalters@232 180 deplibs += graphics_libraries
tomwalters@163 181
tom@514 182 #env.Append(CPPPATH = ['#external/oscpack/'])
tom@514 183 #env.AppendUnique(LIBPATH = ['#external/oscpack/'])
tomwalters@509 184
tomwalters@163 185 if target_platform != 'win32':
tomwalters@163 186 for depname in deplibs:
tomwalters@163 187 env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@163 188 else:
tomwalters@163 189 #env.AppendUnique(LIBS = ['wsock32', 'winmm'])
tomwalters@163 190 if 'sndfile' in deplibs:
tomwalters@163 191 ###### libsndfile ########################################
tomwalters@163 192 # This one is only valid for win32 and already precompiled
tomwalters@163 193 # Only need to create .lib file from .def
tomwalters@163 194 shutil.copyfile(windows_libsndfile_location + '/libsndfile-1.dll',
tomwalters@163 195 build_dir+'/libsndfile-1.dll')
tomwalters@163 196 if compiler=='msvc':
tomwalters@163 197 shutil.copyfile(windows_libsndfile_location + '/libsndfile-1.def',
tomwalters@163 198 build_dir+'/libsndfile-1.def')
tomwalters@163 199 env.Command(build_dir + '/libsndfile-1.lib', build_dir + '/libsndfile-1.def',
tomwalters@163 200 env['AR'] + ' /nologo /machine:i386 /def:$SOURCE /out:$TARGET')
tomwalters@163 201 env.Append(CPPPATH = [windows_libsndfile_location + '/include/'])
tomwalters@163 202 env.AppendUnique(LIBPATH = [build_dir])
tomwalters@163 203 # Replace 'sndfile' with 'sndfile-1'
tomwalters@163 204 deplibs.remove('sndfile')
tomwalters@163 205 deplibs.append('libsndfile-1')
tomwalters@252 206 if 'cairo' in deplibs:
tomwalters@252 207 shutil.copyfile(windows_cairo_location + '/bin/libcairo-2.dll',
tomwalters@252 208 build_dir+'/libcairo-2.dll')
tomwalters@252 209 env.Append(CPPPATH = [windows_cairo_location + '/include/cairo/'])
tomwalters@252 210 env.AppendUnique(LIBPATH = [windows_cairo_location + '/lib/'])
tom@514 211
tom@514 212 #deplibs.append('liboscpack')
tomwalters@163 213 env.AppendUnique(LIBS = deplibs)
tomwalters@163 214
tomwalters@163 215
tomwalters@163 216
tomwalters@163 217 # Builder for the main program
tomwalters@163 218 program = env.Program(target = os.path.join(build_dir, target_executable),
tomwalters@163 219 source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@163 220 sources))
tomwalters@163 221 env.Alias(target_executable, os.path.join(build_dir, target_executable))
tomwalters@163 222 env.Default(program)
tomwalters@163 223
tomwalters@163 224 #test_env = env.Clone()
tomwalters@163 225 #test_libs = ['gtest', 'gtest_main']
tomwalters@163 226 ##for depname in test_libs:
tomwalters@163 227 ## test_env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@163 228 #test_env.AppendUnique(LIBPATH = ['/usr/local/lib'],
tomwalters@163 229 # CPPPATH = ['/usr/local/lib'],
tomwalters@163 230 # LIBS = test_libs)
tomwalters@163 231 #
tomwalters@163 232 #test = test_env.Program(target = os.path.join(build_dir, test_executable),
tomwalters@163 233 # source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@163 234 # test_sources))
tomwalters@163 235 #env.Alias('test', os.path.join(build_dir, test_executable))