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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
#!/usr/bin/python
import os
import glob
import sys
options = Variables('options.cache', ARGUMENTS)
options.Add(PathVariable('install_prefix', 'The prefix where the application will be installed', ''))
options.Add(PathVariable('clam_prefix', 'The prefix where CLAM was installed', ''))
options.Add(BoolVariable('verbose', 'Display the full command line instead a short command description', '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)] )
env = Environment(ENV=os.environ, tools=['default'], options=options)
options.Save('options.cache', env)
Help(options.GenerateHelpText(env))
env.SConsignFile() # Single signature file
CLAMInstallDir = env['clam_prefix']
clam_sconstoolspath = os.path.join(CLAMInstallDir,'share','clam','sconstools')
env.Tool('qt4', toolpath=[clam_sconstoolspath])
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])
sys.path.append(clam_sconstoolspath)
"""
import versionInfo
version, fullVersion = versionInfo.versionFromLocalInfo("NetworkEditor")
print "Version: ", version
print "Package version: ", fullVersion
versionInfo.generateVersionSources(os.path.join('src','NetworkEditorVersion'), "NetworkEditor", fullVersion)
"""
env['CXXFILESUFFIX'] = '.cxx'
env['QT4_UICDECLSUFFIX'] = '.hxx'
env['QT4_MOCHPREFIX'] = os.path.join('generated','moc_')
env['QT4_UICDECLPREFIX'] = os.path.join('generated','uic_')
env['QT4_QRCCXXPREFIX'] = os.path.join('generated','qrc_')
if not env['verbose']:
env['CXXCOMSTR'] = '== Compiling $SOURCE'
env['LINKCOMSTR'] = '== Linking $TARGET'
env['SHLINKCOMSTR'] = '== Linking library $TARGET'
env['QT4_RCCCOMSTR'] = '== Embeding resources $SOURCE'
env['QT4_UICCOMSTR'] = '== Compiling interface $SOURCE'
env['QT4_LRELEASECOMSTR'] = '== Compiling translation $TARGET'
env['QT4_MOCFROMHCOMSTR'] = '== Generating metaobjects for $SOURCE'
env['QT4_MOCFROMCXXCOMSTR'] = '== Generating metaobjects for $SOURCE'
env.EnableClamModules([
'clam_core',
'clam_audioio',
'clam_processing',
] , CLAMInstallDir)
env.EnableQt4Modules([
'QtCore',
'QtGui',
'QtOpenGL',
# 'QtSql',
# 'QtNetwork',
# 'QtTest',
'QtXml',
# 'QtSvg',
'QtUiTools',
# 'QtDesigner',
# 'Qt3Support',
], debug=False)
mainSources = {
'DownSampling_Example' : 'DownSampling/DownSampling_example.cxx',
'FormantExtractor_Example': 'FormantExtractor/FormantExtractor_example.cxx',
'MDP_Example' : 'MDP/MDP_example.cxx',
'TDFilterGenerator_Example' : 'TDFilterGenerator/TDFilterGenerator_example.cxx',
'FormantTracker_Test' : os.path.join('FormantTracker','FormantTracker_test.cxx'),
# 'DP_Test' : 'MDP/DP_test.cxx',
'Permute_Test' : 'MDP/Permute_test.cxx',
'MagnitudeFR_Test' : 'TDFilterGenerator/MagnitudeFR_test.cxx',
'TDFilter_Test' : os.path.join('TDFilterGenerator','TDFilter_test.cxx'),
'LPC_Example': 'LPC/LPC_Example.cxx',
}
sourcePaths = [
os.path.join('DownSampling'),
os.path.join('TDFilterGenerator'),
os.path.join('FormantExtractor'),
os.path.join('LPC'),
os.path.join('FormantTracker'),
os.path.join('MDP'),
]
extraPaths = [
CLAMInstallDir+'/include',
CLAMInstallDir+'/include/CLAM', # KLUDGE to keep old style includes
]
includePaths = sourcePaths + extraPaths
blacklist = [
'MDP/DP_test.cxx',
]
sources = scanFiles('*.cxx', sourcePaths)
sources = filter( (lambda a : a.rfind( "moc_")==-1 ), sources )
sources = filter( (lambda a : a.rfind( "qrc_")==-1 ), sources )
sources = dict.fromkeys(sources).keys()
for blacksheep in blacklist :
sources.remove(blacksheep)
for mainSource in mainSources.values() :
sources.remove(mainSource)
qrcfiles = scanFiles("*.qrc", sourcePaths)
if qrcfiles : sources += env.Qrc(source=qrcfiles)
uifiles = scanFiles("*.ui", sourcePaths)
if uifiles: uiheaders = env.Uic4(source=uifiles)
if sys.platform=="win32" :
sources += env.RES(source=["resources/NetworkEditor.rc"])
if sys.platform=='win32' :
env.Append(CPPFLAGS=['-D_USE_MATH_DEFINES']) # to have M_PI defined
if sys.platform=='linux2' :
# TODO: This should not be hardcoded neither install_prefix (because package install)
env.Append(CPPFLAGS='-DDATA_EXAMPLES_PATH="\\"/usr/share/networkeditor/example-data\\""')
if sys.platform=='linux2' :
env.Append( CCFLAGS=['-g','-O3','-Wall'] )
# env.Append( LINKFLAGS=['-rdynamic'] ) # TODO: Is it needed?
testsources = scanFiles('*.cxx', ['test'])
env.Append(CPPPATH=includePaths)
#commonObjects = env.StaticLibrary(target="networkeditor", source=sources)
#programs = [ env.Program(target=program, source = [main, commonObjects])
# for program, main in mainSources.items()]
programs = [ env.Program(target=program, source = [main] + sources)
for program, main in mainSources.items()]
#env.AppendUnique(CPPFLAGS=['-fPIC']) # qtPlugin examples were compiled with this option
# TODO: Move this to the qt4 tool
if os.getenv('QTDIR') :
env.AppendUnique(QT4_MOCFROMHFLAGS=['-I'+os.path.join(env['QTDIR'],'include')])
env.AppendUnique(QT4_MOCFROMCXXFLAGS=['-I'+os.path.join(env['QTDIR'],'include')])
else:
env.AppendUnique(QT4_MOCFROMHFLAGS=['-I/usr/include/qt4'])
env.AppendUnique(QT4_MOCFROMCXXFLAGS=['-I/usr/include/qt4'])
if sys.platform == "win32":
env.AppendUnique(LINKFLAGS='/OPT:NOREF')
manpages = [
'resources/man/man1/NetworkEditor.1',
'resources/man/man1/Prototyper.1',
]
# Manual step: lupdate-qt4 *xx *ui -ts NetworkEditor_ca.ts
tsfiles = scanFiles("*.ts", ["src/i18n/"])
#env.NoClean(tsfiles) # TODO: this is not enough!! scan -c will delete ts files!!!
translatableSources = scanFiles('*.cxx', sourcePaths);
translatableSources+= scanFiles('*.hxx', sourcePaths);
translatableSources+= scanFiles('*.ui', sourcePaths);
translatableSources = filter( (lambda a : a.rfind( "generated/")==-1 ), translatableSources )
translations = []
if len(tsfiles) :
# tsNodes = env.Ts(target=tsfiles, source = translatableSources)
translations = env.Qm(source = tsfiles)
examples = []
for ext in ['clamnetwork', 'pos', 'ui', 'wav', 'mp3', 'ogg']:
examples += scanFiles('*.%s'%ext, ['example-data'])
menuEntries = [
'resources/Prototyper.desktop',
'resources/NetworkEditor.desktop',
]
mimeEntries = [
'resources/clam-network.xml',
]
kdeMimeEntries = [
'resources/vnd.clam.network.desktop'
]
installation = {
'/bin' : programs,
'/share/applications': menuEntries,
'/share/mime/packages': mimeEntries,
'/share/mimelnk/application': kdeMimeEntries,
'/share/man/man1' : manpages,
'/share/networkeditor': ['resources/NetworkEditor-icon.svg'],
'/share/networkeditor/i18n': translations,
'/share/networkeditor/example-data': examples,
}
installTargets = [
env.Install( env['install_prefix']+path, files ) for path, files in installation.items() ]
if sys.platform=='win32' :
installTargets += [
env.Install(
env['install_prefix']+"/bin",
os.path.join(env['QTDIR'],'lib',"Qt"+dll+"4.dll")
) for dll in 'Core', 'Gui', 'OpenGL']
env.Append(NSIS_OPTIONS=['/DVERSION=%s' % fullVersion ])
env.Append(NSIS_OPTIONS=['/DQTDIR=$QTDIR'])
externalsDllDir = os.environ['EXTERNALDLLDIR']
env.Append(NSIS_OPTIONS=['/DEXTERNALDLLDIR=%s' % externalsDllDir ])
# 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\\clam_networkeditor.nsi')]
env.AddPreAction(win_packages, '%s\\changeExampleDataPath.py . ..' % clam_sconstoolspath)
env.Alias('package', win_packages)
if sys.platform=='darwin' :
mac_networkeditor_bundle = env.Bundle(
BUNDLE_NAME='NetworkEditor',
BUNDLE_BINARIES=["NetworkEditor"],
BUNDLE_RESOURCEDIRS=["example-data"],
BUNDLE_PLIST='resources/NetworkEditor-Info.plist',
BUNDLE_ICON='resources/CLAM.icns',
)
mac_prototyper_bundle = env.Bundle(
BUNDLE_NAME='Prototyper',
BUNDLE_BINARIES=["Prototyper"],
BUNDLE_PLUGINS=["libCLAMWidgets.dylib"],
BUNDLE_RESOURCEDIRS=[],
BUNDLE_PLIST='resources/Prototyper-Info.plist',
BUNDLE_ICON='resources/Prototyper.icns',
)
mac_designer_bundle = env.Bundle(
BUNDLE_NAME='QtDesigner',
BUNDLE_BINARIES=["$QTDIR/bin/Designer.app/Contents/MacOS/Designer"],
BUNDLE_PLUGINS=[
"libCLAMWidgets.dylib",
"$QTDIR/plugins/designer/libarthurplugin.dylib",
],
BUNDLE_RESOURCEDIRS=[],
BUNDLE_PLIST='resources/QtDesigner-Info.plist',
BUNDLE_ICON='resources/QtDesigner.icns',
)
# Kludge to fix the plugins location for Designer
env.AddPostAction( mac_designer_bundle, env.Action( [
'mv QtDesigner.app/Contents/MacOS/Designer QtDesigner.app/Contents/MacOS/QtDesigner',
'mkdir QtDesigner.app/Contents/MacOS/designer',
'mv QtDesigner.app/Contents/PlugIns/* QtDesigner.app/Contents/MacOS/designer',
]))
env.Alias('bundle', [mac_networkeditor_bundle, mac_prototyper_bundle, mac_designer_bundle])
#TODO mac_bundle should be dependency of Dmg:
arch = os.popen("uname -p").read().strip()
mac_packages = env.Dmg('CLAM_NetworkEditor-%s-%s.dmg'% (fullVersion, arch), [
env.Dir('NetworkEditor.app/'),
env.Dir('Prototyper.app'),
env.Dir('QtDesigner.app'),
] )
env.Alias('package', mac_packages)
env.Alias('install', installTargets )
env.Default(programs, translations)
|