annotate trunk/carfac/SConstruct @ 684:49af9a8d5a53

Initial translation of SAI code to C++. This only implements the simple (as opposed to the layered) SAI, as implemented in SAI_Run.m.
author ronw@google.com
date Fri, 31 May 2013 21:46:48 +0000
parents 10dc41e4d2f2
children d0612798f6de
rev   line source
ronw@666 1 # CARFAC Open Source C++ Library
ronw@666 2 #
ronw@666 3 # This C++ file is part of an implementation of Lyon's cochlear model:
ronw@666 4 # "Cascade of Asymmetric Resonators with Fast-Acting Compression"
ronw@666 5 # to supplement Lyon's upcoming book "Human and Machine Hearing"
ronw@666 6 #
ronw@666 7 # Licensed under the Apache License, Version 2.0 (the "License");
ronw@666 8 # you may not use this file except in compliance with the License.
ronw@666 9 # You may obtain a copy of the License at
ronw@666 10 #
ronw@666 11 # http://www.apache.org/licenses/LICENSE-2.0
ronw@666 12 #
ronw@666 13 # Unless required by applicable law or agreed to in writing, software
ronw@666 14 # distributed under the License is distributed on an "AS IS" BASIS,
ronw@666 15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ronw@666 16 # See the License for the specific language governing permissions and
ronw@666 17 # limitations under the License.
ronw@666 18
ronw@666 19 ## @author Ron Weiss <ronw@google.com>
ronw@666 20 # @date created 2013/05/21
ronw@666 21 # @version \$Id$
ronw@666 22
ronw@666 23 """@package SConstruct
ronw@666 24 SConstruct file for the CARFAC Open Source C++ Library.
ronw@666 25
ronw@673 26 To install dependencies on Ubuntu, run:
ronw@666 27
ronw@673 28 sudo apt-get install libeigen3-dev scons \
ronw@673 29 cmake libgtest-dev libsndfile-dev # For testing.
ronw@673 30 export EIGEN_PATH=/usr/include/eigen3
ronw@673 31 export GTEST_SOURCE=/usr/src/gtest
ronw@673 32
ronw@673 33 To build all libraries, run:
ronw@666 34 scons
ronw@673 35
ronw@673 36 To run unit tests, run:
ronw@673 37 scons test
ronw@673 38
ronw@673 39 To clean up binaries, run:
ronw@673 40 scons --clean
ronw@666 41 """
ronw@666 42
ronw@681 43 import commands
ronw@666 44 import os
ronw@666 45
ronw@666 46 env = Environment(CPPPATH=[os.environ['EIGEN_PATH']])
ronw@681 47 GCC_VERSION = commands.getoutput(env['CXX'] + ' -dumpversion')
ronw@681 48 if GCC_VERSION.startswith('4.6'):
ronw@681 49 env.MergeFlags(['-std=c++0x'])
ronw@681 50 else:
alexbrandmeyer@682 51 env.MergeFlags(['-std=c++11'])
ronw@681 52
ronw@684 53 carfac_sources = [
ronw@684 54 'agc_coeffs.h',
ronw@684 55 'agc_params.h',
ronw@684 56 'agc_state.h',
ronw@684 57 'car_coeffs.h',
ronw@684 58 'carfac.cc',
ronw@684 59 'carfac_common.cc',
ronw@684 60 'carfac_output.cc',
ronw@684 61 'car_params.h',
ronw@684 62 'car_state.h',
ronw@684 63 'ear.cc',
ronw@684 64 'ihc_coeffs.h',
ronw@684 65 'ihc_params.h',
ronw@684 66 'ihc_state.h',
ronw@684 67 'sai.cc',
ronw@684 68 ]
ronw@666 69 env.Library(target = 'carfac', source = carfac_sources)
ronw@667 70
ronw@667 71 env.Command('tmp/libgtest.a', [],
ronw@667 72 [
ronw@667 73 Delete('tmp'),
ronw@667 74 Copy('tmp', os.environ['GTEST_SOURCE']),
ronw@667 75 'cd tmp && cmake . && make',
ronw@667 76 ])
ronw@667 77
ronw@684 78 test_sources = [
ronw@684 79 'carfac_test.cc',
ronw@684 80 'sai_test.cc',
ronw@684 81 ]
ronw@684 82 test_program = env.Program(target = 'test',
ronw@684 83 source = test_sources,
ronw@673 84 LIBS = ['carfac', 'gtest', 'gtest_main', 'pthread'],
ronw@673 85 LIBPATH = ['.', 'tmp'])
ronw@673 86 test_alias = Alias('test', [test_program], test_program[0].abspath)
ronw@673 87 AlwaysBuild(test_alias)