annotate SConstruct @ 6:8c859ef1fb75

- Added a basic main function to test that all the can be fitted together - Fixed an initialisation bug in ModuleFileInput that left the buffer size at zero - Added proper description strings to the input and output modules - Fixed an out-by-a-factor-of-1000 bug in the SAI memory allocation (oops) - Added LOG_INFO_NN fucnction to log without a newline. Useful for the ASCII art module chain in aimc.cc.
author tomwalters
date Thu, 18 Feb 2010 19:35:07 +0000
parents 3c782dec2fc0
children bd370910aa05
rev   line source
tomwalters@0 1 # Copyright 2006-2010, Willem van Engen, Thomas Walters
tomwalters@0 2 #
tomwalters@0 3 # AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@0 4 # http://www.acousticscale.org/AIMC
tomwalters@0 5 #
tomwalters@0 6 # This program is free software: you can redistribute it and/or modify
tomwalters@0 7 # it under the terms of the GNU General Public License as published by
tomwalters@0 8 # the Free Software Foundation, either version 3 of the License, or
tomwalters@0 9 # (at your option) any later version.
tomwalters@0 10 #
tomwalters@0 11 # This program is distributed in the hope that it will be useful,
tomwalters@0 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@0 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@0 14 # GNU General Public License for more details.
tomwalters@0 15 #
tomwalters@0 16 # You should have received a copy of the GNU General Public License
tomwalters@0 17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@0 18
tomwalters@0 19 ## @author Thomas Walters <tom@acousticscale.org>
tomwalters@0 20 # @author Willem van Engen <cnbh@willem.engen.nl>
tomwalters@0 21 # @date created 2010/02/02
tomwalters@0 22 # @version \$Id$
tomwalters@0 23
tomwalters@0 24 """@package SConstruct
tomwalters@0 25 SConstruct file for the aimc project
tomwalters@0 26
tomwalters@0 27 """
tomwalters@0 28
tomwalters@0 29 import os
tomwalters@0 30 import shutil
tomwalters@0 31
tomwalters@0 32 # Define the command-line options for running scons
tomwalters@0 33 options = Variables()
tomwalters@0 34 options.Add(BoolVariable('mingw',
tomwalters@0 35 'Compile on Windows using mingw rather than msvc',
tomwalters@0 36 False))
tomwalters@0 37
tomwalters@0 38 # Environment variables
tomwalters@0 39 env = Environment(options = options, ENV = os.environ)
tomwalters@0 40 if env['mingw']:
tomwalters@0 41 # SCons Defaults to MSVC if installed on Windows.
tomwalters@0 42 env = Environment(options = opts, ENV = os.environ, tools = ['mingw'])
tomwalters@0 43
tomwalters@0 44 # Platform
tomwalters@0 45 build_platform = env['PLATFORM']
tomwalters@0 46 target_platform = build_platform
tomwalters@0 47
tomwalters@0 48 # Build products location and executable name
tomwalters@0 49 build_dir = os.path.join('build', target_platform + '-release')
tomwalters@0 50 target_executable = 'aimc'
tomwalters@0 51
tomwalters@0 52 # Create build products directory if necessary
tomwalters@0 53 if not os.path.exists(build_dir):
tomwalters@0 54 os.makedirs(build_dir)
tomwalters@0 55 env.SConsignFile(os.path.join(build_dir,'.sconsign'))
tomwalters@0 56
tomwalters@0 57 # Set any platform-specific environment variables and options
tomwalters@0 58 if target_platform == 'win32':
tomwalters@0 59 env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32',
tomwalters@0 60 'WINVER=0x0400', '_CONSOLE'])
tomwalters@0 61 elif target_platform == 'darwin':
tomwalters@0 62 env.AppendUnique(CPPDEFINES = ['_MACOSX'])
tomwalters@0 63
tomwalters@0 64 # Compiler selection based on platform
tomwalters@0 65 # compiler can be one of: gcc msvc
tomwalters@0 66 compiler = 'gcc'
tomwalters@0 67 if (build_platform == 'win32'
tomwalters@0 68 and target_platform == 'win32'
tomwalters@0 69 and not env['mingw']):
tomwalters@0 70 compiler = 'msvc'
tomwalters@0 71
tomwalters@0 72 # Compiler-specific options:
tomwalters@0 73 # Microsoft visual studio
tomwalters@0 74 if compiler == 'msvc':
tomwalters@0 75 env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc'])
tomwalters@0 76 env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE',
tomwalters@0 77 '_RINT_REQUIRED'])
tomwalters@0 78 env.AppendUnique(CPPFLAGS = ['/Ox'])
tomwalters@0 79 env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT'])
tomwalters@0 80
tomwalters@0 81 # GNU compiler collection
tomwalters@0 82 elif compiler == 'gcc':
tomwalters@0 83 env['STRIP'] = 'strip'
tomwalters@0 84 env.AppendUnique(CPPFLAGS = ['-Wall'])
tomwalters@0 85 env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer'])
tomwalters@0 86 if env['mingw']:
tomwalters@0 87 if not env['PLATFORM'] == 'win32':
tomwalters@0 88 print('Cross-compilation for Windows is not supported')
tomwalters@0 89 Exit(1)
tomwalters@0 90 else:
tomwalters@0 91 print('Unsupported compiler: ' + compiler)
tomwalters@0 92 Exit(1)
tomwalters@0 93
tomwalters@0 94 # Sources common to every version
tomwalters@0 95 common_sources = ['Support/Common.cc',
tomwalters@1 96 'Support/SignalBank.cc',
tomwalters@0 97 'Support/Parameters.cc',
tomwalters@3 98 'Support/Module.cc',
tomwalters@3 99 'Modules/Input/ModuleFileInput.cc',
tomwalters@5 100 'Modules/BMM/ModuleGammatone.cc',
tomwalters@0 101 'Modules/BMM/ModulePZFC.cc',
tomwalters@0 102 'Modules/NAP/ModuleHCL.cc',
tomwalters@5 103 'Modules/Strobes/ModuleParabola.cc',
tomwalters@5 104 'Modules/SAI/ModuleSAI.cc',
tomwalters@5 105 'Modules/Features/ModuleGaussians.cc',
tomwalters@5 106 'Modules/Output/FileOutputHTK.cc']
tomwalters@0 107
tomwalters@0 108 if not target_platform == 'win32':
tomwalters@0 109 # On windows, utf support is builtin for SimpleIni
tomwalters@0 110 # bit not on other platforms
tomwalters@0 111 common_sources += ['Support/ConvertUTF.c']
tomwalters@0 112
tomwalters@0 113 # Choose file which contains main()
tomwalters@1 114 sources = common_sources + ['Main/aimc.cc']
tomwalters@0 115
tomwalters@0 116 # Place the build products in the corect place
tomwalters@0 117 env.BuildDir('#' + build_dir, '#', duplicate = 0)
tomwalters@0 118
tomwalters@0 119 # Look for the sources in the correct place
tomwalters@0 120 env.Append(CPPPATH = '#src')
tomwalters@0 121
tomwalters@0 122 # Dependencies
tomwalters@3 123 deplibs = ['sndfile']
tomwalters@3 124
tomwalters@3 125 for depname in deplibs:
tomwalters@3 126 env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@3 127
tomwalters@0 128 env.AppendUnique(LIBS = deplibs)
tomwalters@0 129
tomwalters@0 130 # Set up the builder to build the program
tomwalters@0 131 program = env.Program(target = os.path.join(build_dir, target_executable),
tomwalters@0 132 source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@0 133 sources))
tomwalters@0 134 env.Default(program)