From 43e057949d62626cff746f6a7e98307fb5062e04 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 14 Sep 2015 02:15:40 -0400 Subject: [PATCH] scons: Generate Windows installer Also: - scons: Fix copying wrong scenario graphics on Windows - MSVC: Fix output filenames for release builds --- .gitignore | 2 +- SConstruct | 19 +- pkg/mac/SConscript | 0 pkg/win/SConscript | 26 +++ .../Installer => pkg/win}/fileassoc.nsh | 0 .../Installer => pkg/win}/gen-data.py | 9 +- .../BoE.vsproj/Installer => pkg/win}/main.nsi | 165 +++++++++--------- rsrc/SConscript | 7 +- .../Installer/Installer.vcxproj.filters | 6 +- src/BoE.vsproj/Installer/Makefile.mak | 14 +- src/BoE.vsproj/PcEdit/Char Editor.vcxproj | 3 +- src/BoE.vsproj/ScenEdit/Scen Editor.vcxproj | 3 +- 12 files changed, 157 insertions(+), 97 deletions(-) create mode 100644 pkg/mac/SConscript create mode 100644 pkg/win/SConscript rename {src/BoE.vsproj/Installer => pkg/win}/fileassoc.nsh (100%) rename {src/BoE.vsproj/Installer => pkg/win}/gen-data.py (79%) rename {src/BoE.vsproj/Installer => pkg/win}/main.nsi (67%) diff --git a/.gitignore b/.gitignore index b8194513..949f7cad 100644 --- a/.gitignore +++ b/.gitignore @@ -57,7 +57,7 @@ build/ deps/ # Generated NSIS script file -src/*.vsproj/Installer/data.nsi +pkg/win/data.nsi # Shader Builder projects # It's an sqlite3 database and not particularly important, so exclude it diff --git a/SConstruct b/SConstruct index 4e257a77..e0d8e234 100644 --- a/SConstruct +++ b/SConstruct @@ -14,7 +14,7 @@ if str(platform) not in ("darwin", "win32"): print 'Building for:', platform -env = Environment(TARGET_ARCH='x86') +env = Environment(TARGET_ARCH='x86',ENV=os.environ) env.VariantDir('#build/obj', 'src') env.VariantDir('#build/obj/test', 'test') @@ -331,4 +331,21 @@ elif str(platform) == "win32": for targ in target_dirs: env.Install(targ, src_file) break + # Extra: Microsoft redistributable libraries installer + if 'msvc' in env["TOOLS"]: + if path.exists("dep/VCRedistInstall.exe"): + env.Install("build/Blades of Exile/", "dep/VCRedistInstall.exe") + else: + print "WARNING: Cannot find installer for the MSVC redistributable libraries for your version of Visual Studio." + print "Please download it from Microsoft's website and place it at:" + print " dep/VCRedistInstall.exe" + # Create it so its lack doesn't cause makensis to break + # (Because the installer is an optional component.) + open("build/Blades of Exile/VCRedistInstall.exe", 'w').close() +if str(platform) == "darwin": + # TODO: Build a disk image package + env.VariantDir("#build/pkg", "pkg/mac") +elif str(platform) == "win32" and subprocess.call(['where', '/Q', 'makensis']) == 0: + env.VariantDir("#build/pkg", "pkg/win") +SConscript("build/pkg/SConscript") diff --git a/pkg/mac/SConscript b/pkg/mac/SConscript new file mode 100644 index 00000000..e69de29b diff --git a/pkg/win/SConscript b/pkg/win/SConscript new file mode 100644 index 00000000..79e6b072 --- /dev/null +++ b/pkg/win/SConscript @@ -0,0 +1,26 @@ + +import os.path as path + +Import("env platform") + +if str(platform) != "win32": + print "Error: Building for", str(platform), "but trying to create a Windows installer package" + +env.Depends("data.nsi", ["gen-data.py", "#build/Blades of Exile/data"]) + +env.Command("data.nsi", "../Blades of Exile", + action = 'python build/pkg/gen-data.py ${SOURCE.abspath} > $TARGET' +) + +env.Depends("Install-OBoE.exe", [ + "#build/Blades of Exile", + "data.nsi", + "fileassoc.nsh" +]) + +if 'msvc' in env["TOOLS"]: + makensis = "makensis /DMSVC" +else: + makensis = "makensis" + +env.Command("Install-OBoE.exe", "main.nsi", action = makensis + " /V2 $SOURCE") diff --git a/src/BoE.vsproj/Installer/fileassoc.nsh b/pkg/win/fileassoc.nsh similarity index 100% rename from src/BoE.vsproj/Installer/fileassoc.nsh rename to pkg/win/fileassoc.nsh diff --git a/src/BoE.vsproj/Installer/gen-data.py b/pkg/win/gen-data.py similarity index 79% rename from src/BoE.vsproj/Installer/gen-data.py rename to pkg/win/gen-data.py index 9abe122e..0f1bfa35 100644 --- a/src/BoE.vsproj/Installer/gen-data.py +++ b/pkg/win/gen-data.py @@ -1,8 +1,9 @@ -from os.path import relpath as makepath +from os.path import normpath as makepath from glob import glob +import sys -root = makepath("../Release") +root = makepath(sys.argv[1]) # To add directories to the list of sources to generate file lists from, # simply edit this dictionary. The key is the directory path (relative to @@ -27,7 +28,7 @@ for path, pattern in files.items(): if type(pattern) == list: check_files = [root + '/' + path + '/' + x for x in pattern] else: - check_files = glob(root + '/' + path + '/' + pattern) + check_files = glob(makepath(root + '/' + path + '/' + pattern)) for fname in check_files: - print 'File', '"' + makepath(fname) + '"' + print 'File', '"' + makepath(fname.replace(root, '${RELEASE_DIR}')) + '"' diff --git a/src/BoE.vsproj/Installer/main.nsi b/pkg/win/main.nsi similarity index 67% rename from src/BoE.vsproj/Installer/main.nsi rename to pkg/win/main.nsi index 33eae984..b157176f 100644 --- a/src/BoE.vsproj/Installer/main.nsi +++ b/pkg/win/main.nsi @@ -4,11 +4,18 @@ !define APPNAME "Blades of Exile" !define APPNAMEANDVERSION "Blades of Exile 1.0 beta" +; This specifies the build output dir to copy files from +; It uses /ifndef so it can be overridden from the commandline +; The default is the scons output directory +!ifndef RELEASE_DIR + !define RELEASE_DIR "..\..\build\Blades of Exile" +!endif + ; Main Install settings Name "${APPNAMEANDVERSION}" InstallDir "$PROGRAMFILES\Blades of Exile" InstallDirRegKey HKLM "Software\${APPNAME}" "" -OutFile "Release\Install-OBoE.exe" +OutFile "Install-OBoE.exe" ; File association helpers !include "fileassoc.nsh" @@ -24,7 +31,7 @@ OutFile "Release\Install-OBoE.exe" !define MUI_LICENSEPAGE_BUTTON "&Install" !insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "..\..\..\LICENSE.txt" +!insertmacro MUI_PAGE_LICENSE "..\..\LICENSE.txt" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES @@ -46,30 +53,32 @@ Section "Blades of Exile" Section1 ; Set Section Files and Shortcuts SetOutPath "$INSTDIR\" ; Install Visual Studio Redistributables - File "..\Release\VCRedistInstall.exe" - MessageBox MB_OK "Blades of Exile Installer will now launch the Microsoft Visual C++ \ - Redistributable installer, which is required to complete the installation." - ExecWait '$INSTDIR\VCRedistInstall.exe /passive' - Delete "$INSTDIR\VCRedistInstall.exe" + !ifdef MSVC + File "${RELEASE_DIR}\VCRedistInstall.exe" + MessageBox MB_OK "Blades of Exile Installer will now launch the Microsoft Visual C++ \ + Redistributable installer, which is required to complete the installation." + ExecWait '$INSTDIR\VCRedistInstall.exe /passive' + Delete "$INSTDIR\VCRedistInstall.exe" + !endif ; The executable file itself - File "..\Release\Blades of Exile.exe" + File "${RELEASE_DIR}\Blades of Exile.exe" ; Required DLLs - File "..\Release\libsndfile-1.dll" - File "..\Release\openal32.dll" - File "..\Release\sfml-audio-2.dll" - File "..\Release\sfml-graphics-2.dll" - File "..\Release\sfml-system-2.dll" - File "..\Release\sfml-window-2.dll" - File "..\Release\zlib1.dll" + File "${RELEASE_DIR}\libsndfile-1.dll" + File "${RELEASE_DIR}\openal32.dll" + File "${RELEASE_DIR}\sfml-audio-2.dll" + File "${RELEASE_DIR}\sfml-graphics-2.dll" + File "${RELEASE_DIR}\sfml-system-2.dll" + File "${RELEASE_DIR}\sfml-window-2.dll" + File "${RELEASE_DIR}\zlib1.dll" ; Scenarios SetOutPath "$INSTDIR\Blades of Exile Scenarios" - File "..\Release\Blades of Exile Scenarios\busywork.exs" - File "..\Release\Blades of Exile Scenarios\STEALTH.BMP" - File "..\Release\Blades of Exile Scenarios\stealth.exs" - File "..\Release\Blades of Exile Scenarios\VALLEYDY.BMP" - File "..\Release\Blades of Exile Scenarios\valleydy.exs" - File "..\Release\Blades of Exile Scenarios\ZAKHAZI.BMP" - File "..\Release\Blades of Exile Scenarios\zakhazi.exs" + File "${RELEASE_DIR}\Blades of Exile Scenarios\busywork.exs" + File "${RELEASE_DIR}\Blades of Exile Scenarios\STEALTH.BMP" + File "${RELEASE_DIR}\Blades of Exile Scenarios\stealth.exs" + File "${RELEASE_DIR}\Blades of Exile Scenarios\VALLEYDY.BMP" + File "${RELEASE_DIR}\Blades of Exile Scenarios\valleydy.exs" + File "${RELEASE_DIR}\Blades of Exile Scenarios\ZAKHAZI.BMP" + File "${RELEASE_DIR}\Blades of Exile Scenarios\zakhazi.exs" !include data.nsi SetShellVarContext all CreateShortCut "$DESKTOP\Blades of Exile.lnk" "$INSTDIR\Blades of Exile.exe" @@ -85,9 +94,9 @@ Section "Character Editor" Section2 ; Set Section Files and Shortcuts SetOutPath "$INSTDIR\" - File "..\Release\Char Editor.exe" + File "${RELEASE_DIR}\BoE Character Editor.exe" SetShellVarContext all - CreateShortCut "$SMPROGRAMS\Blades of Exile\Character Editor.lnk" "$INSTDIR\Char Editor.exe" + CreateShortCut "$SMPROGRAMS\Blades of Exile\Character Editor.lnk" "$INSTDIR\BoE Character Editor.exe" SectionEnd @@ -98,11 +107,11 @@ Section "Scenario Editor" Section3 ; Set Section Files and Shortcuts SetOutPath "$INSTDIR\" - File "..\Release\Scen Editor.exe" + File "${RELEASE_DIR}\BoE Scenario Editor.exe" SetOutPath "$INSTDIR\Blades of Exile Base\" - File "..\Release\Blades of Exile Base\bladbase.exs" + File "${RELEASE_DIR}\Blades of Exile Base\bladbase.exs" SetShellVarContext all - CreateShortCut "$SMPROGRAMS\Blades of Exile\Scenario Editor.lnk" "$INSTDIR\Scen Editor.exe" + CreateShortCut "$SMPROGRAMS\Blades of Exile\Scenario Editor.lnk" "$INSTDIR\BoE Scenario Editor.exe" SectionEnd @@ -113,60 +122,60 @@ Section /o "Documentation" Section4 ; Set Section Files and Shortcuts SetOutPath "$INSTDIR\doc\game" - File "..\..\..\doc\game\Contents.html" - File "..\..\..\doc\game\About.html" - File "..\..\..\doc\game\Tips.html" - File "..\..\..\doc\game\Intro.html" - File "..\..\..\doc\game\Screen.html" - File "..\..\..\doc\game\Menus.html" - File "..\..\..\doc\game\Town.html" - File "..\..\..\doc\game\Outdoors.html" - File "..\..\..\doc\game\Combat.html" - File "..\..\..\doc\game\Misc.html" - File "..\..\..\doc\game\Mage.html" - File "..\..\..\doc\game\Priest.html" - File "..\..\..\doc\game\Hints.html" - File "..\..\..\doc\game\Editor.html" - File "..\..\..\doc\game\Credits.html" - File "..\..\..\doc\game\Licensing.html" - File "..\..\..\doc\game\nav.js" - File "..\..\..\doc\game\style.css" + File "..\..\doc\game\Contents.html" + File "..\..\doc\game\About.html" + File "..\..\doc\game\Tips.html" + File "..\..\doc\game\Intro.html" + File "..\..\doc\game\Screen.html" + File "..\..\doc\game\Menus.html" + File "..\..\doc\game\Town.html" + File "..\..\doc\game\Outdoors.html" + File "..\..\doc\game\Combat.html" + File "..\..\doc\game\Misc.html" + File "..\..\doc\game\Mage.html" + File "..\..\doc\game\Priest.html" + File "..\..\doc\game\Hints.html" + File "..\..\doc\game\Editor.html" + File "..\..\doc\game\Credits.html" + File "..\..\doc\game\Licensing.html" + File "..\..\doc\game\nav.js" + File "..\..\doc\game\style.css" SetOutPath "$INSTDIR\doc\editor" - File "..\..\..\doc\editor\Contents.html" - File "..\..\..\doc\editor\About.html" - File "..\..\..\doc\editor\Building.html" - File "..\..\..\doc\editor\Editing.html" - File "..\..\..\doc\editor\Outdoors.html" - File "..\..\..\doc\editor\Towns.html" - File "..\..\..\doc\editor\Terrain.html" - File "..\..\..\doc\editor\Monsters.html" - File "..\..\..\doc\editor\Items.html" - File "..\..\..\doc\editor\Advanced.html" - File "..\..\..\doc\editor\Specials.html" - File "..\..\..\doc\editor\Dialogue.html" - File "..\..\..\doc\editor\Graphics.html" - File "..\..\..\doc\editor\Testing.html" - File "..\..\..\doc\editor\nav.js" - File "..\..\..\doc\editor\style.css" + File "..\..\doc\editor\Contents.html" + File "..\..\doc\editor\About.html" + File "..\..\doc\editor\Building.html" + File "..\..\doc\editor\Editing.html" + File "..\..\doc\editor\Outdoors.html" + File "..\..\doc\editor\Towns.html" + File "..\..\doc\editor\Terrain.html" + File "..\..\doc\editor\Monsters.html" + File "..\..\doc\editor\Items.html" + File "..\..\doc\editor\Advanced.html" + File "..\..\doc\editor\Specials.html" + File "..\..\doc\editor\Dialogue.html" + File "..\..\doc\editor\Graphics.html" + File "..\..\doc\editor\Testing.html" + File "..\..\doc\editor\nav.js" + File "..\..\doc\editor\style.css" SetOutPath "$INSTDIR\doc\editor\appendix" - File "..\..\..\doc\editor\appendix\Specials.html" - File "..\..\..\doc\editor\appendix\Items.html" - File "..\..\..\doc\editor\appendix\Monsters.html" - File "..\..\..\doc\editor\appendix\Terrain.html" - File "..\..\..\doc\editor\appendix\Sounds.html" - File "..\..\..\doc\editor\appendix\Messages.html" - File "..\..\..\doc\editor\appendix\Magic.html" - File "..\..\..\doc\editor\appendix\Examples.html" + File "..\..\doc\editor\appendix\Specials.html" + File "..\..\doc\editor\appendix\Items.html" + File "..\..\doc\editor\appendix\Monsters.html" + File "..\..\doc\editor\appendix\Terrain.html" + File "..\..\doc\editor\appendix\Sounds.html" + File "..\..\doc\editor\appendix\Messages.html" + File "..\..\doc\editor\appendix\Magic.html" + File "..\..\doc\editor\appendix\Examples.html" SetOutPath "$INSTDIR\doc\img" - File "..\..\..\doc\img\background.gif" - File "..\..\..\doc\img\boe.gif" - File "..\..\..\doc\img\editormainmenu.png" - File "..\..\..\doc\img\editorsymbols.gif" - File "..\..\..\doc\img\edoutbtns.png" - File "..\..\..\doc\img\edtownbtns.png" - File "..\..\..\doc\img\invenbtn.gif" - File "..\..\..\doc\img\pcbtn.gif" - File "..\..\..\doc\img\terscr.gif" + File "..\..\doc\img\background.gif" + File "..\..\doc\img\boe.gif" + File "..\..\doc\img\editormainmenu.png" + File "..\..\doc\img\editorsymbols.gif" + File "..\..\doc\img\edoutbtns.png" + File "..\..\doc\img\edtownbtns.png" + File "..\..\doc\img\invenbtn.gif" + File "..\..\doc\img\pcbtn.gif" + File "..\..\doc\img\terscr.gif" SectionEnd diff --git a/rsrc/SConscript b/rsrc/SConscript index b3565f6b..5a251d2a 100644 --- a/rsrc/SConscript +++ b/rsrc/SConscript @@ -18,7 +18,12 @@ env.Install(path.join(data_dir, "shaders"), Glob("#src/tools/mask.*")) # Scenarios -env.Install(path.join(install_dir, "Blades of Exile Scenarios"), Glob("Blades of Exile Scenarios/*.exs") + Glob("Blades of Exile Scenarios/*.meg")) +if str(platform) == "darwin": + scen_gfx = Glob("Blades of Exile Scenarios/*.meg") +elif str(platform) == "win32": + scen_gfx = Glob("Blades of Exile Scenarios/*.BMP") + +env.Install(path.join(install_dir, "Blades of Exile Scenarios"), Glob("Blades of Exile Scenarios/*.exs") + scen_gfx) env.Install(path.join(install_dir, "Blades of Exile Base"), Glob("Blades of Exile Bases/*.exs")) have_xmllint = False diff --git a/src/BoE.vsproj/Installer/Installer.vcxproj.filters b/src/BoE.vsproj/Installer/Installer.vcxproj.filters index 98314430..a027c55a 100644 --- a/src/BoE.vsproj/Installer/Installer.vcxproj.filters +++ b/src/BoE.vsproj/Installer/Installer.vcxproj.filters @@ -7,13 +7,13 @@ - + Source Files - + Source Files - + Source Files diff --git a/src/BoE.vsproj/Installer/Makefile.mak b/src/BoE.vsproj/Installer/Makefile.mak index 009de22c..1d843b79 100644 --- a/src/BoE.vsproj/Installer/Makefile.mak +++ b/src/BoE.vsproj/Installer/Makefile.mak @@ -1,14 +1,14 @@ -all: Release\Install-OBoE.exe +all: Install-OBoE.exe Makefile.mak -Release\Install-OBoE.exe: main.nsi data.nsi - makensis main.nsi +Install-OBoE.exe: ..\..\..\pkg\win\main.nsi ..\..\..\pkg\win\data.nsi + makensis /DMSVC /DRELEASE_DIR=..\..\src\BoE.vsproj\Release ..\..\..\pkg\win\main.nsi -data.nsi: gen-data.py - python gen-data.py > data.nsi +..\..\..\pkg\win\data.nsi: ..\..\..\pkg\win\gen-data.py + python ..\..\..\pkg\win\gen-data.py ..\Release > ..\..\..\pkg\win\data.nsi clean: - del data.nsi - del Release\Install-OBoE.exe + del ..\..\..\pkg\win\data.nsi + del Install-OBoE.exe rebuild: clean all diff --git a/src/BoE.vsproj/PcEdit/Char Editor.vcxproj b/src/BoE.vsproj/PcEdit/Char Editor.vcxproj index 68049cfd..d83b131d 100644 --- a/src/BoE.vsproj/PcEdit/Char Editor.vcxproj +++ b/src/BoE.vsproj/PcEdit/Char Editor.vcxproj @@ -42,11 +42,12 @@ true $(SolutionDir)$(Configuration)\ - Character Editor + BoE Character Editor false $(SolutionDir)$(Configuration)\ + BoE Character Editor diff --git a/src/BoE.vsproj/ScenEdit/Scen Editor.vcxproj b/src/BoE.vsproj/ScenEdit/Scen Editor.vcxproj index 8ee33ce5..04c2abc6 100644 --- a/src/BoE.vsproj/ScenEdit/Scen Editor.vcxproj +++ b/src/BoE.vsproj/ScenEdit/Scen Editor.vcxproj @@ -42,11 +42,12 @@ true $(SolutionDir)$(Configuration)\ - Scenario Editor + BoE Scenario Editor false $(SolutionDir)$(Configuration)\ + BoE Scenario Editor