diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2007-05-31 15:15:47 +0400 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2007-05-31 15:15:47 +0400 |
commit | 8b2a129294a8b389072728d6384cd89c11208a9c (patch) | |
tree | cf8d4680d0c4eb041a6ab2611fd8d2db0503c66f | |
parent | 1badf04923cfbe0007a7497ee9085ca732d19d4e (diff) |
=== SCons ===
* Finally cleaned up the NSIS installer creation process
This is now a proper action and command, with simple printout
The 'nsis' target (only on Windows) now properly depends on
all the build process, and will be done as very last.
* Make LZMA (Solid) default compressor for installer (= the best)
-rw-r--r-- | SConstruct | 170 | ||||
-rw-r--r-- | release/windows/installer/00.sconsblender.nsi | 15 | ||||
-rwxr-xr-x | tools/btools.py | 186 |
3 files changed, 200 insertions, 171 deletions
diff --git a/SConstruct b/SConstruct index 8f1ab1d2529..7e9e0344c3a 100644 --- a/SConstruct +++ b/SConstruct @@ -234,170 +234,6 @@ env['BUILDDIR'] = B.root_build_dir if not B.root_build_dir[-1]==os.sep: B.root_build_dir += os.sep -def NSIS_Installer(): - - if env['OURPLATFORM'] != 'win32-vc' and env['OURPLATFORM'] != 'win32-mingw': - print "NSIS installer is only available on Windows." - Exit() - - install_base_dir = os.getcwd() + "\\" - - if not os.path.exists(install_base_dir+env['BF_INSTALLDIR']+'/plugins/include'): - os.mkdir(install_base_dir+env['BF_INSTALLDIR']+'/plugins/include') - - for f in glob.glob('source/blender/blenpluginapi/*.h'): - shutil.copy(f,install_base_dir+env['BF_INSTALLDIR']+'/plugins/include') - - shutil.copy('source/blender/blenpluginapi/plugin.def',install_base_dir+env['BF_INSTALLDIR']+'/plugins/include/') - - os.chdir("release") - v = open("VERSION") - version = v.read()[:-1] - shortver = version.split('.')[0] + version.split('.')[1] - v.close() - - #### change to suit install dir #### - inst_dir = install_base_dir + env['BF_INSTALLDIR'] - - os.chdir("windows/installer") - - ns = open("00.sconsblender.nsi","r") - - ns_cnt = str(ns.read()) - ns.close() - - # do root - rootlist = [] - rootdir = os.listdir(inst_dir+"\\") - for rootitem in rootdir: - if os.path.isdir(inst_dir+"\\"+ rootitem) == 0: - rootlist.append("File " + inst_dir + "\\" + rootitem) - rootstring = string.join(rootlist, "\n ") - rootstring += "\n\n" - ns_cnt = string.replace(ns_cnt, "[ROOTDIRCONTS]", rootstring) - - # do delete items - delrootlist = [] - for rootitem in rootdir: - if os.path.isdir(inst_dir + rootitem) == 0: - delrootlist.append("Delete $INSTDIR\\" + rootitem) - delrootstring = string.join(delrootlist, "\n ") - delrootstring += "\n" - ns_cnt = string.replace(ns_cnt, "[DELROOTDIRCONTS]", delrootstring) - - # do scripts - scriptlist = [] - scriptpath = "%s%s" % (inst_dir, "\\.blender\\scripts") - scriptdir = os.listdir(scriptpath) - for scriptitem in scriptdir: - scriptfile = "%s\\%s" % (scriptpath, scriptitem) - if os.path.isdir(scriptfile) == 0: - scriptlist.append("File %s" % scriptfile) - scriptstring = string.join(scriptlist, "\n ") - scriptstring += "\n\n" - ns_cnt = string.replace(ns_cnt, "[SCRIPTCONTS]", scriptstring) - - # do scripts\bpymodules - bpymodlist = [] - bpymodpath = "%s%s" % (inst_dir, "\\.blender\\scripts\\bpymodules") - bpymoddir = os.listdir(bpymodpath) - - for bpymoditem in bpymoddir: - bpymodfile = "%s\\%s" % (bpymodpath, bpymoditem) - if os.path.isdir(bpymodfile) == 0: - bpymodlist.append("File %s" % bpymodfile) - bpymodstring = string.join(bpymodlist, "\n ") - bpymodstring += "\n\n" - ns_cnt = string.replace(ns_cnt, "[SCRIPTMODCONTS]", bpymodstring) - - # do scripts\bpymodules\colladaimex - colladalist = [] - bpymodpath = "%s%s" % (inst_dir, "\\.blender\\scripts\\bpymodules\\ColladaImEx") - bpymoddir = os.listdir(bpymodpath) - - for bpymoditem in bpymoddir: - bpymodfile = "%s\\%s" % (bpymodpath, bpymoditem) - if os.path.isdir(bpymodfile) == 0: - colladalist.append("File %s" % bpymodfile) - bpymodstring = string.join(colladalist, "\n ") - bpymodstring += "\n\n" - ns_cnt = string.replace(ns_cnt, "[SCRIPTMODCOLLADACONT]", bpymodstring) - - # do scripts\bpydata - bpydatalist = [] - bpydatapath = "%s%s" % (inst_dir, "\\.blender\\scripts\\bpydata") - bpydatadir = os.listdir(bpydatapath) - for bpydataitem in bpydatadir: - bpydatafile = "%s\\%s" % (bpydatapath, bpydataitem) - if os.path.isdir(bpydatafile) == 0: - bpydatalist.append("File %s" % bpydatafile) - bpydatastring = string.join(bpydatalist, "\n ") - bpydatastring += "\n\n" - ns_cnt = string.replace(ns_cnt, "[SCRIPTDATACONTS]", bpydatastring) - - # do plugins\include - plugincludelist = [] - plugincludepath = "%s%s" % (inst_dir, "\\plugins\\include") - plugincludedir = os.listdir(plugincludepath) - for plugincludeitem in plugincludedir: - plugincludefile = "%s\\%s" % (plugincludepath, plugincludeitem) - if os.path.isdir(plugincludefile) == 0: - if plugincludefile.find('.h') or plugincludefile.find('.DEF'): - plugincludelist.append("File %s" % plugincludefile) - plugincludestring = string.join(plugincludelist, "\n ") - plugincludestring += "\n\n" - ns_cnt = string.replace(ns_cnt, "[PLUGINCONTS]", plugincludestring) - - # do scripts\bpydata\config - cfglist = [] - cfgpath = "%s%s" % (inst_dir, "\\.blender\\scripts\\bpydata\\config") - cfgdir = os.listdir(cfgpath) - for cfgitem in cfgdir: - cfgfile = "%s\\%s" % (cfgpath, cfgitem) - if os.path.isdir(cfgfile) == 0: - cfglist.append("File %s" % cfgfile) - cfgstring = string.join(cfglist, "\n ") - cfgstring += "\n\n" - ns_cnt = string.replace(ns_cnt, "[SCRIPTDATACFGCONTS]", cfgstring) - - # do dotblender - dotblendlist = [] - dotblenddir = os.listdir(inst_dir+"\\.blender") - for dotblenditem in dotblenddir: - if os.path.isdir(inst_dir + "\\.blender\\" + dotblenditem) == 0: - dotblendlist.append("File " + inst_dir + "\\.blender\\" + dotblenditem) - dotblendstring = string.join(dotblendlist, "\n ") - dotblendstring += "\n\n" - ns_cnt = string.replace(ns_cnt, "[DOTBLENDERCONTS]", dotblendstring) - - # do language files - langlist = [] - langfiles = [] - langdir = os.listdir(inst_dir + "\\.blender\\locale") - for langitem in langdir: - if os.path.isdir(inst_dir + "\\.blender\\locale\\" + langitem) == 1: - langfiles.append("SetOutPath $BLENDERHOME\\.blender\\locale\\" + langitem + "\\LC_MESSAGES") - langfiles.append("File " + inst_dir + "\\.blender\\locale\\" + langitem + "\\LC_MESSAGES\\blender.mo") - langstring = string.join(langfiles, "\n ") - langstring += "\n\n" - ns_cnt = string.replace(ns_cnt, "[LANGUAGECONTS]", langstring) - - # var replacements - ns_cnt = string.replace(ns_cnt, "DISTDIR", inst_dir+"\\") - ns_cnt = string.replace(ns_cnt, "SHORTVER", shortver) - ns_cnt = string.replace(ns_cnt, "VERSION", version) - - new_nsis = open("00.blender_tmp.nsi", 'w') - new_nsis.write(ns_cnt) - new_nsis.close() - - sys.stdout = os.popen("makensis 00.blender_tmp.nsi", 'w') - -nsis_build = None -if 'nsis' in B.targets: - NSIS_Installer() - Exit() - # We do a shortcut for clean when no quicklist is given: just delete # builddir without reading in SConscripts do_clean = None @@ -578,6 +414,10 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw'): installtarget = env.Alias('install', allinstall) bininstalltarget = env.Alias('install-bin', blenderinstall) +nsisaction = env.Action(btools.NSIS_Installer, btools.NSIS_print) +nsiscmd = env.Command('nsisinstaller', None, nsisaction) +nsisalias = env.Alias('nsis', nsiscmd) + if env['WITH_BF_PLAYER']: blenderplayer = env.Alias('blenderplayer', B.program_list) Depends(blenderplayer,installtarget) @@ -586,6 +426,8 @@ if not env['WITH_BF_GAMEENGINE']: blendernogame = env.Alias('blendernogame', B.program_list) Depends(blendernogame,installtarget) +Depends(nsiscmd, allinstall) + Default(B.program_list) Default(installtarget) diff --git a/release/windows/installer/00.sconsblender.nsi b/release/windows/installer/00.sconsblender.nsi index cd68312e69f..ff7a198d0b9 100644 --- a/release/windows/installer/00.sconsblender.nsi +++ b/release/windows/installer/00.sconsblender.nsi @@ -8,17 +8,19 @@ !include "FileFunc.nsh" !include "WordFunc.nsh" +SetCompressor /SOLID lzma + Name "Blender VERSION" !define MUI_ABORTWARNING !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Blender.\r\n\r\nIt is recommended that you close all other applications before starting Setup.\r\n\r\nNote to Win2k/XP users: You may require administrator privileges to install Blender successfully." -!define MUI_WELCOMEFINISHPAGE_BITMAP "01.installer.bmp" +!define MUI_WELCOMEFINISHPAGE_BITMAP "RELDIR\01.installer.bmp" !define MUI_HEADERIMAGE -!define MUI_HEADERIMAGE_BITMAP "00.header.bmp" +!define MUI_HEADERIMAGE_BITMAP "RELDIR\00.header.bmp" !define MUI_COMPONENTSPAGE_SMALLDESC !define MUI_FINISHPAGE_RUN "$INSTDIR\blender.exe" -!define MUI_CHECKBITMAP "00.checked.bmp" +!define MUI_CHECKBITMAP "RELDIR\00.checked.bmp" !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "DISTDIR\Copyright.txt" @@ -38,8 +40,8 @@ Page custom DataLocation !insertmacro VersionCompare -Icon "00.installer.ico" -UninstallIcon "00.installer.ico" +Icon "RELDIR\00.installer.ico" +UninstallIcon "RELDIR\00.installer.ico" ;-------------------------------- ;Languages @@ -60,7 +62,6 @@ UninstallIcon "00.installer.ico" Caption "Blender VERSION Installer" OutFile "DISTDIR\..\blender-VERSION-windows.exe" - InstallDir "$PROGRAMFILES\Blender Foundation\Blender" BrandingText "http://www.blender.org/bf" @@ -208,7 +209,7 @@ Function .onInit Call GetWindowsVersion Pop $R0 Strcpy $winversion $R0 - !insertmacro MUI_INSTALLOPTIONS_EXTRACT "data.ini" + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "RELDIR\data.ini" FunctionEnd !define DLL_VER "8.00.50727.42" diff --git a/tools/btools.py b/tools/btools.py index cf936a95e26..1dc35bb7248 100755 --- a/tools/btools.py +++ b/tools/btools.py @@ -4,6 +4,9 @@ import SCons.Options import SCons.Options.BoolOption import subprocess import string +import glob +import shutil +import sys Options = SCons.Options BoolOption = SCons.Options.BoolOption @@ -292,3 +295,186 @@ def read_opts(cfg, args): return localopts +def NSIS_print(target, source, env): + return "Creating NSIS installer for Blender 3D" + +def NSIS_Installer(target=None, source=None, env=None): + + if env['OURPLATFORM'] != 'win32-vc' and env['OURPLATFORM'] != 'win32-mingw': + print "NSIS installer is only available on Windows." + Exit() + + start_dir = os.getcwd() + rel_dir = start_dir + "\\release\\windows\\installer\\" + install_base_dir = start_dir + "\\" + + if not os.path.exists(install_base_dir+env['BF_INSTALLDIR']+'/plugins/include'): + os.mkdir(install_base_dir+env['BF_INSTALLDIR']+'/plugins/include') + + for f in glob.glob('source/blender/blenpluginapi/*.h'): + shutil.copy(f,install_base_dir+env['BF_INSTALLDIR']+'/plugins/include') + + shutil.copy('source/blender/blenpluginapi/plugin.def',install_base_dir+env['BF_INSTALLDIR']+'/plugins/include/') + + os.chdir("release") + v = open("VERSION") + version = v.read()[:-1] + shortver = version.split('.')[0] + version.split('.')[1] + v.close() + + #### change to suit install dir #### + inst_dir = install_base_dir + env['BF_INSTALLDIR'] + + os.chdir("windows/installer") + + ns = open("00.sconsblender.nsi","r") + + ns_cnt = str(ns.read()) + ns.close() + + # do root + rootlist = [] + rootdir = os.listdir(inst_dir+"\\") + for rootitem in rootdir: + if os.path.isdir(inst_dir+"\\"+ rootitem) == 0: + rootlist.append("File \"" + os.path.normpath(inst_dir) + "\\" + rootitem+"\"") + rootstring = string.join(rootlist, "\n ") + rootstring += "\n\n" + ns_cnt = string.replace(ns_cnt, "[ROOTDIRCONTS]", rootstring) + + # do delete items + delrootlist = [] + for rootitem in rootdir: + if os.path.isdir(inst_dir + rootitem) == 0: + delrootlist.append("Delete $INSTDIR\\" + rootitem) + delrootstring = string.join(delrootlist, "\n ") + delrootstring += "\n" + ns_cnt = string.replace(ns_cnt, "[DELROOTDIRCONTS]", delrootstring) + + # do scripts + scriptlist = [] + scriptpath = "%s%s" % (inst_dir, "\\.blender\\scripts") + scriptdir = os.listdir(scriptpath) + for scriptitem in scriptdir: + scriptfile = "%s\\%s" % (scriptpath, scriptitem) + if os.path.isdir(scriptfile) == 0: + scriptfile = os.path.normpath(scriptfile) + scriptlist.append("File \"%s\"" % scriptfile) + scriptstring = string.join(scriptlist, "\n ") + scriptstring += "\n\n" + ns_cnt = string.replace(ns_cnt, "[SCRIPTCONTS]", scriptstring) + + # do scripts\bpymodules + bpymodlist = [] + bpymodpath = "%s%s" % (inst_dir, "\\.blender\\scripts\\bpymodules") + bpymoddir = os.listdir(bpymodpath) + + for bpymoditem in bpymoddir: + bpymodfile = "%s\\%s" % (bpymodpath, bpymoditem) + if os.path.isdir(bpymodfile) == 0: + bpymodfile = os.path.normpath(bpymodfile) + bpymodlist.append("File \"%s\"" % bpymodfile) + bpymodstring = string.join(bpymodlist, "\n ") + bpymodstring += "\n\n" + ns_cnt = string.replace(ns_cnt, "[SCRIPTMODCONTS]", bpymodstring) + + # do scripts\bpymodules\colladaimex + colladalist = [] + bpymodpath = "%s%s" % (inst_dir, "\\.blender\\scripts\\bpymodules\\ColladaImEx") + bpymoddir = os.listdir(bpymodpath) + + for bpymoditem in bpymoddir: + bpymodfile = "%s\\%s" % (bpymodpath, bpymoditem) + if os.path.isdir(bpymodfile) == 0: + bpymodfile=os.path.normpath(bpymodfile) + colladalist.append("File \"%s\"" % bpymodfile) + bpymodstring = string.join(colladalist, "\n ") + bpymodstring += "\n\n" + ns_cnt = string.replace(ns_cnt, "[SCRIPTMODCOLLADACONT]", bpymodstring) + + # do scripts\bpydata + bpydatalist = [] + bpydatapath = "%s%s" % (inst_dir, "\\.blender\\scripts\\bpydata") + bpydatadir = os.listdir(bpydatapath) + for bpydataitem in bpydatadir: + bpydatafile = "%s\\%s" % (bpydatapath, bpydataitem) + if os.path.isdir(bpydatafile) == 0: + bpydatalist.append("File \"%s\"" % bpydatafile) + bpydatastring = string.join(bpydatalist, "\n ") + bpydatastring += "\n\n" + ns_cnt = string.replace(ns_cnt, "[SCRIPTDATACONTS]", bpydatastring) + + # do plugins\include + plugincludelist = [] + plugincludepath = "%s%s" % (inst_dir, "\\plugins\\include") + plugincludedir = os.listdir(plugincludepath) + for plugincludeitem in plugincludedir: + plugincludefile = "%s\\%s" % (plugincludepath, plugincludeitem) + if os.path.isdir(plugincludefile) == 0: + if plugincludefile.find('.h') or plugincludefile.find('.DEF'): + plugincludefile = os.path.normpath(plugincludefile) + plugincludelist.append("File \"%s\"" % plugincludefile) + plugincludestring = string.join(plugincludelist, "\n ") + plugincludestring += "\n\n" + ns_cnt = string.replace(ns_cnt, "[PLUGINCONTS]", plugincludestring) + + # do scripts\bpydata\config + cfglist = [] + cfgpath = "%s%s" % (inst_dir, "\\.blender\\scripts\\bpydata\\config") + cfgdir = os.listdir(cfgpath) + for cfgitem in cfgdir: + cfgfile = "%s\\%s" % (cfgpath, cfgitem) + if os.path.isdir(cfgfile) == 0: + cfglist.append("File \"%s\"" % cfgfile) + cfgstring = string.join(cfglist, "\n ") + cfgstring += "\n\n" + ns_cnt = string.replace(ns_cnt, "[SCRIPTDATACFGCONTS]", cfgstring) + + # do dotblender + dotblendlist = [] + dotblenddir = os.listdir(inst_dir+"\\.blender") + for dotblenditem in dotblenddir: + if os.path.isdir(inst_dir + "\\.blender\\" + dotblenditem) == 0: + dotblendlist.append("File \"" + os.path.normpath(inst_dir) + "\\.blender\\" + + dotblenditem+"\"") + dotblendstring = string.join(dotblendlist, "\n ") + dotblendstring += "\n\n" + ns_cnt = string.replace(ns_cnt, "[DOTBLENDERCONTS]", dotblendstring) + + # do language files + langlist = [] + langfiles = [] + langdir = os.listdir(inst_dir + "\\.blender\\locale") + for langitem in langdir: + if os.path.isdir(inst_dir + "\\.blender\\locale\\" + langitem) == 1: + langfiles.append("SetOutPath $BLENDERHOME\\.blender\\locale\\" + langitem + "\\LC_MESSAGES") + langfiles.append("File \"" + os.path.normpath(inst_dir) + "\\.blender\\locale\\" + + langitem + "\\LC_MESSAGES\\blender.mo\"") + langstring = string.join(langfiles, "\n ") + langstring += "\n\n" + ns_cnt = string.replace(ns_cnt, "[LANGUAGECONTS]", langstring) + + # var replacements + ns_cnt = string.replace(ns_cnt, "DISTDIR", os.path.normpath(inst_dir+"\\")) + ns_cnt = string.replace(ns_cnt, "SHORTVER", shortver) + ns_cnt = string.replace(ns_cnt, "VERSION", version) + ns_cnt = string.replace(ns_cnt, "RELDIR", os.path.normpath(rel_dir)) + + tmpnsi = os.path.normpath(install_base_dir+os.sep+env['BF_BUILDDIR']+os.sep+"00.blender_tmp.nsi") + new_nsis = open(tmpnsi, 'w') + new_nsis.write(ns_cnt) + new_nsis.close() + + os.chdir(start_dir) + + cmdline = "makensis " + "\""+tmpnsi+"\"" + + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, startupinfo=startupinfo, shell = True) + data, err = proc.communicate() + rv = proc.wait() + + return 0 + |