annotate SConstruct @ 116:47b009f2c936

- First add of a lot of graphics code from the old version. Not working yet, not even compiling yet.
author tomwalters
date Fri, 15 Oct 2010 05:40:53 +0000
parents 37b084ec9770
children 3cdaa81c3aca
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@52 41 'Modules/Input/ModuleFileInput.cc',
tomwalters@52 42 'Modules/BMM/ModuleGammatone.cc',
tomwalters@52 43 'Modules/BMM/ModulePZFC.cc',
tomwalters@52 44 'Modules/NAP/ModuleHCL.cc',
tomwalters@52 45 'Modules/Strobes/ModuleParabola.cc',
tomwalters@52 46 'Modules/Strobes/ModuleLocalMax.cc',
tomwalters@52 47 'Modules/SAI/ModuleSAI.cc',
tomwalters@52 48 'Modules/SSI/ModuleSSI.cc',
tomwalters@52 49 'Modules/Profile/ModuleSlice.cc',
tomwalters@52 50 'Modules/Profile/ModuleScaler.cc',
tomwalters@52 51 'Modules/Output/FileOutputHTK.cc',
tomwalters@76 52 'Modules/Output/FileOutputAIMC.cc',
tomwalters@76 53 'Modules/Features/ModuleGaussians.cc']
tomwalters@116 54
tomwalters@116 55 graphics_sources = [ 'Modules/Output/Graphics/GraphAxisSpec.cc',
tomwalters@116 56 'Modules/Output/Graphics/GraphicsView.cc',
tomwalters@116 57 'Modules/Output/Graphics/GraphicsViewTime.cc',
tomwalters@116 58 'Modules/Output/Graphics/Devices/GraphicsOutputDevice.cc',
tomwalters@116 59 'Modules/Output/Graphics/Devices/GraphicsOutputDeviceCairo.cc',
tomwalters@116 60 'Modules/Output/Graphics/Devices/GraphicsOutputDeviceMovie.cc',
tomwalters@116 61 'Modules/Output/Graphics/Devices/GraphicsOutputDeviceMovieDirect.cc' ]
tomwalters@116 62 graphics_libraries = [ 'cairo',
tomwalters@116 63 '' ]
tomwalters@52 64
tomwalters@52 65 # List of currently incative source files which we may want to add back in
tomwalters@52 66 sources_disabled = ['Modules/SNR/ModuleNoise.cc',
tomwalters@76 67 ]
tomwalters@52 68
tomwalters@52 69 # File which contains main()
tomwalters@75 70 sources = common_sources + ['Main/AIMCopy_SSI_Features_v3.cc']
tomwalters@52 71 #sources = common_sources + ['Main/AIMCopy_SSI_Features_v4_PZFC.cc']
tomwalters@52 72 #sources = common_sources + ['Main/AIMCopy_SSI_Features_v5_smooth_nap.cc']
tomwalters@75 73 #sources = common_sources + ['Main/aimc.cc']
tomwalters@52 74
tomwalters@52 75 # Test sources
tomwalters@52 76 test_sources = ['Modules/Profile/ModuleSlice_unittest.cc']
tomwalters@52 77 test_sources += common_sources
tomwalters@52 78
tomwalters@52 79 # Define the command-line options for running scons
tomwalters@52 80 options = Variables()
tomwalters@52 81 options.Add(BoolVariable('mingw',
tomwalters@52 82 'Compile on Windows using mingw rather than msvc',
tomwalters@52 83 False))
tomwalters@52 84 options.Add(BoolVariable('symbols',
tomwalters@52 85 'Add debuging symbols when compiling on gcc',
tomwalters@52 86 False))
tomwalters@52 87
tomwalters@52 88 # Environment variables
tomwalters@52 89 env = Environment(options = options, ENV = os.environ)
tomwalters@52 90 if env['mingw']:
tomwalters@52 91 # SCons Defaults to MSVC if installed on Windows.
tomwalters@52 92 env = Environment(options = opts, ENV = os.environ, tools = ['mingw'])
tomwalters@52 93
tomwalters@52 94 # Platform
tomwalters@52 95 build_platform = env['PLATFORM']
tomwalters@52 96 target_platform = build_platform
tomwalters@52 97
tomwalters@52 98 # Build products location and executable name
tomwalters@52 99 build_dir = os.path.join('build', target_platform + '-release')
tomwalters@75 100 #target_executable = 'aimc'
tomwalters@75 101 target_executable = 'AIMCopy'
tomwalters@52 102 test_executable = 'aimc_tests'
tomwalters@52 103
tomwalters@52 104 # Create build products directory if necessary
tomwalters@52 105 if not os.path.exists(build_dir):
tomwalters@52 106 os.makedirs(build_dir)
tomwalters@52 107 env.SConsignFile(os.path.join(build_dir,'.sconsign'))
tomwalters@52 108
tomwalters@52 109 # Set any platform-specific environment variables and options
tomwalters@52 110 if target_platform == 'win32':
tomwalters@52 111 env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32',
tomwalters@52 112 'WINVER=0x0400', '_CONSOLE'])
tomwalters@52 113 elif target_platform == 'darwin':
tomwalters@52 114 env.AppendUnique(CPPDEFINES = ['_MACOSX'])
tomwalters@52 115
tomwalters@52 116 # Compiler selection based on platform
tomwalters@52 117 # compiler can be one of: gcc msvc
tomwalters@52 118 compiler = 'gcc'
tomwalters@52 119 if (build_platform == 'win32'
tomwalters@52 120 and target_platform == 'win32'
tomwalters@52 121 and not env['mingw']):
tomwalters@52 122 compiler = 'msvc'
tomwalters@52 123
tomwalters@52 124 # Compiler-specific options:
tomwalters@52 125 # Microsoft visual studio
tomwalters@52 126 if compiler == 'msvc':
tomwalters@52 127 env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc'])
tomwalters@52 128 env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE',
tomwalters@52 129 '_RINT_REQUIRED'])
tomwalters@52 130 env.AppendUnique(CPPFLAGS = ['/Ox'])
tomwalters@52 131 env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT'])
tomwalters@52 132
tomwalters@52 133 # GNU compiler collection
tomwalters@52 134 elif compiler == 'gcc':
tomwalters@52 135 env['STRIP'] = 'strip'
tomwalters@52 136 env.AppendUnique(CPPFLAGS = ['-Wall'])
tomwalters@52 137 env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer'])
tomwalters@52 138 if env['symbols']:
tomwalters@52 139 env.AppendUnique(CPPFLAGS = ['-g'])
tomwalters@52 140 if env['mingw']:
tomwalters@52 141 if not env['PLATFORM'] == 'win32':
tomwalters@52 142 print('Cross-compilation for Windows is not supported')
tomwalters@52 143 Exit(1)
tomwalters@52 144 else:
tomwalters@52 145 print('Unsupported compiler: ' + compiler)
tomwalters@52 146 Exit(1)
tomwalters@52 147
tomwalters@52 148 # To make a statically-linked version for os 10.4 and up...
tomwalters@52 149 #if build_platform == 'darwin':
tomwalters@52 150 # env.AppendUnique(CPPFLAGS = ['-arch', 'i386'])
tomwalters@52 151 # env.AppendUnique(LINKFLAGS = ['-arch', 'i386'])
tomwalters@52 152 # env.AppendUnique(LINKFLAGS = ['-Wl'])
tomwalters@52 153 # env.AppendUnique(LINKFLAGS = ['-search_paths_first'])
tomwalters@52 154 # env.AppendUnique(MACOSX_DEPLOYMENT_TARGET = ['10.4'])
tomwalters@52 155 # env.AppendUnique(GCC_VERSION = ['4.0'])
tomwalters@52 156 # env.Replace(CC = ['gcc-4.0'])
tomwalters@52 157 # env.Replace(CXX = ['gcc-4.0'])
tomwalters@52 158 # env.AppendUnique(CPPFLAGS = ['-fno-stack-protector','-isysroot', '/Developer/SDKs/MacOSX10.5.sdk', '-mmacosx-version-min=10.4'])
tomwalters@52 159 # deplibs = ['sndfile', 'flac', 'vorbis', 'vorbisenc', 'ogg']
tomwalters@52 160 if not target_platform == 'win32':
tomwalters@52 161 # On windows, utf support is builtin for SimpleIni
tomwalters@52 162 # but not on other platforms
tomwalters@52 163 sources += ['Support/ConvertUTF.c']
tomwalters@52 164
tomwalters@52 165 # Place the build products in the corect place
tomwalters@52 166 env.VariantDir('#' + build_dir, '#', duplicate = 0)
tomwalters@52 167
tomwalters@52 168 # Look for the sources in the correct place
tomwalters@52 169 env.Append(CPPPATH = ['#src'])
tomwalters@52 170
tomwalters@52 171 # Dependencies
tomwalters@52 172 deplibs = ['sndfile']
tomwalters@52 173
tomwalters@52 174 if target_platform != 'win32':
tomwalters@52 175 for depname in deplibs:
tomwalters@52 176 env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@52 177 else:
tomwalters@52 178 #env.AppendUnique(LIBS = ['wsock32', 'winmm'])
tomwalters@52 179 if 'sndfile' in deplibs:
tomwalters@52 180 ###### libsndfile ########################################
tomwalters@52 181 # This one is only valid for win32 and already precompiled
tomwalters@52 182 # Only need to create .lib file from .def
tomwalters@52 183 shutil.copyfile(windows_libsndfile_location + '/libsndfile-1.dll',
tomwalters@52 184 build_dir+'/libsndfile-1.dll')
tomwalters@52 185 if compiler=='msvc':
tomwalters@52 186 shutil.copyfile(windows_libsndfile_location + '/libsndfile-1.def',
tomwalters@52 187 build_dir+'/libsndfile-1.def')
tomwalters@52 188 env.Command(build_dir + '/libsndfile-1.lib', build_dir + '/libsndfile-1.def',
tomwalters@52 189 env['AR'] + ' /nologo /machine:i386 /def:$SOURCE /out:$TARGET')
tomwalters@52 190 env.Append(CPPPATH = [windows_libsndfile_location + '/include/'])
tomwalters@52 191 env.AppendUnique(LIBPATH = [build_dir])
tomwalters@52 192 # Replace 'sndfile' with 'sndfile-1'
tomwalters@52 193 deplibs.remove('sndfile')
tomwalters@52 194 deplibs.append('libsndfile-1')
tomwalters@52 195 env.AppendUnique(LIBS = deplibs)
tomwalters@52 196
tomwalters@52 197
tomwalters@52 198
tomwalters@52 199 # Builder for the main program
tomwalters@52 200 program = env.Program(target = os.path.join(build_dir, target_executable),
tomwalters@52 201 source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@52 202 sources))
tomwalters@52 203 env.Alias(target_executable, os.path.join(build_dir, target_executable))
tomwalters@52 204 env.Default(program)
tomwalters@52 205
tomwalters@52 206 #test_env = env.Clone()
tomwalters@52 207 #test_libs = ['gtest', 'gtest_main']
tomwalters@52 208 ##for depname in test_libs:
tomwalters@52 209 ## test_env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@52 210 #test_env.AppendUnique(LIBPATH = ['/usr/local/lib'],
tomwalters@52 211 # CPPPATH = ['/usr/local/lib'],
tomwalters@52 212 # LIBS = test_libs)
tomwalters@52 213 #
tomwalters@52 214 #test = test_env.Program(target = os.path.join(build_dir, test_executable),
tomwalters@52 215 # source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@52 216 # test_sources))
tomwalters@52 217 #env.Alias('test', os.path.join(build_dir, test_executable))