From ec32d11b76812c920a05eb85fce00df11ac5d744 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sun, 28 Jul 2019 01:05:15 -0400 Subject: [PATCH] Update installer and make things build on windows. We can now build windows executables with jpm. --- appveyor.yml | 4 + auxbin/jpm | 0 auxlib/cook.janet | 8 +- build_win.bat | 4 +- janet-installer.nsi | 72 +++++++-------- tools/FileAssociation.nsh | 190 -------------------------------------- tools/format.sh | 0 7 files changed, 48 insertions(+), 230 deletions(-) mode change 100755 => 100644 auxbin/jpm delete mode 100644 tools/FileAssociation.nsh mode change 100755 => 100644 tools/format.sh diff --git a/appveyor.yml b/appveyor.yml index 4f9fd582..543a7078 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,6 +20,10 @@ init: install: - choco install nsis -y -pre - build_win all + - refreshenv + # We need to reload vcvars after refreshing + - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" + - build_win test-install build: off only_commits: diff --git a/auxbin/jpm b/auxbin/jpm old mode 100755 new mode 100644 diff --git a/auxlib/cook.janet b/auxlib/cook.janet index 09d08711..da779af6 100644 --- a/auxlib/cook.janet +++ b/auxlib/cook.janet @@ -464,7 +464,13 @@ int main(int argc, const char **argv) { (defn clear-cache "Clear the global git cache." [] - (rm (find-cache))) + (def cache (find-cache)) + (print "clearing " cache "...") + (if is-win + # Git for windows decided that .git should be hidden and everything in it read-only. + # This means we can't delete things easily. + (os/shell (string `rmdir /S /Q "` cache `"`)) + (rm cache))) (defn install-git "Install a bundle from git. If the bundle is already installed, the bundle diff --git a/build_win.bat b/build_win.bat index e8d41c29..054c8a7c 100644 --- a/build_win.bat +++ b/build_win.bat @@ -159,7 +159,7 @@ exit /b 0 :INSTALL @echo Running Installer... FOR %%a in (janet-*-windows-installer.exe) DO ( - %%a /S /D=%userprofile%\AppData\Local\Janet\ + %%a /S /CurrentUser ) exit /b 0 @@ -183,8 +183,6 @@ call %0 dist @if errorlevel 1 exit /b 1 call %0 install @if errorlevel 1 exit /b 1 -call %0 test-install -@if errorlevel 1 exit /b 1 @echo Done! exit /b 0 diff --git a/janet-installer.nsi b/janet-installer.nsi index 2278bb5e..f98bb9f7 100644 --- a/janet-installer.nsi +++ b/janet-installer.nsi @@ -20,7 +20,6 @@ VIFileVersion "${PRODUCT_VERSION}" !include "MUI2.nsh" !include ".\tools\EnvVarUpdate.nsh" !include "LogicLib.nsh" -!include "./tools\FileAssociation.nsh" # Basics Name "Janet" @@ -82,7 +81,7 @@ section "Janet" BfWSection createDirectory "$INSTDIR\C" createDirectory "$INSTDIR\bin" createDirectory "$INSTDIR\docs" - setOutPath "$INSTDIR" + setOutPath "$INSTDIR" # Bin files file /oname=bin\janet.exe dist\janet.exe @@ -109,11 +108,11 @@ section "Janet" BfWSection file README.md file LICENSE - # Uninstaller - See function un.onInit and section "uninstall" for configuration - writeUninstaller "$INSTDIR\uninstall.exe" + # Uninstaller - See function un.onInit and section "uninstall" for configuration + writeUninstaller "$INSTDIR\uninstall.exe" - # Start Menu - createShortCut "$SMPROGRAMS\Janet.lnk" "$INSTDIR\bin\janet.exe" "" "$INSTDIR\logo.ico" + # Start Menu + createShortCut "$SMPROGRAMS\Janet.lnk" "$INSTDIR\bin\janet.exe" "" "$INSTDIR\logo.ico" # Set up Environment variables !insertmacro WriteEnv JANET_PATH "$INSTDIR\Library" @@ -124,28 +123,28 @@ section "Janet" BfWSection SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 # Update path - ${EnvVarUpdate} $0 "PATH" "A" "HKCU" "$INSTDIR\bin" ; Append - ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\bin" ; Append - - # File Assocations - ${RegisterExtension} "$INSTDIR\bin\janet.exe" ".janet" "Janet Source File" + ${If} $MultiUser.InstallMode == "AllUsers" + ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\bin" ; Append + ${Else} + ${EnvVarUpdate} $0 "PATH" "A" "HKCU" "$INSTDIR\bin" ; Append + ${EndIf} - # Registry information for add/remove programs - WriteRegStr SHCTX "${UNINST_KEY}" "DisplayName" "Janet" - WriteRegStr SHCTX "${UNINST_KEY}" "InstallLocation" "$INSTDIR" - WriteRegStr SHCTX "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\logo.ico" - WriteRegStr SHCTX "${UNINST_KEY}" "Publisher" "Janet-Lang.org" - WriteRegStr SHCTX "${UNINST_KEY}" "HelpLink" "${HELPURL}" - WriteRegStr SHCTX "${UNINST_KEY}" "URLUpdateInfo" "${HELPURL}" - WriteRegStr SHCTX "${UNINST_KEY}" "URLInfoAbout" "${HELPURL}" - WriteRegStr SHCTX "${UNINST_KEY}" "DisplayVersion" "${VERSION}" - WriteRegDWORD SHCTX "${UNINST_KEY}" "NoModify" 1 - WriteRegDWORD SHCTX "${UNINST_KEY}" "NoRepair" 1 - WriteRegDWORD SHCTX "${UNINST_KEY}" "EstimatedSize" 1000 + # Registry information for add/remove programs + WriteRegStr SHCTX "${UNINST_KEY}" "DisplayName" "Janet" + WriteRegStr SHCTX "${UNINST_KEY}" "InstallLocation" "$INSTDIR" + WriteRegStr SHCTX "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\logo.ico" + WriteRegStr SHCTX "${UNINST_KEY}" "Publisher" "Janet-Lang.org" + WriteRegStr SHCTX "${UNINST_KEY}" "HelpLink" "${HELPURL}" + WriteRegStr SHCTX "${UNINST_KEY}" "URLUpdateInfo" "${HELPURL}" + WriteRegStr SHCTX "${UNINST_KEY}" "URLInfoAbout" "${HELPURL}" + WriteRegStr SHCTX "${UNINST_KEY}" "DisplayVersion" "${VERSION}" + WriteRegDWORD SHCTX "${UNINST_KEY}" "NoModify" 1 + WriteRegDWORD SHCTX "${UNINST_KEY}" "NoRepair" 1 + WriteRegDWORD SHCTX "${UNINST_KEY}" "EstimatedSize" 1000 # Add uninstall WriteRegStr SHCTX "${UNINST_KEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\" /$MultiUser.InstallMode" WriteRegStr SHCTX "${UNINST_KEY}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /$MultiUser.InstallMode /S" - + sectionEnd # Uninstaller @@ -156,10 +155,10 @@ functionEnd section "uninstall" - # Remove Start Menu launcher - delete "$SMPROGRAMS\Janet.lnk" + # Remove Start Menu launcher + delete "$SMPROGRAMS\Janet.lnk" - # Remove files + # Remove files delete "$INSTDIR\logo.ico" delete "$INSTDIR\README.md" delete "$INSTDIR\LICENSE" @@ -175,18 +174,19 @@ section "uninstall" !insertmacro DelEnv JANET_BINPATH # Unset PATH - ${un.EnvVarUpdate} $0 "PATH" "R" "HKCU" "$INSTDIR\bin" ; Remove - ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\bin" ; Remove - - # File Associations - ${UnRegisterExtension} ".janet" "Janet Source File" + ${If} $MultiUser.InstallMode == "AllUsers" + ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\bin" ; Remove + ${Else} + ${un.EnvVarUpdate} $0 "PATH" "R" "HKCU" "$INSTDIR\bin" ; Remove + ${EndIf} # make sure windows knows about the change SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - # Always delete uninstaller as the last action - delete "$INSTDIR\uninstall.exe" + # Always delete uninstaller as the last action + delete "$INSTDIR\uninstall.exe" - # Remove uninstaller information from the registry + # Remove uninstaller information from the registry DeleteRegKey SHCTX "${UNINST_KEY}" -sectionEnd + +sectionEnd \ No newline at end of file diff --git a/tools/FileAssociation.nsh b/tools/FileAssociation.nsh deleted file mode 100644 index 71a9162e..00000000 --- a/tools/FileAssociation.nsh +++ /dev/null @@ -1,190 +0,0 @@ -/* -_____________________________________________________________________________ - - File Association -_____________________________________________________________________________ - - Based on code taken from http://nsis.sourceforge.net/File_Association - - Usage in script: - 1. !include "FileAssociation.nsh" - 2. [Section|Function] - ${FileAssociationFunction} "Param1" "Param2" "..." $var - [SectionEnd|FunctionEnd] - - FileAssociationFunction=[RegisterExtension|UnRegisterExtension] - -_____________________________________________________________________________ - - ${RegisterExtension} "[executable]" "[extension]" "[description]" - -"[executable]" ; executable which opens the file format - ; -"[extension]" ; extension, which represents the file format to open - ; -"[description]" ; description for the extension. This will be display in Windows Explorer. - ; - - - ${UnRegisterExtension} "[extension]" "[description]" - -"[extension]" ; extension, which represents the file format to open - ; -"[description]" ; description for the extension. This will be display in Windows Explorer. - ; - -_____________________________________________________________________________ - - Macros -_____________________________________________________________________________ - - Change log window verbosity (default: 3=no script) - - Example: - !include "FileAssociation.nsh" - !insertmacro RegisterExtension - ${FileAssociation_VERBOSE} 4 # all verbosity - !insertmacro UnRegisterExtension - ${FileAssociation_VERBOSE} 3 # no script -*/ - - -!ifndef FileAssociation_INCLUDED -!define FileAssociation_INCLUDED - -!include Util.nsh - -!verbose push -!verbose 3 -!ifndef _FileAssociation_VERBOSE - !define _FileAssociation_VERBOSE 3 -!endif -!verbose ${_FileAssociation_VERBOSE} -!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE` -!verbose pop - -!macro FileAssociation_VERBOSE _VERBOSE - !verbose push - !verbose 3 - !undef _FileAssociation_VERBOSE - !define _FileAssociation_VERBOSE ${_VERBOSE} - !verbose pop -!macroend - - - -!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION - !verbose push - !verbose ${_FileAssociation_VERBOSE} - Push `${_DESCRIPTION}` - Push `${_EXTENSION}` - Push `${_EXECUTABLE}` - ${CallArtificialFunction} RegisterExtension_ - !verbose pop -!macroend - -!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION - !verbose push - !verbose ${_FileAssociation_VERBOSE} - Push `${_EXTENSION}` - Push `${_DESCRIPTION}` - ${CallArtificialFunction} UnRegisterExtension_ - !verbose pop -!macroend - - - -!define RegisterExtension `!insertmacro RegisterExtensionCall` -!define un.RegisterExtension `!insertmacro RegisterExtensionCall` - -!macro RegisterExtension -!macroend - -!macro un.RegisterExtension -!macroend - -!macro RegisterExtension_ - !verbose push - !verbose ${_FileAssociation_VERBOSE} - - Exch $R2 ;exe - Exch - Exch $R1 ;ext - Exch - Exch 2 - Exch $R0 ;desc - Exch 2 - Push $0 - Push $1 - - ReadRegStr $1 HKCR $R1 "" ; read current file association - StrCmp "$1" "" NoBackup ; is it empty - StrCmp "$1" "$R0" NoBackup ; is it our own - WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value -NoBackup: - WriteRegStr HKCR $R1 "" "$R0" ; set our file association - - ReadRegStr $0 HKCR $R0 "" - StrCmp $0 "" 0 Skip - WriteRegStr HKCR "$R0" "" "$R0" - WriteRegStr HKCR "$R0\shell" "" "open" - WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0" -Skip: - WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"' - WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0" - WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"' - - Pop $1 - Pop $0 - Pop $R2 - Pop $R1 - Pop $R0 - - !verbose pop -!macroend - - - -!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall` -!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall` - -!macro UnRegisterExtension -!macroend - -!macro un.UnRegisterExtension -!macroend - -!macro UnRegisterExtension_ - !verbose push - !verbose ${_FileAssociation_VERBOSE} - - Exch $R1 ;desc - Exch - Exch $R0 ;ext - Exch - Push $0 - Push $1 - - ReadRegStr $1 HKCR $R0 "" - StrCmp $1 $R1 0 NoOwn ; only do this if we own it - ReadRegStr $1 HKCR $R0 "backup_val" - StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key - DeleteRegKey HKCR $R0 - Goto NoOwn - -Restore: - WriteRegStr HKCR $R0 "" $1 - DeleteRegValue HKCR $R0 "backup_val" - DeleteRegKey HKCR $R1 ;Delete key with association name settings - -NoOwn: - - Pop $1 - Pop $0 - Pop $R1 - Pop $R0 - - !verbose pop -!macroend - -!endif # !FileAssociation_INCLUDED diff --git a/tools/format.sh b/tools/format.sh old mode 100755 new mode 100644