From e43ea677abc03ee6e76cd7429ef7fb983c0366a9 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sat, 25 Sep 2004 20:45:44 +0000 Subject: [PATCH] note to all: actually adding+commited new files does help a lot. :] --- tools/scons/bs/__init__.py | 1 + tools/scons/bs/bs_arc.py | 241 +++++++++++++++++++++++++++++++++++ tools/scons/bs/bs_bincopy.py | 45 +++++++ tools/scons/bs/bs_clean.py | 17 +++ tools/scons/bs/bs_config.py | 37 ++++++ tools/scons/bs/bs_default.py | 16 +++ tools/scons/bs/bs_dirs.py | 126 ++++++++++++++++++ tools/scons/bs/bs_globals.py | 16 +++ tools/scons/bs/bs_libs.py | 155 ++++++++++++++++++++++ tools/scons/bs/bs_nsis.py | 115 +++++++++++++++++ 10 files changed, 769 insertions(+) create mode 100644 tools/scons/bs/__init__.py create mode 100644 tools/scons/bs/bs_arc.py create mode 100644 tools/scons/bs/bs_bincopy.py create mode 100644 tools/scons/bs/bs_clean.py create mode 100644 tools/scons/bs/bs_config.py create mode 100644 tools/scons/bs/bs_default.py create mode 100644 tools/scons/bs/bs_dirs.py create mode 100644 tools/scons/bs/bs_globals.py create mode 100644 tools/scons/bs/bs_libs.py create mode 100644 tools/scons/bs/bs_nsis.py diff --git a/tools/scons/bs/__init__.py b/tools/scons/bs/__init__.py new file mode 100644 index 00000000000..063b2449f4b --- /dev/null +++ b/tools/scons/bs/__init__.py @@ -0,0 +1 @@ +__all__ = ['bs_default','bs_dirs','bs_globals','bs_libs','bs_nsis','bs_arc','bs_clean', 'bs_config', 'bs_bincopy'] \ No newline at end of file diff --git a/tools/scons/bs/bs_arc.py b/tools/scons/bs/bs_arc.py new file mode 100644 index 00000000000..43b191a473a --- /dev/null +++ b/tools/scons/bs/bs_arc.py @@ -0,0 +1,241 @@ +# archive targets ('scons release') +# and extra functions +# +# Mac OS: appit +# Unices: zipit -> .tar.gz +# Windows: zipit -> .zip +# + +import os +import sys +import string +import bs_dirs + +import bs_globals + +def add2arc(arc, file): + """ + Add file to arc. For win32 arc is a Zipfile, for unices it's a Tarfile + """ + if sys.platform == 'win32': + arc.write(file) + else: + arc.add(file) + +def appit(target, source, env): + if sys.platform == 'darwin': + import shutil + import commands + import os.path + + target = 'blender' + sourceinfo = "source/darwin/%s.app/Contents/Info.plist"%target + targetinfo = "%s.app/Contents/Info.plist"%target + + cmd = '%s.app'%target + if os.path.isdir(cmd): + shutil.rmtree('%s.app'%target) + shutil.copytree("source/darwin/%s.app"%target, '%s.app'%target) + cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo) + commands.getoutput(cmd) + cmd = 'cp %s %s.app/Contents/MacOS/%s'%(target, target, target) + commands.getoutput(cmd) + if user_options_dict['BUILD_BINARY'] == 'debug': + print "building debug" + else : + cmd = 'strip -u -r %s.app/Contents/MacOS/%s'%(target, target) + commands.getoutput(cmd) + cmd = '%s.app/Contents/Resources/'%target + shutil.copy('bin/.blender/.bfont.ttf', cmd) + shutil.copy('bin/.blender/.Blanguages', cmd) + cmd = 'cp -R bin/.blender/locale %s.app/Contents/Resources/'%target + commands.getoutput(cmd) + cmd = 'mkdir %s.app/Contents/MacOS/.blender'%target + commands.getoutput(cmd) + cmd = 'cp -R release/bpydata %s.app/Contents/MacOS/.blender'%target + commands.getoutput(cmd) + cmd = 'cp -R release/scripts %s.app/Contents/MacOS/.blender/'%target + commands.getoutput(cmd) + cmd = 'cp -R release/plugins %s.app/Contents/Resources/'%target + commands.getoutput(cmd) + cmd = 'chmod +x %s.app/Contents/MacOS/%s'%(target, target) + commands.getoutput(cmd) + cmd = 'find %s.app -name CVS -prune -exec rm -rf {} \;'%target + commands.getoutput(cmd) + cmd = 'find %s.app -name .DS_Store -exec rm -rf {} \;'%target + commands.getoutput(cmd) + + if user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + target = 'blenderplayer' + sourceinfo = "source/darwin/%s.app/Contents/Info.plist"%target + targetinfo = "%s.app/Contents/Info.plist"%target + + cmd = '%s.app'%target + if os.path.isdir(cmd): + shutil.rmtree('%s.app'%target) + shutil.copytree("source/darwin/%s.app"%target, '%s.app'%target) + cmd = "cat %s | sed s/VERSION/`cat release/VERSION`/ | sed s/DATE/`date +'%%Y-%%b-%%d'`/ > %s"%(sourceinfo,targetinfo) + commands.getoutput(cmd) + cmd = 'cp %s %s.app/Contents/MacOS/%s'%(target, target, target) + commands.getoutput(cmd) + if user_options_dict['BUILD_BINARY'] == 'debug': + print "building debug player" + else : + cmd = 'strip -u -r %s.app/Contents/MacOS/%s'%(target, target) + commands.getoutput(cmd) + cmd = '%s.app/Contents/Resources/'%target + shutil.copy('bin/.blender/.bfont.ttf', cmd) + shutil.copy('bin/.blender/.Blanguages', cmd) + cmd = 'cp -R bin/.blender/locale %s.app/Contents/Resources/'%target + commands.getoutput(cmd) + cmd = 'cp -R release/bpydata %s.app/Contents/MacOS/.blender'%target + commands.getoutput(cmd) + cmd = 'cp -R release/scripts %s.app/Contents/MacOS/.blender/'%target + commands.getoutput(cmd) + cmd = 'cp -R release/plugins %s.app/Contents/Resources/'%target + commands.getoutput(cmd) + cmd = 'chmod +x %s.app/Contents/MacOS/%s'%(target, target) + commands.getoutput(cmd) + cmd = 'find %s.app -name CVS -prune -exec rm -rf {} \;'%target + commands.getoutput(cmd) + cmd = 'find %s.app -name .DS_Store -exec rm -rf {} \;'%target + commands.getoutput(cmd) + + else: + print "This target is for the Os X platform only" + +def zipit(env, target, source): + try: + if sys.platform == 'win32': + import zipfile + else: + import tarfile + except: + if sys.platform == 'win32': + print "no zipfile module found" + else: + print "no tarfile module found" + print "make sure you use python 2.3" + print + return + + import shutil + import glob + import time + + startdir = os.getcwd() + pf="" + zipext = "" + zipname = "" + + today = time.strftime("%Y%m%d", time.gmtime()) # get time in the form 20040714 + + if bs_dirs.preparedist()==0: + print "check output for error" + return + + if sys.platform == 'win32': + zipext += ".zip" + pf = "windows" + elif sys.platform == 'linux2' or sys.platform == 'linux-i386': + zipext += ".tar.gz" + pf = "linux" + elif sys.platform == 'freebsd4': + zipext += ".tar.gz" + pf = "freebsd4" + elif sys.platform == 'freebsd5': + zipext += ".tar.gz" + pf = "freebsd5" + elif sys.platform == 'cygwin': + zipext += ".tar.gz" + pf = "cygwin" + + if bs_globals.user_options_dict['BUILD_BINARY'] == 'release': + blendname = "blender-" + bs_globals.version + "-" + bs_globals.config_guess + else: + blendname = "bf_blender_" + pf + "_" + today + + zipname = blendname + zipext + + if os.path.isdir(blendname): + shutil.rmtree(blendname) + shutil.move(startdir + os.sep + "dist", blendname) + + print + if sys.platform == 'win32': + print "Create the zip!" + else: + print "Create the tarball!" + print + + if sys.platform == 'win32': + thezip = zipfile.ZipFile(zipname, 'w', zipfile.ZIP_DEFLATED) + else: + thezip = tarfile.open(zipname, 'w:gz') + + for root, dirs, files in os.walk(blendname, topdown=False): + for name in files: + if name in [zipname]: + print "skipping self" + else: + file = root + "/" + name + print "adding: " + file + add2arc(thezip, file) + + thezip.close() + + os.chdir(startdir) + shutil.move(blendname, startdir + os.sep + "dist") + + if bs_dirs.finalisedist(zipname)==0: + print "encountered an error in finalisedist" + print + return + + print + print "Blender has been successfully packaged" + print "You can find the file %s in the root source directory"%zipname + print + +def printadd(env, target, source): + """ + Print warning message if platform hasn't been added to zipit() yet + """ + + print + print "############" + print + print "Make sure zipit() works for your platform:" + print " - binaries to copy (naming?)" + print " - possible libraries?" + print " - archive format?" + print + print "/Nathan Letwory (jesterKing)" + print + +def BlenderRelease(target): + """ + Make a Release package (tarball, zip, bundle). + + target = Name of package to make (string) + eg: BlenderRelease('blender') + """ + + if sys.platform == 'darwin': + app_env = bs_globals.init_env.Copy() + Mappit = app_env.Command('appit', bs_globals.appname, appit) + if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + app_env.Depends(Mappit, bs_globals.playername) + app_env.Alias("release", Mappit) + elif sys.platform in ['win32', 'linux2', 'linux-i386', 'freebsd4', 'freebsd5','cygwin']: + release_env = bs_globals.init_env.Copy() + releaseit = release_env.Command('blenderrelease', bs_globals.appname, zipit) + if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + release_env.Depends(releaseit, bs_globals.playername) + release_env.Alias("release", releaseit) + else: + release_env = init_env.Copy() + releaseit = release_env.Command('blender.tar.gz', bs_globals.appname, printadd) + if user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + release_env.Depends(releaseit, bs_globals.playername) + release_env.Alias("release", releaseit) \ No newline at end of file diff --git a/tools/scons/bs/bs_bincopy.py b/tools/scons/bs/bs_bincopy.py new file mode 100644 index 00000000000..117abc1ed9c --- /dev/null +++ b/tools/scons/bs/bs_bincopy.py @@ -0,0 +1,45 @@ +# bincopy target +import sys +import os +import shutil +import bs_globals + +def docopyit(env, target, source): + """ + Copy the blender binaries to a specified location + """ + if bs_globals.docopy==0 or bs_globals.copyto=='': + print "The bincopy target has been activated with corrupt data" + sys.exit() + + blender = 'blender' + blenderplayer = 'blenderplayer' + + # make sure bs_globals.copyto exists + if os.path.isdir(bs_globals.copyto) == 0: + os.makedirs(bs_globals.copyto) + + if sys.platform in ['win32', 'cygwin']: + blender = 'blender.exe' + blenderplayer = 'blenderplayer.exe' + + shutil.copy(blender, bs_globals.copyto + os.sep + blender) + if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + shutil.copy(blenderplayer, bs_globals.copyto + os.sep + blenderplayer) + +def BlenderCopy(target): + #~ if sys.platform == 'darwin': + #~ copy_env = bs_globals.init_env.Copy() + #~ Mappit = app_env.Command('appit', bs_globals.appname, appit) + #~ if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + #~ app_env.Depends(Mappit, bs_globals.playername) + #~ app_env.Alias("release", Mappit) + if sys.platform in ['win32', 'linux2', 'linux-i386', 'freebsd4', 'freebsd5','cygwin']: + copy_env = bs_globals.init_env.Copy() + copyit = copy_env.Command('blendercopy', bs_globals.appname, docopyit) + if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + copy_env.Depends(copyit, bs_globals.playername) + copy_env.Alias("bincopy", copyit) + else: + print "Check the scons implementation for bincopy, copydo if everything is setup correctly for your platform" + diff --git a/tools/scons/bs/bs_clean.py b/tools/scons/bs/bs_clean.py new file mode 100644 index 00000000000..e3d8c9929c2 --- /dev/null +++ b/tools/scons/bs/bs_clean.py @@ -0,0 +1,17 @@ +# the clean target + +import os +import shutil + +def DoClean(dir2clean): + """ + Do a removal of the root_build_dir the fast way + """ + + print "start the clean" + dirs = os.listdir(dir2clean) + for dir in dirs: + if os.path.isdir(dir2clean + "/" + dir) == 1: + print "clean dir %s"%(dir2clean+"/" + dir) + shutil.rmtree(dir2clean+"/" + dir) + print "done" \ No newline at end of file diff --git a/tools/scons/bs/bs_config.py b/tools/scons/bs/bs_config.py new file mode 100644 index 00000000000..7413ee9ab7b --- /dev/null +++ b/tools/scons/bs/bs_config.py @@ -0,0 +1,37 @@ +# configuration functions +import sys +import os + +import SCons.Script +import bs_globals + +def checkPyVersion(): + if hex(sys.hexversion) < 0x2030000: + print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + print + print "You need at least Python 2.3 to build Blender with SCons" + print + print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + sys.exit() + +def parseOpts(): + copyloc = '' + + all_args = sys.argv[1:] + parser = SCons.Script.OptParser() + options, targets = parser.parse_args(all_args) + if ('clean' in targets): + bs_globals.enable_clean = 1 + + # User configurable options file. This can be controlled by the user by running + # scons with the following argument: CONFIG=user_config_options_file + bs_globals.config_file = bs_globals.arguments.get('CONFIG', 'config.opts') + bs_globals.root_build_dir = bs_globals.arguments.get('root_build_dir', '..' + os.sep + 'build' + os.sep + sys.platform + os.sep) + + copyloc = bs_globals.arguments.get('copyto', '0') + if copyloc == '0': + bs_globals.docopy = 0; + else: + bs_globals.docopy = 1; + bs_globals.copyto = copyloc + \ No newline at end of file diff --git a/tools/scons/bs/bs_default.py b/tools/scons/bs/bs_default.py new file mode 100644 index 00000000000..df806415ef1 --- /dev/null +++ b/tools/scons/bs/bs_default.py @@ -0,0 +1,16 @@ +# Default target + +import bs_globals + +def noaction(env, target, source): + print "Empty action" + +def BlenderDefault(target): + """ + The default Blender build. + """ + def_env = bs_globals.init_env.Copy() + default = def_env.Command('nozip', 'blender$PROGSUFFIX', noaction) + if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + def_env.Depends(default, 'blenderplayer$PROGSUFFIX') + def_env.Alias(".", default) \ No newline at end of file diff --git a/tools/scons/bs/bs_dirs.py b/tools/scons/bs/bs_dirs.py new file mode 100644 index 00000000000..4d1482b436e --- /dev/null +++ b/tools/scons/bs/bs_dirs.py @@ -0,0 +1,126 @@ +# functions used for dir handling / preperation / cleaning + +import os +import string +import sys +import bs_globals + +def cleanCVS(): + """ + walks the dist dir and removes all CVS dirs + """ + + try: + import shutil + except: + print "no shutil available" + print "make sure you use python 2.3" + print + return 0 + + startdir = os.getcwd() + + for root, dirs, files in os.walk("dist", topdown=False): + for name in dirs: + if name in ['CVS']: + if os.path.isdir(root + "/" + name): + shutil.rmtree(root + "/" + name) + + os.chdir(startdir) + + return 1 + +def preparedist(): + """ + Prepare a directory for creating either archives or the installer + """ + + try: + import shutil + import time + import stat + except: + print "no shutil available" + print "make sure you use python 2.3" + print + return 0 + + startdir = os.getcwd() + + if os.path.isdir("dist") == 0: + os.makedirs("dist") + else: + shutil.rmtree("dist") # make sure we don't get old cruft + os.makedirs("dist") + + # first copy binaries + + if sys.platform == 'win32': + shutil.copy("blender.exe", "dist/blender.exe") + if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + shutil.copy("blenderplayer.exe", "dist/blenderplayer.exe") + shutil.copy("../lib/windows/python/lib/python23.dll", "dist/python23.dll") + shutil.copy("../lib/windows/sdl/lib/SDL.dll", "dist/SDL.dll") + shutil.copy("../lib/windows/gettext/lib/gnu_gettext.dll", "dist/gnu_gettext.dll") + elif sys.platform in ['linux2', 'linux-i386', 'freebsd4', 'freebsd5']: + shutil.copy("blender", "dist/blender") + if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + shutil.copy("blenderplayer", "dist/blenderplayer") + else: + print "update preparedist() for your platform!" + return 0 + + # now copy .blender and necessary extras for it + if os.path.isdir("dist/.blender"): + shutil.rmtree("dist/.blender") + os.chdir("bin") + shutil.copytree(".blender/", "../dist/.blender") + os.chdir(startdir) + if os.path.isdir("dist/.blender/scripts"): + shutil.rmtree("dist/.blender/scripts") + if os.path.isdir("dist/.blender/bpydata"): + shutil.rmtree("dist/.blender/bpydata") + + os.makedirs("dist/.blender/bpydata") + shutil.copy("release/bpydata/readme.txt", "dist/.blender/bpydata/readme.txt") + shutil.copy("release/bpydata/KUlang.txt", "dist/.blender/bpydata/KUlang.txt") + + os.chdir("release") + shutil.copytree("scripts/", "../dist/.blender/scripts") + + # finally copy auxiliaries (readme, license, etc.) + if sys.platform == 'win32': + shutil.copy("windows/extra/Help.url", "../dist/Help.url") + shutil.copy("windows/extra/Python23.zip", "../dist/Python23.zip") + shutil.copy("windows/extra/zlib.pyd", "../dist/zlib.pyd") + shutil.copy("text/copyright.txt", "../dist/copyright.txt") + shutil.copy("text/blender.html", "../dist/blender.html") + shutil.copy("text/GPL-license.txt", "../dist/GPL-license.txt") + shutil.copy("text/Python-license.txt", "../dist/Python-license.txt") + + reltext = "release_" + string.join(bs_globals.version.split("."), '') + ".txt" + shutil.copy("text/" + reltext, "../dist/" + reltext) + + os.chdir(startdir) + + if cleanCVS()==0: + return 0 + return 1 + +def finalisedist(zipname): + """ + Fetch the package created and remove temp dir + """ + + try: + import shutil + except: + print "no shutil available" + print "make sure you use python 2.3" + print + return 0 + + #shutil.copy("dist/" + zipname, zipname) + #shutil.rmtree("dist") + + return 1 \ No newline at end of file diff --git a/tools/scons/bs/bs_globals.py b/tools/scons/bs/bs_globals.py new file mode 100644 index 00000000000..abe03d45649 --- /dev/null +++ b/tools/scons/bs/bs_globals.py @@ -0,0 +1,16 @@ +# Global variables for the Blender build process + +arguments = [] +enable_clean = 0 +config_file = '' +root_build_dir = '' +user_options_dict = [] +init_env = [] +version = '' +shortversion = '' +appname = '' +playername = '' +config_guess = '' + +docopy = 0 +copyto = '' \ No newline at end of file diff --git a/tools/scons/bs/bs_libs.py b/tools/scons/bs/bs_libs.py new file mode 100644 index 00000000000..c874b7c5c5c --- /dev/null +++ b/tools/scons/bs/bs_libs.py @@ -0,0 +1,155 @@ +# Blender library functions + +import sys +import os +import string +import SCons + +import bs_globals + +def common_libs(env): + """ + Append to env all libraries that are common to Blender and Blenderplayer + """ + env.Append (LIBS=[ + 'blender_blenloader', + 'blender_readblenfile', + 'blender_img', + 'blender_blenkernel', + 'blender_blenpluginapi', + 'blender_imbuf', + 'blender_avi', + 'blender_blenlib', + 'blender_makesdna', + 'blender_kernel', + 'blender_GHOST', + 'blender_STR', + 'blender_guardedalloc', + 'blender_CTR', + 'blender_MEM', + 'blender_MT', + 'blender_BMF', + 'soundsystem']) + if bs_globals.user_options_dict['USE_QUICKTIME'] == 1: + env.Append (LIBS=['blender_quicktime']) + +def international_libs(env): + """ + Append international font support libraries + """ + if bs_globals.user_options_dict['USE_INTERNATIONAL'] == 1: + env.Append (LIBS=bs_globals.user_options_dict['FREETYPE_LIBRARY']) + env.Append (LIBPATH=bs_globals.user_options_dict['FREETYPE_LIBPATH']) + env.Append (LIBS=['blender_FTF']) + env.Append (LIBS=bs_globals.user_options_dict['FTGL_LIBRARY']) + env.Append (LIBPATH=bs_globals.user_options_dict['FTGL_LIBPATH']) + env.Append (LIBS=bs_globals.user_options_dict['FREETYPE_LIBRARY']) + +def blender_libs(env): + """ + Blender only libs (not in player) + """ + env.Append( LIBS=['blender_creator', + 'blender_blendersrc', + 'blender_render', + 'blender_yafray', + 'blender_renderconverter', + 'blender_radiosity', + 'blender_LOD', + 'blender_BSP', + 'blender_blenkernel', + 'blender_IK', + 'blender_ONL']) + +def ketsji_libs(env): + """ + Game Engine libs + """ + if bs_globals.user_options_dict['BUILD_GAMEENGINE'] == 1: + env.Append (LIBS=['KX_blenderhook', + 'KX_converter', + 'PHY_Dummy', + 'PHY_Physics', + 'KX_ketsji', + 'SCA_GameLogic', + 'RAS_rasterizer', + 'RAS_OpenGLRasterizer', + 'blender_expressions', + 'SG_SceneGraph', + 'blender_MT', + 'KX_blenderhook', + 'KX_network', + 'blender_kernel', + 'NG_network', + 'NG_loopbacknetwork']) + if bs_globals.user_options_dict['USE_PHYSICS'] == 'solid': + env.Append (LIBS=['PHY_Sumo', 'PHY_Physics', 'blender_MT', 'extern_solid', 'extern_qhull']) + else: + env.Append (LIBS=['PHY_Ode', + 'PHY_Physics']) + env.Append (LIBS=bs_globals.user_options_dict['ODE_LIBRARY']) + env.Append (LIBPATH=bs_globals.user_options_dict['ODE_LIBPATH']) + +def player_libs(env): + """ + Player libraries + """ + env.Append (LIBS=['GPG_ghost', + 'GPC_common']) + +def player_libs2(env): + """ + Link order shenannigans: these libs are added after common_libs + """ + env.Append (LIBS=['blender_blenkernel_blc', + 'soundsystem']) + +def winblenderres(env): + """ + build the windows icon resource file + """ + if sys.platform == 'win32': + env.RES(['source/icons/winblender.rc']) + +def system_libs(env): + """ + System libraries: Python, SDL, PNG, JPEG, Gettext, OpenAL, Carbon + """ + env.Append (LIBS=['blender_python']) + env.Append (LIBS=bs_globals.user_options_dict['PYTHON_LIBRARY']) + env.Append (LIBPATH=bs_globals.user_options_dict['PYTHON_LIBPATH']) + env.Append (LINKFLAGS=bs_globals.user_options_dict['PYTHON_LINKFLAGS']) + env.Append (LIBS=bs_globals.user_options_dict['SDL_LIBRARY']) + env.Append (LIBPATH=bs_globals.user_options_dict['SDL_LIBPATH']) + env.Append (LIBS=bs_globals.user_options_dict['PNG_LIBRARY']) + env.Append (LIBPATH=bs_globals.user_options_dict['PNG_LIBPATH']) + env.Append (LIBS=bs_globals.user_options_dict['JPEG_LIBRARY']) + env.Append (LIBPATH=bs_globals.user_options_dict['JPEG_LIBPATH']) + env.Append (LIBS=bs_globals.user_options_dict['GETTEXT_LIBRARY']) + env.Append (LIBPATH=bs_globals.user_options_dict['GETTEXT_LIBPATH']) + env.Append (LIBS=bs_globals.user_options_dict['Z_LIBRARY']) + env.Append (LIBPATH=bs_globals.user_options_dict['Z_LIBPATH']) + if bs_globals.user_options_dict['USE_OPENAL'] == 1: + env.Append (LIBS=bs_globals.user_options_dict['OPENAL_LIBRARY']) + env.Append (LIBPATH=bs_globals.user_options_dict['OPENAL_LIBPATH']) + env.Append (LIBS=bs_globals.user_options_dict['PLATFORM_LIBS']) + env.Append (LIBPATH=bs_globals.user_options_dict['PLATFORM_LIBPATH']) + if sys.platform == 'darwin': + env.Append (LINKFLAGS='-framework') + env.Append (LINKFLAGS='Carbon') + env.Append (LINKFLAGS='-framework') + env.Append (LINKFLAGS='AGL') + env.Append (LINKFLAGS='-framework') + env.Append (LINKFLAGS='AudioUnit') + env.Append (LINKFLAGS='-framework') + env.Append (LINKFLAGS='AudioToolbox') + env.Append (LINKFLAGS='-framework') + env.Append (LINKFLAGS='CoreAudio') + if bs_globals.user_options_dict['USE_QUICKTIME'] == 1: + env.Append (LINKFLAGS='-framework') + env.Append (LINKFLAGS='QuickTime') + else: + env.Append (LINKFLAGS=bs_globals.user_options_dict['PLATFORM_LINKFLAGS']) + env.BuildDir (bs_globals.root_build_dir, '.', duplicate=0) + + diff --git a/tools/scons/bs/bs_nsis.py b/tools/scons/bs/bs_nsis.py new file mode 100644 index 00000000000..df6dcdb1c08 --- /dev/null +++ b/tools/scons/bs/bs_nsis.py @@ -0,0 +1,115 @@ +# nsis target +# +# this file has the NSIS related functions + +import os +import string +import sys + +import bs_dirs +import bs_globals + +def donsis(env, target, source): + """ + Create a Windows installer with NSIS + """ + print + print "Creating the Windows installer" + print + + startdir = os.getcwd() + + if bs_dirs.preparedist()==0: + print "check output for error" + return + + os.chdir("release/windows/installer") + + nsis = open("00.sconsblender.nsi", 'r') + nsis_cnt = str(nsis.read()) + nsis.close() + + # do root + rootlist = [] + rootdir = os.listdir(startdir + "\\dist") + for rootitem in rootdir: + if os.path.isdir(startdir + "\\dist\\" + rootitem) == 0: + rootlist.append("File " + startdir + "\\dist\\" + rootitem) + rootstring = string.join(rootlist, "\n ") + rootstring += "\n\n" + nsis_cnt = string.replace(nsis_cnt, "[ROOTDIRCONTS]", rootstring) + + # do delete items + delrootlist = [] + for rootitem in rootdir: + if os.path.isdir(startdir + "\\dist\\" + rootitem) == 0: + delrootlist.append("Delete $INSTDIR\\" + rootitem) + delrootstring = string.join(delrootlist, "\n ") + delrootstring += "\n" + nsis_cnt = string.replace(nsis_cnt, "[DELROOTDIRCONTS]", delrootstring) + + # do scripts + scriptlist = [] + scriptdir = os.listdir(startdir + "\\dist\\.blender\\scripts") + for scriptitem in scriptdir: + if os.path.isdir(startdir + "\\dist\\.blender\\scripts\\" + scriptitem) == 0: + scriptlist.append("File " + startdir + "\\dist\\.blender\\scripts\\" + scriptitem) + scriptstring = string.join(scriptlist, "\n ") + scriptstring += "\n\n" + nsis_cnt = string.replace(nsis_cnt, "[SCRIPTCONTS]", scriptstring) + + # do bpycontents + bpydatalist = [] + bpydatadir = os.listdir(startdir + "\\dist\\.blender\\bpydata") + for bpydataitem in bpydatadir: + if os.path.isdir(startdir + "\\dist\\.blender\\bpydata\\" + bpydataitem) == 0: + bpydatalist.append("File " + startdir + "\\dist\\.blender\\bpydata\\" + bpydataitem) + bpydatastring = string.join(bpydatalist, "\n ") + bpydatastring += "\n\n" + nsis_cnt = string.replace(nsis_cnt, "[BPYCONTS]", bpydatastring) + + # do dotblender + dotblendlist = [] + dotblenddir = os.listdir(startdir+"\\dist\\.blender") + for dotblenditem in dotblenddir: + if os.path.isdir(startdir + "\\dist\\.blender\\" + dotblenditem) == 0: + dotblendlist.append("File " + startdir + "\\dist\\.blender\\" + dotblenditem) + dotblendstring = string.join(dotblendlist, "\n ") + dotblendstring += "\n\n" + nsis_cnt = string.replace(nsis_cnt, "[DOTBLENDERCONTS]", dotblendstring) + + # do language files + langlist = [] + langfiles = [] + langdir = os.listdir(startdir + "\\dist\\.blender\\locale") + for langitem in langdir: + if os.path.isdir(startdir + "\\dist\\.blender\\locale\\" + langitem) == 1: + langfiles.append("SetOutPath $BLENDERHOME\\.blender\\locale\\" + langitem + "\\LC_MESSAGES") + langfiles.append("File " + startdir + "\\dist\\.blender\\locale\\" + langitem + "\\LC_MESSAGES\\blender.mo") + langstring = string.join(langfiles, "\n ") + langstring += "\n\n" + nsis_cnt = string.replace(nsis_cnt, "[LANGUAGECONTS]", langstring) + + # var replacements + nsis_cnt = string.replace(nsis_cnt, "DISTDIR", startdir + "\\dist") + nsis_cnt = string.replace(nsis_cnt, "SHORTVER", bs_globals.shortversion) + nsis_cnt = string.replace(nsis_cnt, "VERSION", bs_globals.version) + + new_nsis = open("00.blender_tmp.nsi", 'w') + new_nsis.write(nsis_cnt) + new_nsis.close() + + sys.stdout = os.popen("makensis 00.blender_tmp.nsi", 'w') + + os.chdir(startdir) + +def BlenderNSIS(target): + """ + Entry for creating Windows installer + """ + if sys.platform == 'win32': + inst_env = bs_globals.init_env.Copy() + nsis_inst = inst_env.Command('nsisinstaller', 'blender$PROGSUFFIX', donsis) + if bs_globals.user_options_dict['BUILD_BLENDER_PLAYER'] == 1: + inst_env.Depends(nsis_inst, 'blenderplayer$PROGSUFFIX') + inst_env.Alias("wininst", nsis_inst) \ No newline at end of file