# HG changeset patch # User John Donoghue # Date 1411668941 14400 # Node ID 70480095b6ed8ef1f8fc1f03061968e9c9a93cbe # Parent 023f392ce053063e17d603e5248196c815a4be27 Use a bat file to run octave in windows (Bug #43164) * binary-dist-rules.mk: copy octave.bat to dist folder * dist-files.mk: add octave.bat * installer-files/octave.bat: new file * makeinst-script.sh: use octave.bat instead of octave-xxxx.exe in script and registry. diff -r 023f392ce053 -r 70480095b6ed binary-dist-rules.mk --- a/binary-dist-rules.mk Tue Sep 23 13:47:30 2014 -0400 +++ b/binary-dist-rules.mk Thu Sep 25 14:15:41 2014 -0400 @@ -73,6 +73,8 @@ cp $(TOP_DIR)/installer-files/README.html $(OCTAVE_DIST_DIR)/ echo " refblas..." cp $(OCTAVE_DIST_DIR)/bin/libblas.dll $(OCTAVE_DIST_DIR)/bin/librefblas.dll + echo " octave.bat..." + cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)/ endef else define copy-windows-dist-files @@ -82,6 +84,8 @@ cp $(TOP_DIR)/installer-files/README.html $(OCTAVE_DIST_DIR)/ echo " refblas..." cp $(OCTAVE_DIST_DIR)/bin/libblas.dll $(OCTAVE_DIST_DIR)/bin/librefblas.dll + echo " octave.bat..." + cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)/ endef endif endif diff -r 023f392ce053 -r 70480095b6ed dist-files.mk --- a/dist-files.mk Tue Sep 23 13:47:30 2014 -0400 +++ b/dist-files.mk Thu Sep 25 14:15:41 2014 -0400 @@ -767,6 +767,7 @@ INSTALL_FILES_1 := \ gpl-3.0.txt \ + octave.bat \ octave.bmp \ octave-hdr.bmp \ octave-logo.ico \ diff -r 023f392ce053 -r 70480095b6ed installer-files/octave.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/installer-files/octave.bat Thu Sep 25 14:15:41 2014 -0400 @@ -0,0 +1,42 @@ +@echo off +Rem Find Octave's install directory through cmd.exe variables. +Rem This batch file should reside in Octaves installation subdir! +Rem +Rem This trick finds the location where the batch file resides. +Rem Note: the result ends with a backslash +set OCT_HOME=%~dp0 + +Rem Set up PATH. Make sure the octave bin dir +Rem comes first. + +set PATH=%OCT_HOME%bin;%PATH% + +Rem Set up any environment vars we may need + +set TERM=cygwin + +Rem Check for args to see if we are told to start GUI +Rem with the --force-gui option or not (--no-gui) +Rem Otherwise assume starting as command line +set GUI_MODE=1 +:checkargs +if -%1-==-- goto noargs + if NOT %1==--force-gui goto notguiarg + set GUI_MODE=1 +:notguiarg + if NOT %1==--no-gui goto notnoguiarg + set GUI_MODE=0 +:notnoguiarg + shift + goto checkargs +:noargs + +Rem Start Octave (this detaches and immediately returns): +if %GUI_MODE%==1 ( +start octave-gui.exe %* +) else ( +start octave-cli.exe %* +) + +Rem Close the batch file's cmd.exe window +exit diff -r 023f392ce053 -r 70480095b6ed makeinst-script.sh --- a/makeinst-script.sh Tue Sep 23 13:47:30 2014 -0400 +++ b/makeinst-script.sh Thu Sep 25 14:15:41 2014 -0400 @@ -41,7 +41,7 @@ !define DESCRIPTION "GNU Octave is a high-level programming language, primarily intended for numerical computations." !define INSTALLER_FILES "../installer-files" !define INSTALLER_NAME "octave-$OCTAVE_VERSION-installer.exe" -!define MAIN_APP_EXE "octave-gui.exe" +!define MAIN_APP_EXE "octave.bat" !define INSTALL_TYPE "SetShellVarContext current" !define PRODUCT_ROOT_KEY "HKLM" !define PRODUCT_KEY "Software\\Octave-$VERSION" @@ -109,7 +109,8 @@ !insertmacro MUI_PAGE_INSTFILES -!define MUI_FINISHPAGE_RUN "\$INSTDIR\\bin\\\${MAIN_APP_EXE}" +!define MUI_FINISHPAGE_RUN "\$INSTDIR\\\${MAIN_APP_EXE}" +!define MUI_FINISHPAGE_RUN_PARAMETERS "--force-gui" !define MUI_FINISHPAGE_SHOWREADME "\$INSTDIR\\README.html" !insertmacro MUI_PAGE_FINISH @@ -215,6 +216,10 @@ SetOutPath "\$INSTDIR" File "$OCTAVE_SOURCE/README.html" + ; include the octave.bat file + SetOutPath "\$INSTDIR" + File "$OCTAVE_SOURCE/octave.bat" + ; distro files EOF @@ -257,8 +262,8 @@ CreateDirectory "\$SMPROGRAMS\\Octave-$VERSION" CreateShortCut "\$SMPROGRAMS\\Octave-$VERSION\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0 SetOutPath "%USERPROFILE%" - CreateShortCut "\$SMPROGRAMS\\Octave-$VERSION\\Octave (Command Line).lnk" "\$INSTDIR\\bin\\octave-cli.exe" "" "\$INSTDIR\\$ICON" 0 - CreateShortCut "\$SMPROGRAMS\\Octave-$VERSION\\Octave (Experimental GUI).lnk" "\$INSTDIR\\bin\\octave-gui.exe" "" "\$INSTDIR\\$ICON" 0 + CreateShortCut "\$SMPROGRAMS\\Octave-$VERSION\\Octave (Command Line).lnk" "\$INSTDIR\\octave.bat" "--no-gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED + CreateShortCut "\$SMPROGRAMS\\Octave-$VERSION\\Octave (Experimental GUI).lnk" "\$INSTDIR\\octave.bat" "--force-gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED SetOutPath "\$INSTDIR" EOF # if we have documentation files, create shortcuts @@ -276,8 +281,8 @@ \${If} \$InstallShortcuts == \${BST_CHECKED} SetOutPath "%USERPROFILE%" - CreateShortCut "\$desktop\\Octave-$VERSION (Command Line).lnk" "\$INSTDIR\\bin\\octave-cli.exe" "" "\$INSTDIR\\$ICON" 0 - CreateShortCut "\$desktop\\Octave-$VERSION (Experimental GUI).lnk" "\$INSTDIR\\bin\\octave-gui.exe" "" "\$INSTDIR\\$ICON" 0 + CreateShortCut "\$desktop\\Octave-$VERSION (Command Line).lnk" "\$INSTDIR\\octave.bat" "--no-gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED + CreateShortCut "\$desktop\\Octave-$VERSION (Experimental GUI).lnk" "\$INSTDIR\\octave.bat" "--force-gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED \${Endif} ; BLAS set up @@ -296,7 +301,7 @@ WriteRegStr HKCR "Octave.Document.$VERSION" "" "GNU Octave Script" WriteRegStr HKCR "Octave.Document.$VERSION\\DefaultIcon" "" "\$INSTDIR\\$ICON" ; document actions - WriteRegStr HKCR "Octave.Document.$VERSION\\shell\\open\\command" "" "\$\\"\$INSTDIR\\bin\\octave-gui.exe\$\\" --force-gui --persist --eval \$\\"edit '%1'\$\\"" + WriteRegStr HKCR "Octave.Document.$VERSION\\shell\\open\\command" "" "\$\\"\$INSTDIR\\octave.bat\$\\" --force-gui --persist --eval \$\\"edit '%1'\$\\"" \${If} \$RegisterOctaveFileType == \${BST_CHECKED} ReadRegStr \$0 HKCR ".m" ""