diff --git a/.gitignore b/.gitignore index b6a1750..784ab7c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.chm *.exe +*.ini build/ dist/ -rules.ini +belvedere.sublime-workspace diff --git a/README.md b/README.md index 9d3c1d7..f1c19ba 100644 --- a/README.md +++ b/README.md @@ -10,25 +10,24 @@ An automated file manager for Windows See [LICENSE.txt](https://github.com/mshorts/belvedere/blob/master/LICENSE.txt) for licensing details. -#How to build the installer manually. +### How to build the installer manually. 1. Clone the repo: `git clone git://github.com/mshorts/belvedere.git` 2. Download and install [NSIS](http://prdownloads.sourceforge.net/nsis/nsis-2.46-setup.exe?download) 3. Download [KIllProc plug-in for NSIS](http://code.google.com/p/mulder/downloads/detail?name=NSIS-KillProc-Plugin.2011-04-09.zip&can=4&q=) -4. Download and install [Microsoft HTML Help Workshop 1.3](http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=21138). -5. Download and install [AutoHotkey_L](http://www.autohotkey.com/download/). -6. Download and install [Compile_AHK](http://www.autohotkey.com/forum/topic22975.html). -7. Compile Belvedere.ahk with Compile_AHK(in the root of the repo) and move the .exe into the /installer directory. -8. Compile /help/Belvedere Help.hhp with HTML Help Workshop and move the .chm to the /installer directory. -9. Compile /installer/install.nsi -10. Make sure to test the installer. +4. Download and install [AutoHotkey_L](http://www.autohotkey.com/download/). +5. Download and install [Compile_AHK](http://www.autohotkey.com/forum/topic22975.html). +6. Compile Belvedere.ahk with Compile_AHK(in the root of the repo) and move the .exe into the /installer directory. +7. Compile /help/Belvedere Help.hhp with HTML Help Workshop and move the .chm to the /installer directory. +8. Compile /installer/install.nsi +9. Make sure to test the installer. -#How to build the installer automatically. +### How to build the installer automatically. -1. Run build.ahk +1. Run build-tools/build.ahk 2. Find the installer in the /dist directory. -#How to run. +### How to run. 1. Download the installer -or- 2. Install AutoHotkey and run Belvedere.ahk. diff --git a/belvedere.sublime-project b/belvedere.sublime-project new file mode 100644 index 0000000..36bdd1c --- /dev/null +++ b/belvedere.sublime-project @@ -0,0 +1,8 @@ +{ + "folders": + [ + { + "path": "/I/dev/projects/belvedere" + } + ] +} diff --git a/build-tools/build-GUI-build.ahk b/build-tools/build-GUI-build.ahk new file mode 100644 index 0000000..03ab20a --- /dev/null +++ b/build-tools/build-GUI-build.ahk @@ -0,0 +1,10 @@ +Gui, 2:Add, Edit, x12 y10 w450 h130 +cBlack +ReadOnly +R10 +Gui, 2:Add, Button, x187 y150 w100 h30 gCancel, Cancel +; Generated using SmartGUI Creator 4.0 +Gui, 2:Show, x448 y272 h196 w479, New GUI Window +Return + +2GuiClose: +ExitApp + +Cancel: \ No newline at end of file diff --git a/build-tools/build-GUI-welcome.ahk b/build-tools/build-GUI-welcome.ahk new file mode 100644 index 0000000..10b9d52 --- /dev/null +++ b/build-tools/build-GUI-welcome.ahk @@ -0,0 +1,21 @@ +Gui, 1:Add, Text, x2 y0 w270 h20 +ReadOnly +ReadOnly +Center, Belvedere Installer Build Tool +Gui, 1:Add, Picture, x2 y20 w270 h270 , I:\dev\projects\belvedere\resources\both.png +Gui, 1:Add, Button, x282 y10 w100 h50 gBuild, &Build +Gui, 1:Add, Button, x282 y70 w100 h30 , &Configure +Gui, 1:Add, Button, x282 y110 w100 h30 g1GuiClose, &Exit +Gui, 1:Add, Text, x392 y10 w190 h50 , Build the installer using the default setting. The build tool will look for dependencies automatically. +Gui, 1:Add, Text, x392 y70 w190 h30 , Configure the build environment manually. +Gui, 1:Add, Text, x392 y110 w190 h30 , Close the build tool. +Gui, 1:Add, Text, x282 y150 w300 h140 , Copyright 2012 Dorian Alexander Patterson.`nDistrubed under the GNU Public License version 3. See LICENSE.txt for details.`nWritten in AutoHotkey. +; Generated using SmartGUI Creator 4.0 +Gui, 1:Show, Center h298 w600, %buildToolsName% +Return + +1GuiClose: +ExitApp +return + +Build: +Gui, 1:Cancel +#Include build-GUI-build.ahk +Return \ No newline at end of file diff --git a/build-tools/build.ahk b/build-tools/build.ahk new file mode 100644 index 0000000..dd7b869 --- /dev/null +++ b/build-tools/build.ahk @@ -0,0 +1,141 @@ +; Build script for Belvedere +; Version 0.3.1 +; Author: Dorian Alexander Patterson +; Requires: AutoHotkey_L 1.1.07.01+ +; +; Copyright 2012 Dorian Alexander Patterson +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . + +; Set up build environment +#NoEnv +#SingleInstance ignore +#NoTrayIcon +SetWorkingDir .. +buildDir = %A_WorkingDir%\build +buildToolsDir = %A_WorkingDir%\build-tools +;buildToolsName = Belvedere Installer Build Tool +installerDir = %A_WorkingDir%\installer +helpProject = %A_WorkingDir%\help\Belvedere Help.hhp +distDir = %A_WorkingDir%\dist +executableName = Belvedere.exe +installerScript = %buildDir%\installer.nsi + +SetWorkingDir, %buildToolsDir% +#Include configure.ahk + +; After configuration, actually build things. +SetWorkingDir, .. +; Clean old build files. +IfExist, %BuildDir% +{ + FileAppend, Clean old build files...`n, * + FileRemoveDir, %BuildDir%, 1 +} +; Create build directory. +try +{ + FileAppend, Creating build directory: %BuildDir%`n, * + FileCreateDir, %BuildDir% +} +catch e +{ + FileAppend, Could not create the build directory. Check your permissions.`n, * + ExitApp, 1 +} + +; Compile executable. +FileAppend, Building Belvedere.exe...`n, * +; 64-Bit workaround. Compile_AHK doesn't play nice. Use ahk2exe directly. +if (Is64Bit()) +{ + try + { + Program := Dependencies.ahk2exe + Target = %Program% /in %A_WorkingDir%\Belvedere.ahk + RunWait, %Target% + } + catch e + { + FileAppend, Could not build Belvedere.exe. Check your permissions.`n, * + ExitApp, 1 + } +} +; 32-bit. Use Compile_AHK. +else +{ + try + { + Program := Dependencies.compileahk + Target = %Program% /auto %A_WorkingDir%\Belvedere.ahk + RunWait, %Target% + } + catch e + { + FileAppend, Could not build Belvedere.exe. Check your permissions.`n, * + ExitApp, 1 + } +} + +; Move executable to build directory. +FileMove, %A_WorkingDir%\%executableName%, %BuildDir% + +; Compile help. +FileAppend, Building help...`n, * +try +{ + Program := Dependencies.hhc + Target = "%Program%" "%helpProject%" + RunWait, %Target% +} +catch e +{ + FileAppend, Could not build help. Check your permissions.`n, * + ExitApp, 1 +} + +; Copy installer files to build directory. +try +{ + FileCopy, %InstallerDir%\*.*, %BuildDir%\*.* +} +catch e +{ + FileAppend, Could not copy installation files. Check your permissions.`n, * + ExitApp, 1 +} + +; Compile the installer. +FileAppend, Building installer...`n, * +try +{ + Program := Dependencies.makensis + Target = "%Program%" /V4 "%InstallerScript%" + RunWait, %Target% +} +catch e +{ + FileAppend, Could not build installer. Check your permissions.`n, * + ExitApp, 1 +} + +OnExit: +If (A_ExitReason == "Error") +{ + MsgBox, Unable to compile the installer. Please check the logs. +} +Else +{ + MsgBox, Installer compiled successfully!`nYou can find the installer in %distDir% +} diff --git a/build-tools/configure.ahk b/build-tools/configure.ahk new file mode 100644 index 0000000..0ef4f9e --- /dev/null +++ b/build-tools/configure.ahk @@ -0,0 +1,183 @@ +; configure.ahk +; Configures dependencies for the build script +; +; Copyright 2012 Dorian Alexander Patterson +; +; This is part of build.ahk. +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . + +Dependencies := {ahk2exe: "", compileahk: "", hhc: "", makensis: ""} +DependencyCount = 4 +ahk2exe := { DefaultLocation32: "C:\Program Files\AutoHotKey\Compiler\Ahk2Exe.exe" + , DefaultLocation64: "C:\Program Files (x86)\AutoHotKey\Compiler\Ahk2Exe.exe" + , RegistryRootKey: "HKLM" + , RegistrySubKey: "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Ahk2Exe.exe" + , RegistryValueName: ""} +compileahk := { DefaultLocation32: "C:\Program Files\AutoHotKey\Compiler\Compile_AHK.exe" + , DefaultLocation64: "C:\Program Files (x86)\AutoHotKey\Compiler\Compile_AHK.exe" + , RegistryRootKey: "HKLM" + , RegistrySubKey: "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Ahk2Exe.exe" + , RegistryValueName: ""} +hhc := { DefaultLocation32: "C:\Program Files\HTML Help Workshop\hhc.exe" + , DefaultLocation64: "C:\Program Files (x86)\HTML Help Workshop\hhc.exe" + , RegistryRootKey: "HKLM" + , RegistrySubKey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\28E7A37130464D115AF3000972A8B18B" + , RegistryValueName: "6EA51B6D250BE3636BBB4C17C4AB5690"} +makensis := { DefaultLocation32: "C:\Program Files\NSIS\makensis.exe" + , DefaultLocation64: "C:\Program Files (x86)\NSIS\makensis.exe" + , RegistryRootKey: "HKLM" + , RegistrySubKey: "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\NSIS" + , RegistryValueName: "InstallLocation"} +ConfigFile = build.ini + +; Check for a build.ini. Create an annotated boilerplate if one does not exist. +FileAppend, % "Searching for " . ConfigFile . " ... ", * +IfNotExist, %ConfigFile% +{ + FileAppend, not found ... creating one now.`n, * + FileAppend, `; Configuration for build.ahk`n, %ConfigFile% + FileAppend, [compilers]`n, %ConfigFile% + For Key, Value in Dependencies + { + FileAppend, %Key%=`n, %ConfigFile% + } +} + +; If it already exists read from the configuration file +Else +{ + FileAppend, found. searching for dependencies.`n, * + For Key, Value in Dependencies + { + Filename = %ConfigFile% + Section = compilers + IniRead, CompilerLocation, %Filename%, %Section%, %Key% + FileAppend, % "Searching for " . key . " at " . CompilerLocation . " ... ", * + IfExist, %CompilerLocation% + { + FileAppend, found!`n, * + Dependencies[key] := CompilerLocation + } + Else + { + FileAppend, not found.`n, * + } + } +} + +; Search at default install locations. +FileAppend, Seaching default install paths...`n, * +For Key, Value in Dependencies +{ + ; Continue if already found. + If (Value) + { + Continue + } + If (Is64Bit()) + { + CompilerLocation := %key%.DefaultLocation64 + } + Else + { + CompilerLocation := %key%.DefaultLoaction32 + } + FileAppend, % "Searching for " . key . " at " . CompilerLocation . " ... ", * + IfExist, %CompilerLocation% + { + FileAppend, found!`n, * + Dependencies[key] := CompilerLocation + } + Else + { + FileAppend, not found.`n, * + } +} + +; Search in registry. +FileAppend, Searching the registry...`n, * +For Key, Value in Dependencies +{ + if(Value) + { + Continue + } + RootKey := %Key%.RegistryRootKey + SubKey := %Key%.RegistrySubKey + ValueName := %Key%.RegistryValueName + RegRead, CompilerLocation, %RootKey%, %SubKey%, %ValueName% + + ; Compile_AHK doesn't set a registry value for its installation directory. By default, it should be in the same + ; directory as ahk2exe. Use Splitpath to to remove the file name and then append the correct file name. + If (%Key% == compileahk) + { + Splitpath, CompilerLocation, , CompilerLocation + CompilerLocation := CompilerLocation . "\Compile_AHK.exe" + } + + ; The regesitry value for makensis only has the path to the executable not the full file name. Append the rest. + If (%key% == makensis) + { + CompilerLocation := CompilerLocation . "\makensis.exe" + } + + IfExist, %CompilerLocation% + { + Dependencies[key] := CompilerLocation + } +} + +Summary: +; Summary of configuration. +Loop 80 +{ + FileAppend, -, * +} +FileAppend, `n, * +FileAppend, Configuration Summary:`n, * + +For Key, Value in Dependencies +{ + FileAppend, %key% = %value%`n, * + If(Value) + { + Count ++ + } +} + +; Write known dependencies to configuration file. +For Key, Value in Dependencies +{ + Section = compilers + IniWrite, %Value%, %ConfigFile%, compilers, %key% +} + +; If configuration is successful... +If (Count == DependencyCount) +{ + FileAppend, Configuration successful!`n, * +} +Else +{ + FileAppend, Configuration incomplete. Please download the necessary dependencies.`n, * + ExitApp, 1 +} + +; Function definitions. +; Detect CPU architecture +Is64Bit() { + EnvGet, procID, Processor_Identifier + return RegexMatch(procID, "^[^ ]+64") > 0 +} diff --git a/build.ahk b/build.ahk deleted file mode 100644 index bd20270..0000000 --- a/build.ahk +++ /dev/null @@ -1,95 +0,0 @@ -; Build script for Belvedere -; Version 0.1.0 -; Author: Dorian Alexander Patterson -; Requires: AutoHotkey_L 1.1.07.01+ -; -; Copyright 2012 Dorian Alexander Patterson -; -; This program is free software: you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation, either version 3 of the License, or -; (at your option) any later version. - -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. - -; You should have received a copy of the GNU General Public License -; along with this program. If not, see . - -; Set up build environment -#NoEnv -#SingleInstance ignore -SetWorkingDir A_ScriptDir -buildDir = %A_WorkingDir%\build -installerDir = %A_WorkingDir%\installer -helpProject = %A_WorkingDir%\help\Belvedere Help.hhp -distDir = %A_WorkingDir%\dist -executableName = Belvedere.exe -installerScript = %buildDir%\installer.nsi - -; Check dependencies -; AutoHotkey script compiler. -RegRead, ahk2exe, HKEY_LOCAL_MACHINE, SOFTWARE\AutoHotkey, InstallDir -if ErrorLevel{ - MsgBox, "You do not have AutoHotkey_L installed. Please download it." - ExitApp, 1 -} - -ahk2exe .= "\Compiler\Compile_AHK.exe" - -; Help manual compiler. -RegRead, hhc, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\hhw.exe, Path -if ErrorLevel{ - MsgBox, "You do not have Microsoft HTML Help Workshop installed. Please download it." - ExitApp, 1 -} - -hhc .= "\hhc.exe" - -; Commandline compiler for NSIS (makensis.exe) -RegRead, makensis, HKEY_LOCAL_MACHINE, SOFTWARE\NSIS -if ErrorLevel{ - MsgBox, "You do not have NSIS Installed, the installer will not be compiled." - skipInstaller := 1 -} - -makensis .= "\makensis.exe" - -; Clean old build files -IfExist, %buildDir% - FileRemoveDir, %buildDir%, 1 -FileCreateDir, %buildDir% - -; Compile Belvedere.ahk -RunWait, %ahk2exe% /nogui %A_ScriptDir%\Belvedere.ahk - -; Move to build folder -IfExist, %executableName% -{ - FileMove, %executableName%, %buildDir% -}Else{ - MsgBox, "Application Compile Failed, exiting..." - ExitApp, 1 -} - -; Compile help. -RunWait, %hhc% "%helpProject%" - -IfNotExist, %A_ScriptDir%\build\Belvedere Help.chm -{ - MsgBox, "Help Compile Failed, the installer will not be compiled." - skipInstaller := 1 -} - -; Copy installer files to build -FileCopy, %installerDir%\*.*, %buildDir%\*.* - -; Build the installer -if(!skipInstaller) -{ - CompileCommand = %makensis% /V1 %installerScript% - FileCreateDir, %A_WorkingDir%\dist - RunWait, %CompileCommand% -}