Mercurial > hg > octave-kai > gnulib-hg
annotate lib/csharpexec.c @ 17463:203c036eb0c6
bootstrap: support checksum utils without a --status option
* build-aux/bootstrap: Only look for sha1sum if updating po files.
Add sha1 to the list of supported checksum utils since it's now
supported through adjustments below.
(update_po_files): Remove the use of --status
in a way that will suppress all error messages, but since this is
only used to minimize updates, it shouldn't cause an issue.
Exit early if there is a problem updating the po file checksums.
(find_tool): Remove the check for --version support as this
is optional as per commit 86186b17. Don't even check for the
presence of the command as if that is needed, it's supported
through configuring prerequisites in bootstrap.conf.
Prompt that when a tool isn't found, one can define an environment
variable to add to the hardcoded search list.
author | Pádraig Brady <P@draigBrady.com> |
---|---|
date | Thu, 08 Aug 2013 11:08:49 +0100 (2013-08-08) |
parents | e542fd46ad6f |
children |
rev | line source |
---|---|
5902 | 1 /* Execute a C# program. |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16935
diff
changeset
|
2 Copyright (C) 2003-2013 Free Software Foundation, Inc. |
5902 | 3 Written by Bruno Haible <bruno@clisp.org>, 2003. |
4 | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8948
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
5902 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8948
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8948
diff
changeset
|
8 (at your option) any later version. |
5902 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8948
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
5902 | 17 |
7304
1c4ed7637c24
Include <config.h> unconditionally.
Bruno Haible <bruno@clisp.org>
parents:
7012
diff
changeset
|
18 #include <config.h> |
5902 | 19 #include <alloca.h> |
20 | |
21 /* Specification. */ | |
22 #include "csharpexec.h" | |
23 | |
24 #include <stdio.h> | |
25 #include <stdlib.h> | |
26 | |
27 #include "execute.h" | |
28 #include "sh-quote.h" | |
8948
a162347a0232
Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents:
7304
diff
changeset
|
29 #include "xmalloca.h" |
5902 | 30 #include "error.h" |
31 #include "gettext.h" | |
32 | |
33 /* Handling of MONO_PATH is just like Java CLASSPATH. */ | |
34 #define CLASSPATHVAR "MONO_PATH" | |
35 #define new_classpath new_monopath | |
36 #define set_classpath set_monopath | |
37 #define reset_classpath reset_monopath | |
38 #include "classpath.h" | |
39 #include "classpath.c" | |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
40 #undef reset_classpath |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
41 #undef set_classpath |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
42 #undef new_classpath |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
43 #undef CLASSPATHVAR |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
44 |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
45 /* Handling of clix' PATH variable is just like Java CLASSPATH. */ |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
46 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ |
16214
ec738d6aeef5
Talk about "native Windows API", not "Win32".
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
47 /* Native Windows, Cygwin */ |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
48 #define CLASSPATHVAR "PATH" |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
49 #elif defined __APPLE__ && defined __MACH__ |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16214
diff
changeset
|
50 /* Mac OS X */ |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
51 #define CLASSPATHVAR "DYLD_LIBRARY_PATH" |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
52 #else |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
53 /* Normal Unix */ |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
54 #define CLASSPATHVAR "LD_LIBRARY_PATH" |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
55 #endif |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
56 #define new_classpath new_clixpath |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
57 #define set_classpath set_clixpath |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
58 #define reset_classpath reset_clixpath |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
59 #include "classpath.h" |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
60 #include "classpath.c" |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
61 #undef reset_classpath |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
62 #undef set_classpath |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
63 #undef new_classpath |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
64 #undef CLASSPATHVAR |
5902 | 65 |
66 #define _(str) gettext (str) | |
67 | |
68 | |
69 /* Survey of CIL interpreters. | |
70 | |
71 Program from | |
72 | |
73 ilrun pnet | |
74 mono mono | |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
75 clix sscli |
5902 | 76 |
77 With Mono, the MONO_PATH is a colon separated list of pathnames. (On | |
78 Windows: semicolon separated list of pathnames.) | |
79 | |
80 We try the CIL interpreters in the following order: | |
81 1. "ilrun", because it is a completely free system. | |
82 2. "mono", because it is a partially free system but doesn't integrate | |
83 well with Unix. | |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
84 3. "clix", although it is not free, because it is a kind of "reference |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
85 implementation" of C#. |
5902 | 86 But the order can be changed through the --enable-csharp configuration |
87 option. | |
88 */ | |
89 | |
90 static int | |
91 execute_csharp_using_pnet (const char *assembly_path, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
92 const char * const *libdirs, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
93 unsigned int libdirs_count, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
94 const char * const *args, unsigned int nargs, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
95 bool verbose, bool quiet, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
96 execute_fn *executer, void *private_data) |
5902 | 97 { |
98 static bool ilrun_tested; | |
99 static bool ilrun_present; | |
100 | |
101 if (!ilrun_tested) | |
102 { | |
103 /* Test for presence of ilrun: | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
104 "ilrun --version >/dev/null 2>/dev/null" */ |
5902 | 105 char *argv[3]; |
106 int exitstatus; | |
107 | |
108 argv[0] = "ilrun"; | |
109 argv[1] = "--version"; | |
110 argv[2] = NULL; | |
111 exitstatus = execute ("ilrun", "ilrun", argv, false, false, true, true, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
112 true, false, NULL); |
5902 | 113 ilrun_present = (exitstatus == 0); |
114 ilrun_tested = true; | |
115 } | |
116 | |
117 if (ilrun_present) | |
118 { | |
119 unsigned int argc; | |
120 char **argv; | |
121 char **argp; | |
122 unsigned int i; | |
123 bool err; | |
124 | |
125 argc = 1 + 2 * libdirs_count + 1 + nargs; | |
8948
a162347a0232
Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents:
7304
diff
changeset
|
126 argv = (char **) xmalloca ((argc + 1) * sizeof (char *)); |
5902 | 127 |
128 argp = argv; | |
129 *argp++ = "ilrun"; | |
130 for (i = 0; i < libdirs_count; i++) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
131 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
132 *argp++ = "-L"; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
133 *argp++ = (char *) libdirs[i]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
134 } |
5902 | 135 *argp++ = (char *) assembly_path; |
136 for (i = 0; i < nargs; i++) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
137 *argp++ = (char *) args[i]; |
5902 | 138 *argp = NULL; |
139 /* Ensure argv length was correctly calculated. */ | |
140 if (argp - argv != argc) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
141 abort (); |
5902 | 142 |
143 if (verbose) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
144 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
145 char *command = shell_quote_argv (argv); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
146 printf ("%s\n", command); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
147 free (command); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
148 } |
5902 | 149 |
150 err = executer ("ilrun", "ilrun", argv, private_data); | |
151 | |
8948
a162347a0232
Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents:
7304
diff
changeset
|
152 freea (argv); |
5902 | 153 |
154 return err; | |
155 } | |
156 else | |
157 return -1; | |
158 } | |
159 | |
160 static int | |
161 execute_csharp_using_mono (const char *assembly_path, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
162 const char * const *libdirs, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
163 unsigned int libdirs_count, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
164 const char * const *args, unsigned int nargs, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
165 bool verbose, bool quiet, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
166 execute_fn *executer, void *private_data) |
5902 | 167 { |
168 static bool mono_tested; | |
169 static bool mono_present; | |
170 | |
171 if (!mono_tested) | |
172 { | |
173 /* Test for presence of mono: | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
174 "mono --version >/dev/null 2>/dev/null" */ |
5902 | 175 char *argv[3]; |
176 int exitstatus; | |
177 | |
178 argv[0] = "mono"; | |
179 argv[1] = "--version"; | |
180 argv[2] = NULL; | |
181 exitstatus = execute ("mono", "mono", argv, false, false, true, true, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
182 true, false, NULL); |
5902 | 183 mono_present = (exitstatus == 0); |
184 mono_tested = true; | |
185 } | |
186 | |
187 if (mono_present) | |
188 { | |
189 char *old_monopath; | |
8948
a162347a0232
Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents:
7304
diff
changeset
|
190 char **argv = (char **) xmalloca ((2 + nargs + 1) * sizeof (char *)); |
5902 | 191 unsigned int i; |
192 bool err; | |
193 | |
194 /* Set MONO_PATH. */ | |
195 old_monopath = set_monopath (libdirs, libdirs_count, false, verbose); | |
196 | |
197 argv[0] = "mono"; | |
198 argv[1] = (char *) assembly_path; | |
199 for (i = 0; i <= nargs; i++) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
200 argv[2 + i] = (char *) args[i]; |
5902 | 201 |
202 if (verbose) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
203 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
204 char *command = shell_quote_argv (argv); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
205 printf ("%s\n", command); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
206 free (command); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
207 } |
5902 | 208 |
209 err = executer ("mono", "mono", argv, private_data); | |
210 | |
211 /* Reset MONO_PATH. */ | |
212 reset_monopath (old_monopath); | |
213 | |
8948
a162347a0232
Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents:
7304
diff
changeset
|
214 freea (argv); |
5902 | 215 |
216 return err; | |
217 } | |
218 else | |
219 return -1; | |
220 } | |
221 | |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
222 static int |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
223 execute_csharp_using_sscli (const char *assembly_path, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
224 const char * const *libdirs, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
225 unsigned int libdirs_count, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
226 const char * const *args, unsigned int nargs, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
227 bool verbose, bool quiet, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
228 execute_fn *executer, void *private_data) |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
229 { |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
230 static bool clix_tested; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
231 static bool clix_present; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
232 |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
233 if (!clix_tested) |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
234 { |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
235 /* Test for presence of clix: |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
236 "clix >/dev/null 2>/dev/null ; test $? = 1" */ |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
237 char *argv[2]; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
238 int exitstatus; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
239 |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
240 argv[0] = "clix"; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
241 argv[1] = NULL; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
242 exitstatus = execute ("clix", "clix", argv, false, false, true, true, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
243 true, false, NULL); |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
244 clix_present = (exitstatus == 0 || exitstatus == 1); |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
245 clix_tested = true; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
246 } |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
247 |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
248 if (clix_present) |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
249 { |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
250 char *old_clixpath; |
8948
a162347a0232
Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents:
7304
diff
changeset
|
251 char **argv = (char **) xmalloca ((2 + nargs + 1) * sizeof (char *)); |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
252 unsigned int i; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
253 bool err; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
254 |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
255 /* Set clix' PATH variable. */ |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
256 old_clixpath = set_clixpath (libdirs, libdirs_count, false, verbose); |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
257 |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
258 argv[0] = "clix"; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
259 argv[1] = (char *) assembly_path; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
260 for (i = 0; i <= nargs; i++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
261 argv[2 + i] = (char *) args[i]; |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
262 |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
263 if (verbose) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
264 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
265 char *command = shell_quote_argv (argv); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
266 printf ("%s\n", command); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
267 free (command); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
268 } |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
269 |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
270 err = executer ("clix", "clix", argv, private_data); |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
271 |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
272 /* Reset clix' PATH variable. */ |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
273 reset_clixpath (old_clixpath); |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
274 |
8948
a162347a0232
Update after allocsa -> malloca renaming.
Bruno Haible <bruno@clisp.org>
parents:
7304
diff
changeset
|
275 freea (argv); |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
276 |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
277 return err; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
278 } |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
279 else |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
280 return -1; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
281 } |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
282 |
5902 | 283 bool |
284 execute_csharp_program (const char *assembly_path, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
285 const char * const *libdirs, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
286 unsigned int libdirs_count, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
287 const char * const *args, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
288 bool verbose, bool quiet, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
289 execute_fn *executer, void *private_data) |
5902 | 290 { |
291 unsigned int nargs; | |
292 int result; | |
293 | |
294 /* Count args. */ | |
295 { | |
296 const char * const *arg; | |
297 | |
298 for (nargs = 0, arg = args; *arg != NULL; nargs++, arg++) | |
299 ; | |
300 } | |
301 | |
302 /* First try the C# implementation specified through --enable-csharp. */ | |
303 #if CSHARP_CHOICE_PNET | |
304 result = execute_csharp_using_pnet (assembly_path, libdirs, libdirs_count, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
305 args, nargs, verbose, quiet, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
306 executer, private_data); |
5902 | 307 if (result >= 0) |
308 return (bool) result; | |
309 #endif | |
310 | |
311 #if CSHARP_CHOICE_MONO | |
312 result = execute_csharp_using_mono (assembly_path, libdirs, libdirs_count, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
313 args, nargs, verbose, quiet, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
314 executer, private_data); |
5902 | 315 if (result >= 0) |
316 return (bool) result; | |
317 #endif | |
318 | |
319 /* Then try the remaining C# implementations in our standard order. */ | |
320 #if !CSHARP_CHOICE_PNET | |
321 result = execute_csharp_using_pnet (assembly_path, libdirs, libdirs_count, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
322 args, nargs, verbose, quiet, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
323 executer, private_data); |
5902 | 324 if (result >= 0) |
325 return (bool) result; | |
326 #endif | |
327 | |
328 #if !CSHARP_CHOICE_MONO | |
329 result = execute_csharp_using_mono (assembly_path, libdirs, libdirs_count, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
330 args, nargs, verbose, quiet, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
331 executer, private_data); |
5902 | 332 if (result >= 0) |
333 return (bool) result; | |
334 #endif | |
335 | |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
336 result = execute_csharp_using_sscli (assembly_path, libdirs, libdirs_count, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
337 args, nargs, verbose, quiet, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10197
diff
changeset
|
338 executer, private_data); |
7012
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
339 if (result >= 0) |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
340 return (bool) result; |
268bfcec1a6f
Update csharpexec module from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
5902
diff
changeset
|
341 |
5902 | 342 if (!quiet) |
343 error (0, 0, _("C# virtual machine not found, try installing pnet")); | |
344 return true; | |
345 } |