Mercurial > mxe-octave
annotate installer-files/octave-launch.c @ 5978:1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
* installer-files/octave-launch.c (get_num_physical_cores): New function to get
number of physical processor cores.
(wmain): Set OPENBLAS_NUM_THREADS to number of physical processor cores for
performance.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Thu, 25 Nov 2021 18:37:52 +0100 |
parents | 49b3f6c6d255 |
children | 532c6ba0156f |
rev | line source |
---|---|
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 * Wrapper application to set octave env variables and then run octave |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 * |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
4 * Copyright (C) 2020-2021 John Donoghue <john.donoghue@ieee.org> |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 * |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify it under |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 * the terms of the GNU General Public License as published by the Free Software |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 * Foundation; either version 3 of the License, or (at your option) any later |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 * version. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 * |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, but WITHOUT |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 * details. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 * |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along with |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 * this program; if not, see <http: *www.gnu.org/licenses/>. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 #include <windows.h> |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 #include <shlwapi.h> |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
22 #include <strsafe.h> |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
24 static int ParentDir (wchar_t *dir) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
26 int len = lstrlenW (dir); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
27 while (len > 0 && dir[len] != L'\\') |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 len --; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 dir[len] = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 return len; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
5978
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
33 static wchar_t * FilePart (wchar_t *dir) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
35 int len = lstrlenW (dir); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
36 while (len > 0 && dir[len-1] != L'\\') |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 len --; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 return &dir[len]; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 |
5978
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
41 static size_t get_num_physical_cores (void) |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
42 { |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
43 DWORD length; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
44 PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX lpi; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
45 BOOL res; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
46 size_t num_physical_cores; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
47 size_t offset; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
48 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
49 length = 0; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
50 GetLogicalProcessorInformationEx (RelationProcessorCore, NULL, &length); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
51 if (GetLastError () != ERROR_INSUFFICIENT_BUFFER) |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
52 return 0; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
53 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
54 lpi = malloc (length); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
55 res = GetLogicalProcessorInformationEx (RelationProcessorCore, lpi, &length); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
56 if (! res) |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
57 { |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
58 free (lpi); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
59 return 0; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
60 } |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
61 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
62 num_physical_cores = 0; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
63 offset = 0; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
64 do |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
65 { |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
66 const PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX cur_lpi = |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
67 (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) (lpi + offset); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
68 offset += cur_lpi->Size; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
69 num_physical_cores++; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
70 } |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
71 while (offset < length); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
72 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
73 free (lpi); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
74 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
75 return num_physical_cores; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
76 } |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
77 |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 // Set up environment and launch octave.exe with appropriate |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 // arguments. NOTE: There are corresponding VBS and BAT script |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 // versions of this program so any changes here may need to be made in |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 // those scripts as well. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
83 int wmain (int argc, wchar_t **argv) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 PROCESS_INFORMATION pi; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 // FIXME: There are currently have no checks to ensure that the |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
88 // following fixed-size buffers are sufficiently large. MAX_PATH is |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
89 // 260 on Winndows by default. But a user might have increased that |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
90 // limit to 32767 characters by manually changing policy settings. |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
91 // Maybe it would be better if we used C++ and std::string objects? |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
92 // Note that the use of sizeof(path)-1 will fail if we switch to |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
93 // using |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 // |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
95 // wchar_t *path = (wchar_t *) malloc (...); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
96 // |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 // instead of literal character arrays. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
99 #define PATH_SZ 1024 |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
100 wchar_t msyspath[PATH_SZ]; |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
101 wchar_t rootpath[PATH_SZ]; |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
102 wchar_t path[PATH_SZ]; |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
103 wchar_t binpath[PATH_SZ]; |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 int gui_arg_found = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 int no_gui_arg_found = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 int no_gui_libs = 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 int i; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 /* get path of us which we will assume is the root of the install */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
112 DWORD nSize = GetModuleFileNameW (NULL, path, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 if (nSize) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
115 while (nSize > 0 && path[nSize] != L'\\') |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 nSize --; |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
117 path[nSize] = L'\0'; |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 |
5960
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
120 #ifdef NO_SHORT_PATH_NAMES |
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
121 StringCchCopyW (rootpath, PATH_SZ, path); |
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
122 #else |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
123 /* transform to short paths to work around issues with spaces in |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
124 paths */ |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
125 /* FIXME: This won't help on systems with de-activated short paths */ |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
126 nSize = GetShortPathNameW (path, rootpath, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 if (nSize == 0) |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
128 StringCchCopyW (rootpath, PATH_SZ, path); |
5960
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
129 #endif |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
131 SetEnvironmentVariableW (L"MXE_ROOT", rootpath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 /* get msys path and set env */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
135 StringCchCopyW (msyspath, PATH_SZ, rootpath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
137 StringCchCopyW (path, PATH_SZ, rootpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
138 StringCchCatW (path, PATH_SZ, L"\\mingw64\\bin\\octave.exe"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
139 if (PathFileExistsW (path)) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
141 SetEnvironmentVariableW (L"MSYSTEM", L"MINGW64"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
142 StringCchCatW (msyspath, PATH_SZ, L"\\usr"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
143 SetEnvironmentVariableW (L"MSYSPATH", msyspath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
145 StringCchCatW (msyspath, PATH_SZ, L"\\bin"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
147 StringCchCopyW (binpath, PATH_SZ, rootpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
148 StringCchCatW (binpath, PATH_SZ, L"\\mingw64\\bin"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 else |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
152 StringCchCopyW (path, PATH_SZ, rootpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
153 StringCchCatW (path, PATH_SZ, L"\\mingw32\\bin\\octave.exe"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
154 if (PathFileExistsW (path)) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
156 SetEnvironmentVariableW (L"MSYSTEM", L"MINGW32"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
157 StringCchCatW (msyspath, PATH_SZ, L"\\usr"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
158 SetEnvironmentVariableW (L"MSYSPATH", msyspath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
160 StringCchCatW (msyspath, PATH_SZ, L"\\bin"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
162 StringCchCopyW (binpath, PATH_SZ, rootpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
163 StringCchCatW (binpath, PATH_SZ, L"\\mingw32\\bin"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 else |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
167 SetEnvironmentVariableW (L"MSYSTEM", L"MSYS"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
168 SetEnvironmentVariableW (L"MSYSPATH", msyspath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
170 StringCchCatW (msyspath, PATH_SZ, L"\\bin"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
172 StringCchCopyW (binpath, PATH_SZ, rootpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
173 StringCchCatW (binpath, PATH_SZ, L"\\bin"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 /* binpath is to the octave bin dir so get the parent */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
178 StringCchCopyW (path, PATH_SZ, binpath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 ParentDir (path); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
181 #ifdef SHOW_PATHS |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
182 MessageBoxW (NULL, rootpath, L"octroot", MB_OK); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
183 MessageBoxW (NULL, path, L"octhome", MB_OK); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
184 MessageBoxW (NULL, binpath, L"octbin", MB_OK); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
185 MessageBoxW (NULL, msyspath, L"msysbin", MB_OK); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
186 #endif |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 /* qt paths |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 * either %OCT_HOME%\qt5\plugins |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 * or %OCT_HOME\plugins |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
192 nSize = lstrlenW (path); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
193 StringCchCatW (path, PATH_SZ, L"\\qt5\\plugins"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
194 SetEnvironmentVariableW (L"QT_PLUGIN_PATH", path); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
196 path[nSize] = L'\0'; |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 /* exe paths */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
200 #define PATHBUF_SZ 8096 |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
201 wchar_t pathbuffer[PATHBUF_SZ]; |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
202 wchar_t newpathbuffer[PATHBUF_SZ]; |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
204 nSize = GetEnvironmentVariableW (L"PATH", pathbuffer, PATHBUF_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 pathbuffer[nSize] = '\0'; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 /* set our paths first */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
208 StringCchCopyW (newpathbuffer, PATHBUF_SZ, binpath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
209 StringCchCatW (newpathbuffer, PATHBUF_SZ, L";"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
210 StringCchCatW (newpathbuffer, PATHBUF_SZ, msyspath); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
211 StringCchCatW (newpathbuffer, PATHBUF_SZ, L";"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
212 StringCchCatW (newpathbuffer, PATHBUF_SZ, pathbuffer); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
214 SetEnvironmentVariableW (L"PATH", newpathbuffer); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 /* other env */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
218 SetEnvironmentVariableW (L"TERM", L"cygwin"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
219 SetEnvironmentVariableW (L"GNUTERM", L"wxt"); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
220 SetEnvironmentVariableW (L"GS", L"gs.exe"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 /* home set */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
223 nSize = GetEnvironmentVariableW (L"HOME", path, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 if (nSize == 0 || path[0] == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
226 wchar_t newhome[PATH_SZ]; |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
228 nSize = GetEnvironmentVariableW (L"USERPROFILE", path, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 if (nSize == 0 || path[0] == 0) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 /* build dir from drive and path */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
232 wchar_t tmpbuff[PATH_SZ]; |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
233 nSize = GetEnvironmentVariableW (L"HOMEDRIVE", tmpbuff, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 if (nSize) |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
235 StringCchCopyW (path, PATH_SZ, tmpbuff); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 else |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 path[0] = '\0'; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
239 nSize = GetEnvironmentVariableW (L"HOMEPATH", tmpbuff, PATH_SZ-1); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
240 if (nSize) |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
241 StringCchCopyW (path, PATH_SZ, tmpbuff); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 |
5960
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
244 #ifdef NO_SHORT_PATH_NAMES |
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
245 StringCchCopyW (newhome, PATH_SZ, path); |
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
246 #else |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
247 /* transform to short paths to work around issues with spaces in |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
248 paths */ |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
249 /* FIXME: This won't help on systems with de-activated short |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
250 paths */ |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
251 nSize = GetShortPathNameW (path, newhome, PATH_SZ-1); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 if (nSize == 0) |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
254 StringCchCopyW (newhome, PATH_SZ, path); |
5960
49b3f6c6d255
octave-launch: Don't use short path names when building default-octave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5957
diff
changeset
|
255 #endif |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
257 SetEnvironmentVariableW (L"HOME", newhome); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 |
5978
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
260 /* set number of OpenBLAS threads */ |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
261 nSize = GetEnvironmentVariableW (L"OPENBLAS_NUM_THREADS", NULL, 0); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
262 if (nSize == 0) |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
263 { |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
264 /* Only set if it wasn't already set in the environment */ |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
265 size_t num_threads; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
266 num_threads = get_num_physical_cores (); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
267 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
268 if (num_threads > 0) |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
269 { |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
270 #define THREADS_SZ 64 |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
271 wchar_t buffer[THREADS_SZ]; |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
272 StringCchPrintfW (buffer, THREADS_SZ, L"%zu", num_threads); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
273 SetEnvironmentVariableW (L"OPENBLAS_NUM_THREADS", buffer); |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
274 } |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
275 } |
1569a1d140ae
octave-launch: Set number of OpenBLAS threads to number of cores (bug #61208).
Markus Mützel <markus.muetzel@gmx.de>
parents:
5960
diff
changeset
|
276 |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 /* check for gui mode */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 for (i = 1; i < argc; i++) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
280 if (StrCmpW (argv[i], L"--no-gui-libs") == 0) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 if (gui_arg_found) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 /* Inconsistent options. We can't start the GUI without gui libs. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 How should we fail? For now, --no-gui-libs will |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 override the other options. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
289 no_gui_libs = 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
290 } |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
291 else if (StrCmpW (argv[i], L"--gui") == 0 |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
292 || StrCmpW (argv[i], L"--force-gui") == 0) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
294 if (no_gui_libs) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
295 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 /* Inconsistent options. We can't start the GUI without gui libs. |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 How should we fail? For now, --no-gui-libs will |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 override the other options. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 gui_arg_found = 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 } |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
303 else if (StrCmpW (argv[i], L"--no-gui") == 0) |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 no_gui_arg_found = 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 /* NOTE: specifying both --no-gui and --gui is also an |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 inconsistent set of options but we leave it to octave.exe to |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 detect that. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
309 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
310 |
5957
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
311 #ifdef FIRST_TIME |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
312 { |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
313 /* change directory to USERPROFILE before starting Octave */ |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
314 wchar_t tmpbuff[PATH_SZ]; |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
315 nSize = GetEnvironmentVariableW (L"USERPROFILE", tmpbuff, PATH_SZ-1); |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
316 if (nSize) |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
317 StringCchCopyW (path, PATH_SZ, tmpbuff); |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
318 |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
319 SetCurrentDirectoryW (path); |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
320 } |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
321 #endif |
9cd5425b033b
octave-launch-firsttime: New launcher executable for starting Octave first time.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5956
diff
changeset
|
322 |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 /* set up process args and start it */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 STARTUPINFO si; |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
326 #define ARGBUF_SZ 4096 |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
327 wchar_t argbuffer[ARGBUF_SZ]; |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
329 ZeroMemory (&si, sizeof (si)); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
330 si.cb = sizeof (si); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
331 ZeroMemory (&pi, sizeof (pi)); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
332 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
333 StringCchCopyW (path, PATH_SZ, binpath); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
334 |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
335 StringCchCopyW (argbuffer, ARGBUF_SZ, L"octave.exe "); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
336 StringCchCatW (path, PATH_SZ, L"\\octave.exe"); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
338 if (! (no_gui_libs || no_gui_arg_found)) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
339 { |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 /* Unless --no-gui or --no-gui-libs is specified, we will use a GUI window. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
341 si.dwFlags = STARTF_USESHOWWINDOW; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
342 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
343 /* If none of the options --no-gui, --gui, or --force-gui |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
344 were specified, then we'll add --gui to start the gui as |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
345 most Windows users would expect. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
346 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 if (! gui_arg_found) |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
348 StringCchCatW (argbuffer, ARGBUF_SZ, L"--gui "); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
350 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
351 /* quote and append each arg */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
352 for (i = 1; i < argc; i++) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
353 { |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
354 StringCchCatW (argbuffer, ARGBUF_SZ, L"\""); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
355 StringCchCatW (argbuffer, ARGBUF_SZ, argv[i]); |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
356 StringCchCatW (argbuffer, ARGBUF_SZ, L"\" "); |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
357 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
358 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 /* Start the child process */ |
5956
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
360 int status = CreateProcessW (path, // Module name |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
361 argbuffer, // Command line |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
362 NULL, // Process handle not inheritable |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
363 NULL, // Thread handle not inheritable |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
364 FALSE, // Set handle inheritance to FALSE |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
365 0, // No creation flags |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
366 NULL, // Use parent's environment block |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
367 NULL, // Use parent's starting directory |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
368 &si, // Pointer to STARTUPINFO |
b8e9589b7794
octave-launch: Use Unicode strings in Windows API functions.
Markus Mützel <markus.muetzel@gmx.de>
parents:
5955
diff
changeset
|
369 &pi); // Pointer to PROCESS_INFORMATION |
5955
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
370 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
371 if (! status) |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
372 return 1; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
373 } |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
374 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
375 /* Wait until child process exits. */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 WaitForSingleObject (pi.hProcess, INFINITE); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
377 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
378 /* Close process and thread handles */ |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
379 CloseHandle (pi.hProcess); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
380 CloseHandle (pi.hThread); |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
381 |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
382 return 0; |
f42752ce0ae3
new octave-launcher.exe program from John Donoghue
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
383 } |