2011-02-03 16:15:25 +08:00
import fnmatch
Import('env', 'os', 'sys', 'plugins', 'dist',
2012-09-28 00:43:51 +08:00
'MTS_VERSION', 'hasQt', 'hasCollada', 'hasPython', 'hasBreakpad')
2011-02-03 16:15:25 +08:00
installTargets = []
2011-06-01 08:20:53 +08:00
def install(target, paths, prefix = None):
global installTargets
if prefix == None:
prefix = env['BUILDDIR']
for path in paths:
if os.path.splitext(path)[1] == '.dylib':
installTargets += env.OSXLibInst(target, prefix + '/' + path)
else:
installTargets += env.Install(target, prefix + '/' + path)
2011-08-15 07:30:06 +08:00
def installAs(target, path, prefix = None):
global installTargets
if prefix == None:
prefix = env['BUILDDIR']
if os.path.splitext(path)[1] == '.dylib':
2011-08-17 12:56:22 +08:00
result = env.OSXLibInstAs(target, prefix + '/' + path)
2011-08-15 07:30:06 +08:00
else:
2011-08-17 12:56:22 +08:00
result = env.InstallAs(target, prefix + '/' + path)
installTargets += result
return result
2011-08-15 07:30:06 +08:00
2011-07-18 20:20:02 +08:00
if not 'DISTDIR' in env:
print 'The \"DISTDIR\" variable is missing. Please update your configuration file!'
Exit(1)
distDir = env.GetBuildPath(env['DISTDIR'])
2011-08-23 03:01:20 +08:00
basePath = env.GetBuildPath('#')
2011-07-18 20:20:02 +08:00
for file in os.listdir(env.GetBuildPath('#data/schema')):
if fnmatch.fnmatch(file, '*.xsl') or fnmatch.fnmatch(file, '*.xsd'):
installTargets += env.Install(os.path.join(distDir, 'data/schema'), '#data/schema/' + file)
for file in os.listdir(env.GetBuildPath('#data/ior')):
if fnmatch.fnmatch(file, '*.spd'):
installTargets += env.Install(os.path.join(distDir, 'data/ior'), '#data/ior/' + file)
2011-09-17 13:46:19 +08:00
for file in os.listdir(env.GetBuildPath('#data/microfacet')):
if fnmatch.fnmatch(file, '*.dat'):
installTargets += env.Install(os.path.join(distDir, 'data/microfacet'), '#data/microfacet/' + file)
2011-07-18 20:20:02 +08:00
2011-06-01 08:20:53 +08:00
if sys.platform == 'linux2':
for plugin in plugins:
2011-07-18 20:20:02 +08:00
installTargets += env.Install(os.path.join(distDir, 'plugins'), plugin)
install(distDir, ['libcore/libmitsuba-core.so', 'libhw/libmitsuba-hw.so',
2011-07-01 17:35:49 +08:00
'librender/libmitsuba-render.so', 'libbidir/libmitsuba-bidir.so'])
2012-09-28 00:43:51 +08:00
for ver in hasPython:
installAs(os.path.join(distDir, 'python/'+ver+'/mitsuba.so'), 'libpython/mitsuba_python' + ver + '.so')
2011-11-18 03:41:54 +08:00
install(distDir, ['mitsuba/mitsuba', 'mitsuba/mtssrv', 'mitsuba/mtsutil'])
if hasQt:
install(distDir, ['mtsgui/mtsgui'])
2011-06-17 04:20:45 +08:00
if hasCollada:
2011-07-18 20:20:02 +08:00
install(distDir, ['converter/mtsimport'])
2011-02-03 16:15:25 +08:00
if sys.platform == 'win32':
for plugin in plugins:
if '.dll' in plugin.__str__():
2011-07-18 20:20:02 +08:00
installTargets += env.Install(os.path.join(distDir, 'plugins'), plugin)
2011-06-01 08:20:53 +08:00
2013-11-06 22:20:42 +08:00
compilerType = 'vc' + env['MSVC_VERSION'].replace('.', '')
archType = 'x64' if 'WIN64' in env['CXXFLAGS'] else 'i386'
dllprefix = '#dependencies/lib/%s_%s' % (archType, compilerType[:-1])
2011-06-01 08:20:53 +08:00
2011-06-17 04:20:45 +08:00
if hasCollada:
2011-07-18 20:20:02 +08:00
install(distDir, ['converter/mtsimport.exe'])
2011-08-23 01:09:28 +08:00
sdkDir = os.path.join(distDir, "sdk")
sdkLibDir = os.path.join(sdkDir, "lib")
2011-07-18 20:20:02 +08:00
install(distDir, ['mitsuba/mitsuba.exe', 'mitsuba/mtssrv.exe', 'mitsuba/mtsutil.exe'])
install(distDir, ['libcore/libmitsuba-core.dll', 'libhw/libmitsuba-hw.dll',
2011-07-01 17:35:49 +08:00
'librender/libmitsuba-render.dll', 'libbidir/libmitsuba-bidir.dll'])
2011-08-23 01:09:28 +08:00
install(sdkLibDir, ['libcore/mitsuba-core.lib', 'libhw/mitsuba-hw.lib',
2012-09-28 00:43:51 +08:00
'librender/mitsuba-render.lib', 'libbidir/mitsuba-bidir.lib'])
2011-08-23 01:09:28 +08:00
for entry in os.walk(os.path.join(basePath, "include")):
includeDir = entry[0][len(basePath)+1:]
installTargets += env.Install(os.path.join(sdkDir, includeDir),
[ ('#' + os.path.join(includeDir, fname)) for fname in entry[2] ])
2012-09-28 00:43:51 +08:00
for ver in hasPython:
installAs(os.path.join(distDir, 'python/'+ver+'/mitsuba.pyd'), 'libpython/mitsuba_python' + ver + '.dll')
2013-11-06 22:20:42 +08:00
install(distDir, ['Iex.dll', 'Half.dll','IlmThread.dll', 'Imath.dll','IlmImf.dll','zlib.dll',
'libpng16.dll', 'jpeg62.dll', 'xerces-c_3_1.dll', 'glew32mx.dll', 'libfftw-3.3.dll'],
2011-06-01 08:20:53 +08:00
prefix=dllprefix)
2013-11-06 22:20:42 +08:00
install(distDir, ['libcollada14dom24.dll',
2013-11-05 01:24:53 +08:00
'boost_python27-vc100-mt-1_53.dll', 'boost_python32-vc100-mt-1_53.dll',
'boost_python33-vc100-mt-1_53.dll', 'boost_system-vc100-mt-1_53.dll',
'boost_filesystem-vc100-mt-1_53.dll', 'boost_chrono-vc100-mt-1_53.dll',
'boost_thread-vc100-mt-1_53.dll'], dllprefix)
2012-09-28 00:43:51 +08:00
2011-06-05 22:48:31 +08:00
if 'WIN64' in env['CXXFLAGS']:
2012-09-28 00:43:51 +08:00
installTargets += env.Install(distDir, '#dependencies/bin/vcredist_2010_sp1_x64.exe')
2011-06-05 22:48:31 +08:00
else:
2012-09-28 00:43:51 +08:00
installTargets += env.Install(distDir, '#dependencies/bin/vcredist_2010_sp1_x86.exe')
2011-07-18 20:20:02 +08:00
installTargets += env.Install(distDir, '#data/windows/README.txt')
2011-06-01 08:20:53 +08:00
2011-06-02 05:03:27 +08:00
if 'REDIST_PATH' in env:
2012-10-11 02:42:46 +08:00
install(distDir, ['libmmd.dll', 'libiomp5md.dll', 'svml_dispmd.dll'], prefix = env['REDIST_PATH'])
2011-06-02 05:03:27 +08:00
2011-02-03 16:15:25 +08:00
if hasQt:
2011-08-08 09:01:40 +08:00
install(distDir, ['mtsgui/mtsgui.exe'])
2011-07-18 20:20:02 +08:00
install(distDir, ['QtCore4.dll', 'QtGui4.dll', 'QtXml4.dll',
2012-09-28 00:43:51 +08:00
'QtNetwork4.dll', 'QtOpenGL4.dll', 'QtXmlPatterns4.dll'], prefix = env['QT4_LIBPATH'])
2011-02-03 16:15:25 +08:00
elif sys.platform == 'darwin':
for i in plugins:
2011-08-15 07:30:06 +08:00
plugin = env.Install(os.path.join(distDir, 'plugins'), i)
2012-09-28 00:43:51 +08:00
installTargets += plugin
2011-08-23 03:01:20 +08:00
for entry in os.walk(os.path.join(basePath, "include")):
includeDir = entry[0][len(basePath)+1:]
installTargets += env.Install(os.path.join(os.path.join(distDir, 'Headers'), includeDir),
[ ('#' + os.path.join(includeDir, fname)) for fname in entry[2] ])
2011-07-18 20:20:02 +08:00
install(os.path.join(distDir, 'Contents/MacOS'), ['mitsuba/mitsuba', 'mitsuba/mtssrv', 'mitsuba/mtsutil'])
2011-06-17 04:20:45 +08:00
if hasCollada:
2011-07-18 20:20:02 +08:00
install(os.path.join(distDir, 'Contents/MacOS'), ['converter/mtsimport'])
plist = env.Install(os.path.join(distDir, 'Contents'), '#data/darwin/Info.plist')
2011-02-03 16:15:25 +08:00
installTargets += plist
installTargets += env.AddPostAction(plist, 'perl -pi -e "s/MTS_VERSION/%s/" $TARGET' % MTS_VERSION)
2011-07-18 20:20:02 +08:00
installTargets += env.Install(os.path.join(distDir, 'Contents'), '#data/darwin/PkgInfo')
installTargets += env.Install(os.path.join(distDir, 'Contents/Resources'), '#data/darwin/Resources/mitsuba.icns')
frameworkDir = os.path.join(distDir, 'Contents/Frameworks')
2011-06-01 08:20:53 +08:00
2011-07-18 20:20:02 +08:00
install(frameworkDir, ['libcore/libmitsuba-core.dylib', 'libhw/libmitsuba-hw.dylib',
2011-07-01 17:35:49 +08:00
'librender/libmitsuba-render.dylib', 'libbidir/libmitsuba-bidir.dylib'])
2012-09-28 00:43:51 +08:00
for ver in hasPython:
installTargets += installAs(os.path.join(distDir, 'python/'+ver+'/mitsuba.so'), 'libpython/mitsuba_python'+ver+'.dylib')
for entry in os.walk(os.path.join(basePath, "dependencies/lib")):
installTargets += env.Install(frameworkDir, ['#' + os.path.join('dependencies/lib', e) for e in entry[2] if not os.path.islink(os.path.join(entry[0], e))])
2011-02-03 16:15:25 +08:00
if hasQt:
2011-08-08 09:01:40 +08:00
install(os.path.join(distDir, 'Contents/MacOS'), ['mtsgui/mtsgui'])
2011-08-17 12:17:09 +08:00
install(os.path.join(distDir, 'Contents/MacOS'), ['mtsgui/symlinks_install'])
2012-09-28 00:43:51 +08:00
installTargets += env.OSXLibInst(frameworkDir, '$QTDIR/frameworks/QtCore.framework/Versions/4/QtCore')
opengl = env.OSXLibInst(frameworkDir, '$QTDIR/frameworks/QtOpenGL.framework/Versions/4/QtOpenGL')
xml = env.OSXLibInst(frameworkDir, '$QTDIR/frameworks/QtXml.framework/Versions/4/QtXml')
xmlpatterns = env.OSXLibInst(frameworkDir, '$QTDIR/frameworks/QtXmlPatterns.framework/Versions/4/QtXmlPatterns')
network = env.OSXLibInst(frameworkDir, '$QTDIR/frameworks/QtNetwork.framework/Versions/4/QtNetwork')
gui = env.OSXLibInst(frameworkDir, '$QTDIR/frameworks/QtGui.framework/Versions/4/QtGui')
installTargets += env.AddPostAction(xml, 'install_name_tool -change QtCore.framework/Versions/4/QtCore @rpath/QtCore $TARGET')
installTargets += env.AddPostAction(xmlpatterns, 'install_name_tool -change QtCore.framework/Versions/4/QtCore @rpath/QtCore $TARGET')
installTargets += env.AddPostAction(xmlpatterns, 'install_name_tool -change QtNetwork.framework/Versions/4/QtNetwork @rpath/QtNetwork $TARGET')
installTargets += env.AddPostAction(network, 'install_name_tool -change QtCore.framework/Versions/4/QtCore @rpath/QtCore $TARGET')
installTargets += env.AddPostAction(gui, 'install_name_tool -change QtCore.framework/Versions/4/QtCore @rpath/QtCore $TARGET')
installTargets += env.AddPostAction(opengl, 'install_name_tool -change QtCore.framework/Versions/4/QtCore @rpath/QtCore $TARGET')
installTargets += env.AddPostAction(opengl, 'install_name_tool -change QtGui.framework/Versions/4/QtGui @rpath/QtGui $TARGET')
installTargets += env.Install(os.path.join(distDir, 'Contents/Resources'), '$QTDIR/frameworks//QtGui.framework/Versions/4/Resources/qt_menu.nib')
installTargets += env.Install(os.path.join(distDir, 'Contents/Resources'), '#data/darwin/PreviewSettings.nib')
2011-07-18 20:20:02 +08:00
installTargets += env.Install(os.path.join(distDir, 'Contents/Resources'), '#data/darwin/qt.conf')
installTargets += env.Install(os.path.join(distDir, 'Contents/Frameworks/BWToolkitFramework.framework/Versions/A'),
2012-09-28 00:43:51 +08:00
'#dependencies/frameworks/BWToolkitFramework.framework/Versions/A/BWToolkitFramework')
for file in os.listdir(env.GetBuildPath('#dependencies/frameworks/BWToolkitFramework.framework/Versions/A/Resources')):
2011-02-03 16:15:25 +08:00
if fnmatch.fnmatch(file, '*.pdf') or fnmatch.fnmatch(file, '*.tiff') or fnmatch.fnmatch(file, '*.tif') or fnmatch.fnmatch(file, '*.png') or fnmatch.fnmatch(file, '*.rtf') or fnmatch.fnmatch(file, '*.plist'):
2012-09-28 00:43:51 +08:00
installTargets += env.Install(os.path.join(distDir, 'Contents/Frameworks/BWToolkitFramework.framework/Resources'), '#dependencies/frameworks/BWToolkitFramework.framework/Versions/A/Resources/' + file)
if hasBreakpad:
installTargets += env.Install(os.path.join(distDir, 'Contents/Frameworks'), '#dependencies/frameworks/Breakpad.framework')
2011-02-03 16:15:25 +08:00
if dist:
if sys.platform == 'win32':
2011-06-05 23:13:19 +08:00
bits = 64 if 'WIN64' in env['CXXFLAGS'] else 32
distCommand = env.GetBuildPath('#data/windows/build-dist.bat')
distTarget = env.Command("Mitsuba %s %ibit.zip" % (MTS_VERSION, bits), [], "%s %s %i" % (distCommand, MTS_VERSION, bits))
2011-02-03 16:15:25 +08:00
Depends(distTarget, installTargets)
elif sys.platform == 'darwin':
distTarget = env.Command("Mitsuba %s.dmg" % MTS_VERSION, [], "#data/darwin/build-dmg.sh %s" % MTS_VERSION)
Depends(distTarget, installTargets)
elif sys.platform == 'linux2':
env.Command("mitsuba-%s.tar.gz" % MTS_VERSION, [], "#data/linux/build-sourcedist.sh %s" % MTS_VERSION)