scons: Generate Windows installer

Also:
- scons: Fix copying wrong scenario graphics on Windows
- MSVC: Fix output filenames for release builds
This commit is contained in:
2015-09-14 02:15:40 -04:00
parent 19197a64e7
commit 43e057949d
12 changed files with 157 additions and 97 deletions

0
pkg/mac/SConscript Normal file
View File

26
pkg/win/SConscript Normal file
View File

@@ -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")

119
pkg/win/fileassoc.nsh Normal file
View File

@@ -0,0 +1,119 @@
; fileassoc.nsh
; File association helper macros
; Written by Saivert
;
; Features automatic backup system and UPDATEFILEASSOC macro for
; shell change notification.
;
; |> How to use <|
; To associate a file with an application so you can double-click it in explorer, use
; the APP_ASSOCIATE macro like this:
;
; Example:
; !insertmacro APP_ASSOCIATE "txt" "myapp.textfile" "Description of txt files" \
; "$INSTDIR\myapp.exe,0" "Open with myapp" "$INSTDIR\myapp.exe $\"%1$\""
;
; Never insert the APP_ASSOCIATE macro multiple times, it is only ment
; to associate an application with a single file and using the
; the "open" verb as default. To add more verbs (actions) to a file
; use the APP_ASSOCIATE_ADDVERB macro.
;
; Example:
; !insertmacro APP_ASSOCIATE_ADDVERB "myapp.textfile" "edit" "Edit with myapp" \
; "$INSTDIR\myapp.exe /edit $\"%1$\""
;
; To have access to more options when registering the file association use the
; APP_ASSOCIATE_EX macro. Here you can specify the verb and what verb is to be the
; standard action (default verb).
;
; And finally: To remove the association from the registry use the APP_UNASSOCIATE
; macro. Here is another example just to wrap it up:
; !insertmacro APP_UNASSOCIATE "txt" "myapp.textfile"
;
; |> Note <|
; When defining your file class string always use the short form of your application title
; then a period (dot) and the type of file. This keeps the file class sort of unique.
; Examples:
; Winamp.Playlist
; NSIS.Script
; Photoshop.JPEGFile
;
; |> Tech info <|
; The registry key layout for a file association is:
; HKEY_CLASSES_ROOT
; <applicationID> = <"description">
; shell
; <verb> = <"menu-item text">
; command = <"command string">
;
!macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND
; Backup the previously associated file class
ReadRegStr $R0 HKCR ".${EXT}" ""
WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0"
WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}"
WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}`
WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}`
WriteRegStr HKCR "${FILECLASS}\shell" "" "open"
WriteRegStr HKCR "${FILECLASS}\shell\open" "" `${COMMANDTEXT}`
WriteRegStr HKCR "${FILECLASS}\shell\open\command" "" `${COMMAND}`
!macroend
!macro APP_ASSOCIATE_EX EXT FILECLASS DESCRIPTION ICON VERB DEFAULTVERB SHELLNEW COMMANDTEXT COMMAND
; Backup the previously associated file class
ReadRegStr $R0 HKCR ".${EXT}" ""
WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0"
WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}"
StrCmp "${SHELLNEW}" "0" +2
WriteRegStr HKCR ".${EXT}\ShellNew" "NullFile" ""
WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}`
WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}`
WriteRegStr HKCR "${FILECLASS}\shell" "" `${DEFAULTVERB}`
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}`
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}`
!macroend
!macro APP_ASSOCIATE_ADDVERB FILECLASS VERB COMMANDTEXT COMMAND
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}`
WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}`
!macroend
!macro APP_ASSOCIATE_REMOVEVERB FILECLASS VERB
DeleteRegKey HKCR `${FILECLASS}\shell\${VERB}`
!macroend
!macro APP_UNASSOCIATE EXT FILECLASS
; Backup the previously associated file class
ReadRegStr $R0 HKCR ".${EXT}" `${FILECLASS}_backup`
WriteRegStr HKCR ".${EXT}" "" "$R0"
DeleteRegKey HKCR `${FILECLASS}`
!macroend
!macro APP_ASSOCIATE_GETFILECLASS OUTPUT EXT
ReadRegStr ${OUTPUT} HKCR ".${EXT}" ""
!macroend
; !defines for use with SHChangeNotify
!ifdef SHCNE_ASSOCCHANGED
!undef SHCNE_ASSOCCHANGED
!endif
!define SHCNE_ASSOCCHANGED 0x08000000
!ifdef SHCNF_FLUSH
!undef SHCNF_FLUSH
!endif
!define SHCNF_FLUSH 0x1000
!macro UPDATEFILEASSOC
; Using the system.dll plugin to call the SHChangeNotify Win32 API function so we
; can update the shell.
System::Call "shell32::SHChangeNotify(i,i,i,i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_FLUSH}, 0, 0)"
!macroend
;EOF

34
pkg/win/gen-data.py Normal file
View File

@@ -0,0 +1,34 @@
from os.path import normpath as makepath
from glob import glob
import sys
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
# the build output directory), and the value is either a glob pattern to include,
# or an explicit list of files to include.
# All paths should be in UNIX format, since makepath() will be used to convert them.
# There should be no trailing slashes.
files = {
'data/dialogs': '*.xml',
'data/strings': '*.txt',
'data/fonts': '*.ttf',
'data/shaders': ['mask.frag', 'mask.vert'],
'data/graphics': '*.png',
'data/cursors': '*.gif',
'data/sounds': '*.WAV',
}
for path, pattern in files.items():
print 'SetOutPath', '"' + makepath("$INSTDIR/" + path + '/') + '"'
if type(pattern) == list:
check_files = [root + '/' + path + '/' + x for x in pattern]
else:
check_files = glob(makepath(root + '/' + path + '/' + pattern))
for fname in check_files:
print 'File', '"' + makepath(fname.replace(root, '${RELEASE_DIR}')) + '"'

285
pkg/win/main.nsi Normal file
View File

@@ -0,0 +1,285 @@
; Script generated with the Venis Install Wizard
; Define your application name
!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 "Install-OBoE.exe"
; File association helpers
!include "fileassoc.nsh"
; Modern interface settings
!include "MUI.nsh"
!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_RUN "$INSTDIR\Blades of Exile.exe"
; These ensure that you don't have to "agree" to the license to continue
!define MUI_LICENSEPAGE_TEXT_BOTTOM "Press the Install button to Continue"
!define MUI_LICENSEPAGE_BUTTON "&Install"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "..\..\LICENSE.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
; Set languages (first is default language)
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL
Section "Blades of Exile" Section1
; Set Section properties
SectionIn RO
SetOverwrite ifnewer
; Set Section Files and Shortcuts
SetOutPath "$INSTDIR\"
; Install Visual Studio Redistributables
!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_DIR}\Blades of Exile.exe"
; Required DLLs
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_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"
CreateDirectory "$SMPROGRAMS\Blades of Exile"
CreateShortCut "$SMPROGRAMS\Blades of Exile\Blades of Exile.lnk" "$INSTDIR\Blades of Exile.exe"
CreateShortCut "$SMPROGRAMS\Blades of Exile\Uninstall.lnk" "$INSTDIR\uninstall.exe"
SectionEnd
Section "Character Editor" Section2
; Set Section properties
SetOverwrite on
; Set Section Files and Shortcuts
SetOutPath "$INSTDIR\"
File "${RELEASE_DIR}\BoE Character Editor.exe"
SetShellVarContext all
CreateShortCut "$SMPROGRAMS\Blades of Exile\Character Editor.lnk" "$INSTDIR\BoE Character Editor.exe"
SectionEnd
Section "Scenario Editor" Section3
; Set Section properties
SetOverwrite on
; Set Section Files and Shortcuts
SetOutPath "$INSTDIR\"
File "${RELEASE_DIR}\BoE Scenario Editor.exe"
SetOutPath "$INSTDIR\Blades of Exile Base\"
File "${RELEASE_DIR}\Blades of Exile Base\bladbase.exs"
SetShellVarContext all
CreateShortCut "$SMPROGRAMS\Blades of Exile\Scenario Editor.lnk" "$INSTDIR\BoE Scenario Editor.exe"
SectionEnd
Section /o "Documentation" Section4
; Set Section properties
SetOverwrite on
; 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"
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"
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"
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"
SectionEnd
Section -FinishSection
WriteRegStr HKLM "Software\${APPNAME}" "" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteUninstaller "$INSTDIR\uninstall.exe"
!insertmacro APP_ASSOCIATE "exg" "BladesofExile.SaveGame" "Blades of Exile saved game" "$INSTDIR\Blades of Exile.exe,1" "" '"$INSTDIR\Blades of Exile.exe" "%1"'
!insertmacro APP_ASSOCIATE_ADDVERB "BladesOfExile.SaveGame" "edit" "" '"$INSTDIR\Char Editor.exe" "%1"'
!insertmacro APP_ASSOCIATE "boes" "BladesofExile.Scenario" "Blades of Exile scenario" "$INSTDIR\Blades of Exile.exe,2" "" '"$INSTDIR\Scen Editor.exe" "%1"'
!insertmacro APP_ASSOCIATE "exs" "BladesofExile.OldScenario" "Blades of Exile scenario" "$INSTDIR\Blades of Exile.exe,2" "" '"$INSTDIR\Scen Editor.exe" "%1"'
!insertmacro UPDATEFILEASSOC
; WriteRegStr HKCR ".exg" "" "BladesOfExile.SaveGame"
; WriteRegStr HKCR ".boes" "" "BladesOfExile.Scenario"
; WriteRegStr HKCR "MPC.avi" "" "AVI File"
; WriteRegStr HKCR "MPC.avi\shell" "" "Open"
; WriteRegStr HKCR "MPC.avi\shell\open\command" "" '"$INSTDIR\Blades of Exile.exe" "%1"'
; WriteRegStr HKCR "MPC.avi\DefaultIcon" "" "$INSTDIR\Blades of Exile.exe,1"
SectionEnd
; Modern install component descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} "Install the Blades of Exile game and the four scenarios created by Jeff Vogel, the game's original creator."
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} "Allows you to edit saved games. You can use this to cheat, or to build a stronger party to enter a harder scenario."
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} "Allows you to create your own adventures!"
!insertmacro MUI_DESCRIPTION_TEXT ${Section4} "Install an offline copy of the Blades of Exile documentation."
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;Uninstall section
Section Uninstall
FindWindow $0 "SFML_Window" "Blades of Exile"
IsWindow $0 0 +3
MessageBox MB_ABORTRETRYIGNORE|MB_ICONSTOP "You can't uninstall now because Blades of Exile is currently running. Quit Blades of Exile, and then try again." IDRETRY -2 IDIGNORE +2
Abort
FindWindow $0 "SFML_Window" "Blades of Exile Character Editor"
IsWindow $0 0 +3
MessageBox MB_ABORTRETRYIGNORE|MB_ICONSTOP "You can't uninstall now because the Blades of Exile Character Editor is currently running. Quit the Character Editor, and then try again." IDRETRY -2 IDIGNORE +2
Abort
FindWindow $0 "SFML_Window" "Blades of Exile Scenario Editor"
IsWindow $0 0 +3
MessageBox MB_ABORTRETRYIGNORE|MB_ICONSTOP "You can't uninstall now because the Blades of Exile Scenario Editor is currently running. Quit the Scenario Editor, and then try again." IDRETRY -2 IDIGNORE +2
Abort
;Remove from registry...
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
DeleteRegKey HKLM "SOFTWARE\${APPNAME}"
!insertmacro APP_UNASSOCIATE "exg" "BladesOfExile.SaveGame"
!insertmacro APP_UNASSOCIATE "boes" "BladesOfExile.Scenario"
!insertmacro APP_UNASSOCIATE "exs" "BladesOfExile.OldScenario"
!insertmacro UPDATEFILEASSOC
; Delete self
Delete "$INSTDIR\uninstall.exe"
; Clean up Blades of Exile
Delete "$INSTDIR\Blades of Exile.exe"
Delete "$INSTDIR\Blades of Exile Scenarios\busywork.exs"
Delete "$INSTDIR\Blades of Exile Scenarios\STEALTH.BMP"
Delete "$INSTDIR\Blades of Exile Scenarios\stealth.exs"
Delete "$INSTDIR\Blades of Exile Scenarios\VALLEYDY.BMP"
Delete "$INSTDIR\Blades of Exile Scenarios\valleydy.exs"
Delete "$INSTDIR\Blades of Exile Scenarios\ZAKHAZI.BMP"
Delete "$INSTDIR\Blades of Exile Scenarios\zakhazi.exs"
Delete "$INSTDIR\VCRedistInstall.exe"
Delete "$INSTDIR\libsndfile-1.dll"
Delete "$INSTDIR\sfml-audio-2.dll"
Delete "$INSTDIR\sfml-graphics-2.dll"
Delete "$INSTDIR\sfml-system-2.dll"
Delete "$INSTDIR\sfml-window-2.dll"
Delete "$INSTDIR\zlib1.dll"
Delete "$INSTDIR\openal32.dll"
RMDir /r "$INSTDIR\doc"
RMDir /r "$INSTDIR\data"
; Clean up Character Editor
Delete "$INSTDIR\Char Editor.exe"
; Clean up Scenario Editor
Delete "$INSTDIR\Scen Editor.exe"
Delete "$INSTDIR\Blades of Exile Base\bladbase.exs"
; Remove remaining directories
RMDir "$INSTDIR\Blades of Exile Scenarios\"
RMDir "$INSTDIR\Blades of Exile Base\"
RMDir "$INSTDIR\"
; Delete Shortcuts
SetShellVarContext all
Delete "$DESKTOP\Blades of Exile.lnk"
Delete "$SMPROGRAMS\Blades of Exile\Blades of Exile.lnk"
Delete "$SMPROGRAMS\Blades of Exile\Uninstall.lnk"
Delete "$SMPROGRAMS\Blades of Exile\Character Editor.lnk"
Delete "$SMPROGRAMS\Blades of Exile\Scenario Editor.lnk"
RMDir "$SMPROGRAMS\Blades of Exile\"
SectionEnd
; eof