annotate SConstruct @ 126:a9cb396529c2

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