Added windows NSIS installer script to scons. Not pretty, but it works :)
authorSimon Clitherow <aphex@nildram.co.uk>
Thu, 15 Feb 2007 17:00:22 +0000 (17:00 +0000)
committerSimon Clitherow <aphex@nildram.co.uk>
Thu, 15 Feb 2007 17:00:22 +0000 (17:00 +0000)
To use:

Make sure NSIS is in your %PATH% and type 'scons nsis'

It doesn't currently compile blender first, so make sure you do a
normal 'scons' before this.

SConstruct
release/windows/installer/00.sconsblender.nsi
tools/btools.py

index 9027ce270c401472b175d6124d75aa953a844726..f1948198fba31470958b47922b50c8ba975e6830 100644 (file)
@@ -52,6 +52,7 @@ B = tools.Blender
 platform = sys.platform
 quickie = None
 quickdebug = None
+nsis_build = None
 
 ##### BEGIN SETUP #####
 
@@ -100,7 +101,7 @@ if quickie:
     B.quickie=string.split(quickie,',')
 else:
     B.quickie=[]
-
+    
 toolset = B.arguments.get('BF_TOOLSET', None)
 if toolset:
     print "Using " + toolset
@@ -271,6 +272,162 @@ B.root_build_dir = env['BF_BUILDDIR']
 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() + "\\"
+       
+       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
index 70c2a845c127eb416dd4d7139e7090c06129e0b7..4e604f40a6e51fbdcad7bfdc24f782a718ff2f30 100644 (file)
@@ -248,6 +248,8 @@ Section "Blender-VERSION (required)" SecCopyUI
   [SCRIPTCONTS]
   SetOutPath $BLENDERHOME\.blender\scripts\bpymodules
   [SCRIPTMODCONTS]
+  SetOutPath $BLENDERHOME\.blender\scripts\bpymodules\colladaImEx
+  [SCRIPTMODCOLLADACONT]
   SetOutPath $BLENDERHOME\.blender\scripts\bpydata
   [SCRIPTDATACONTS]
   SetOutPath $BLENDERHOME\.blender\scripts\bpydata\config
index ab74fdf4fe48cd9f9d6f4dfcab5d3db05a48ae03..0a3e67931370f0b290f0549651df992d37fe3409 100755 (executable)
@@ -73,7 +73,7 @@ def print_targets(targs, bc):
 def validate_targets(targs, bc):
     valid_list = ['.', 'blender', 'blenderstatic', 'blenderplayer', 'webplugin',
             'blendernogame', 'blenderstaticnogame', 'release',
-            'everything', 'clean', 'install-bin', 'install']
+            'everything', 'clean', 'install-bin', 'install', 'nsis']
     oklist = []
     for t in targs:
         if t in valid_list: