annotate installer-files/octave.bat @ 4645:56a712112482

octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419). * octave.bat: Set QT_PLUGIN_PATH to avoid segfault. Use if/else/if tree to parse arguments rather than more complicated strategy with goto statements. Indent code for clarity.
author Rik <rik@octave.org>
date Tue, 27 Mar 2018 16:56:01 -0700
parents b0cb0218813c
children 89a9c9a80669
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
1 @echo off
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
2 Rem Find Octave's install directory through cmd.exe variables.
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
3 Rem This batch file should reside in Octaves installation subdir!
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
4 Rem
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
5 Rem This trick finds the location where the batch file resides.
4645
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
6 Rem Note: the result ends with a backslash.
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
7 set OCT_HOME=%~dp0
4645
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
8 Rem Convert to 8.3 format so we don't have to worry about spaces.
4258
a45374f7d9a3 Use 8.3 format for octave path
John D
parents: 4222
diff changeset
9 for %%I in ("%OCT_HOME%") do set OCT_HOME=%%~sI
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
10
4645
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
11 Rem Set up PATH. Make sure the octave bin dir comes first.
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
12
4222
44b1a9b2193e qt5: add initial qt5 to mxe-octave, based on mxe.cc
John D
parents: 4183
diff changeset
13 set PATH=%OCT_HOME%qt5\bin;%OCT_HOME%bin;%PATH%
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
14
4645
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
15 Rem Set up any environment vars we may need.
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
16
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
17 set TERM=cygwin
4472
0fdeee4cfe11 gnuplot: enable Qt terminal and set default to wxt
Mike Miller <mtmiller@octave.org>
parents: 4276
diff changeset
18 set GNUTERM=wxt
4183
cc549d1865cb pstoedit: use GS environment var if set in windows
John D
parents: 4153
diff changeset
19 set GS=gs.exe
4645
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
20
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
21 Rem QT_PLUGIN_PATH must be set to avoid segfault (bug #53419).
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
22 IF EXIST "%OCT_HOME%\qt5\bin\" (
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
23 set QT_PLUGIN_PATH=%OCT_HOME%\qt5\plugins
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
24 ) ELSE (
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
25 set QT_PLUGIN_PATH=%OCT_HOME%\plugins
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
26 )
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
27
4276
b73fe78f73c3 If home not set, set it to userprofile
John D
parents: 4258
diff changeset
28 Rem set home if not already set
b73fe78f73c3 If home not set, set it to userprofile
John D
parents: 4258
diff changeset
29 if "%HOME%"=="" set HOME=%USERPROFILE%
b73fe78f73c3 If home not set, set it to userprofile
John D
parents: 4258
diff changeset
30 if "%HOME%"=="" set HOME=%HOMEDRIVE%%HOMEPATH%
b73fe78f73c3 If home not set, set it to userprofile
John D
parents: 4258
diff changeset
31 Rem set HOME to 8.3 format
b73fe78f73c3 If home not set, set it to userprofile
John D
parents: 4258
diff changeset
32 for %%I in ("%HOME%") do set HOME=%%~sI
b73fe78f73c3 If home not set, set it to userprofile
John D
parents: 4258
diff changeset
33
4645
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
34 Rem Check for args to see if we are told to start GUI (--gui, --force-gui)
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
35 Rem or not (--no-gui).
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
36 Rem If nothing is specified, start the GUI.
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
37 set GUI_MODE=1
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
38 :checkargs
4645
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
39 if -%1-==-- goto args_done
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
40
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
41 if %1==--gui (
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
42 set GUI_MODE=1
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
43 ) else (
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
44 if %1==--force-gui (
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
45 set GUI_MODE=1
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
46 ) else (
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
47 if %1==--no-gui (
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
48 set GUI_MODE=0
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
49 )))
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
50
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
51 Rem move to next argument and continue processing
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
52 shift
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
53 goto checkargs
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
54
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
55 :args_done
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
56
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
57 Rem Start Octave (this detaches and immediately returns):
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
58 if %GUI_MODE%==1 (
4645
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
59 start octave-gui.exe --gui %*
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
60 ) else (
4645
56a712112482 octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419).
Rik <rik@octave.org>
parents: 4643
diff changeset
61 start octave-cli.exe %*
3717
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
62 )
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
63
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
64 Rem Close the batch file's cmd.exe window
70480095b6ed Use a bat file to run octave in windows (Bug #43164)
John Donoghue
parents:
diff changeset
65 exit