1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
#!/usr/bin/python
import os
import glob
import sys
options = Variables('options.cache', ARGUMENTS)
options.Add(PathVariable('prefix', 'The prefix where the application will be installed', ''))
options.Add(PathVariable('clam_prefix', 'The prefix where CLAM was installed', ''))
options.Add(BoolVariable('release', 'Enabling compiler optimizations', 'no') )
options.Add(BoolVariable('verbose', 'Display the full command line instead a short command description', 'no') )
options.Add(PathVariable('external_dll_path', '(Windows only) The place where the NSIS packager takes the installed DLL from', '.'))
if sys.platform=="linux2" :
options.Add(BoolVariable('crossmingw', 'Using MinGW crosscompiler mode', 'no') )
def scanFiles(pattern, paths) :
files = []
for path in paths :
files+=glob.glob(os.path.join(path,pattern))
return files
def recursiveDirs(root) :
return filter( (lambda a : a.rfind( ".svn")==-1 ), [ a[0] for a in os.walk(root)] )
def unique(list) :
return dict.fromkeys(list).keys()
toolchain='default'
if sys.platform == 'win32': toolchain = 'mingw'
env = Environment(ENV=os.environ, tools=[toolchain], options=options)
options.Save('options.cache', env)
Help(options.GenerateHelpText(env))
env.SConsignFile() # Single signature file
crosscompiling = env.has_key("crossmingw") and env["crossmingw"]
isWindowsPlatform = sys.platform=='win32' or crosscompiling
isLinuxPlatform = sys.platform=='linux2' and not crosscompiling
isDarwinPlatform = sys.platform=='darwin'
CLAMInstallDir = env['clam_prefix']
clam_sconstoolspath = os.path.join(CLAMInstallDir,'share','clam','sconstools')
env.Tool('clam', toolpath=[clam_sconstoolspath])
env.Tool('nsis', toolpath=[clam_sconstoolspath])
if sys.platform=='darwin' : env.Tool('bundle', toolpath=[clam_sconstoolspath])
env.Tool('dmg', toolpath=[clam_sconstoolspath])
if crosscompiling :
env.Tool('crossmingw', toolpath=[clam_sconstoolspath])
sys.path.append(clam_sconstoolspath)
env['CXXFILESUFFIX'] = '.cxx'
if not env['verbose']:
env['CXXCOMSTR'] = '== Compiling $SOURCE'
env['SHCXXCOMSTR'] = '== Compiling shared $SOURCE'
env['LINKCOMSTR'] = '== Linking $TARGET'
env['SHLINKCOMSTR'] = '== Linking library $TARGET'
env.EnableClamModules([
'clam_core',
'clam_audioio',
'clam_processing',
], CLAMInstallDir)
mainSources = {
'Chordata' : os.path.join('src','main.cxx'),
}
sourcePaths = [
os.path.join('.'),
]
extraPaths = []
extraPaths += [
CLAMInstallDir+'/include',
CLAMInstallDir+'/include/CLAM', # KLUDGE to keep old style includes
"../UnitTests/CommonHelpers/",
]
includePaths = sourcePaths + extraPaths
sources = scanFiles('*.cxx', sourcePaths)
sources = unique(sources)
env.Append(CPPPATH=includePaths)
#env.Prepend(LIBS="clam_vmqt4")
if sys.platform=='darwin' :
env.Append(CPPFLAGS='-DRESOURCES_BASE="\\"Chordata.app/Contents/Resources\\""')
else :
env.Append(CPPFLAGS='-DRESOURCES_BASE="\\"' + env['prefix'] + '/share/chordata\\""')
if sys.platform!='win32' :
# TODO: This should not be hardcoded neither prefix (because package intall)
env.Append(CPPFLAGS='-DDATA_EXAMPLES_PATH="\\"%s\\""'%env['prefix'] + '/share/chordata/example-data')
if sys.platform=='linux2' :
if env['release'] :
env.Append( CCFLAGS=['-g','-O3','-fomit-frame-pointer','-Wall'] )
else :
env.Append( CCFLAGS=['-g','-O3','-Wall'] )
#commonObjects = env.StaticLibrary(target="chordata", source=sources)
programs = [ env.Program(source = source)
for source in sources]
example_data = [
#'example-data/Chords.pro'
]
pluginDefines=['-DQT_PLUGIN','-DQT_NO_DEBUG','-DQDESIGNER_EXPORT_WIDGETS','-D_REENTRANT']
env.AppendUnique(CPPFLAGS=pluginDefines)
env.AppendUnique(LIBS='cppunit')
def absolutePosixPathToWine(dir) :
return 'z:'+'\\\\'.join(dir.split('/'))
if isWindowsPlatform :
winqtdir=env['QTDIR']
if crosscompiling : env['NSIS_MAKENSIS'] = 'wine ~/.wine/dosdevices/c:/Program\ Files/NSIS/makensis'
if crosscompiling : winqtdir = absolutePosixPathToWine(winqtdir)
externalDllPath = env['external_dll_path']
if crosscompiling : externalDllPath = absolutePosixPathToWine(externalDllPath)
winclampath = CLAMInstallDir
if crosscompiling : winclampath = absolutePosixPathToWine(winclampath)
if crosscompiling :
env.AddPostAction(programs, env.Action(["i586-mingw32msvc-strip $TARGET"]))
installTargets += [
env.Install(
env['prefix']+"/bin",
os.path.join(env['QTDIR'],'bin',"Qt"+dll+"4.dll")
) for dll in 'Core', 'Gui', 'OpenGL']
env.Append(NSIS_OPTIONS=['/DVERSION=%s' % fullVersion ])
env.Append(NSIS_OPTIONS=['/DQTDIR=%s'%winqtdir ])
env.Append(NSIS_OPTIONS=['/DEXTERNALDLLDIR=%s' % externalDllPath ])
env.Append(NSIS_OPTIONS=['/DCLAMINSTALLDIR=%s' % winclampath ])
# Get the visual studio runtimes path
for vcRuntimeDir in os.environ['PATH'].split(";") :
vcRuntimeDir = os.path.normpath(vcRuntimeDir)
if os.access(os.path.join(vcRuntimeDir,"msvcr71.dll"),os.R_OK) :
break
env.Append(NSIS_OPTIONS=['/DVCRUNTIMEDIR=%s' % vcRuntimeDir ])
win_packages = [env.Nsis( source='resources/installer.nsi')]
env.Alias('package', win_packages)
if sys.platform=='darwin' :
# TODO: Review why those flags were added# TODO: Review why those flags were added# TODO: Review why those flags were added
env.Append(CPPFLAGS='-DRESOURCES_BASE="\\"Chordata.app/Contents/Resources\\""')
env.AppendUnique( LINKFLAGS=['-dynamic','-bind_at_load'])
#TODO install resources
installTargets = []
mac_bundle = env.Bundle(
BUNDLE_NAME='Chordata',
BUNDLE_BINARIES=programs,
# BUNDLE_RESOURCEDIRS=['foo','bar'],
BUNDLE_PLIST='resources/Info.plist',
BUNDLE_ICON='resources/CLAM-Chordata.icns',
)
env.Alias('bundle', mac_bundle)
#TODO mac_bundle should be dependency of Dmga:
arch = os.popen("uname -p").read().strip()
mac_packages = env.Dmg('CLAM_Chordata-%s-%s.dmg'% (fullVersion, arch), [
env.Dir('Chordata.app/'),
env.Dir('example-data/'),
]+installTargets )
env.Alias('package', mac_packages)
env.Default(programs)
|