annotate lib/csharpcomp.c @ 6761:14eb5491c867

* lib/wait-process.c, lib/wait-process.h, lib/csharpcomp.c, lib/execute.c, lib/javacomp.c: Back out previous change.
author Derek R. Price <derek@ximbiot.com>
date Wed, 26 Apr 2006 15:55:46 +0000
parents 5d118b8eb6a4
children c91111628d88
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5913
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Compile a C# program.
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 Copyright (C) 2003-2005 Free Software Foundation, Inc.
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Written by Bruno Haible <bruno@clisp.org>, 2003.
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 any later version.
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 along with this program; if not, write to the Free Software Foundation,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #ifdef HAVE_CONFIG_H
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 # include <config.h>
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #endif
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include <alloca.h>
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 /* Specification. */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #include "csharpcomp.h"
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include <errno.h>
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #include <stdio.h>
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 #include <stdlib.h>
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #include <string.h>
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 #include "execute.h"
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 #include "pipe.h"
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #include "wait-process.h"
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 #include "getline.h"
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 #include "sh-quote.h"
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 #include "safe-read.h"
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 #include "xallocsa.h"
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 #include "error.h"
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 #include "gettext.h"
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 #define _(str) gettext (str)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 /* Survey of C# compilers.
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 Program from
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 cscc pnet
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 mcs mono
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 csc sscli
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 We try the CIL interpreters in the following order:
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 1. "cscc", because it is a completely free system.
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 2. "mcs", because it is a free system but doesn't integrate so well
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 with Unix. (Command line options start with / instead of -. Errors go
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 to stdout instead of stderr. Source references are printed as
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 "file(lineno)" instead of "file:lineno:".)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 3. "csc", although it is not free, because it is a kind of "reference
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 implementation" of C#.
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 But the order can be changed through the --enable-csharp configuration
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 option.
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 static int
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 compile_csharp_using_pnet (const char * const *sources,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 unsigned int sources_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 const char * const *libdirs,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 unsigned int libdirs_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 const char * const *libraries,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 unsigned int libraries_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 const char *output_file, bool output_is_library,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 bool optimize, bool debug,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 bool verbose)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 static bool cscc_tested;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 static bool cscc_present;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 if (!cscc_tested)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 /* Test for presence of cscc:
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 "cscc --version >/dev/null 2>/dev/null" */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 char *argv[3];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 int exitstatus;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 argv[0] = "cscc";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 argv[1] = "--version";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 argv[2] = NULL;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 exitstatus = execute ("cscc", "cscc", argv, false, false, true, true,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 true, false);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 cscc_present = (exitstatus == 0);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 cscc_tested = true;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 if (cscc_present)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 unsigned int argc;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 char **argv;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 char **argp;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 int exitstatus;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 unsigned int i;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 argc =
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 1 + (output_is_library ? 1 : 0) + 2 + 2 * libdirs_count
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 + 2 * libraries_count + (optimize ? 1 : 0) + (debug ? 1 : 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 + sources_count;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 argv = (char **) xallocsa ((argc + 1) * sizeof (char *));
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 argp = argv;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 *argp++ = "cscc";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 if (output_is_library)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 *argp++ = "-shared";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 *argp++ = "-o";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 *argp++ = (char *) output_file;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 for (i = 0; i < libdirs_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 *argp++ = "-L";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 *argp++ = (char *) libdirs[i];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 for (i = 0; i < libraries_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 *argp++ = "-l";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 *argp++ = (char *) libraries[i];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 if (optimize)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 *argp++ = "-O";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 if (debug)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 *argp++ = "-g";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 for (i = 0; i < sources_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 const char *source_file = sources[i];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 if (strlen (source_file) >= 9
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 && memcmp (source_file + strlen (source_file) - 9, ".resource",
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 9) == 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 char *option = (char *) xallocsa (12 + strlen (source_file) + 1);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 memcpy (option, "-fresources=", 12);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 strcpy (option + 12, source_file);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 *argp++ = option;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 else
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143 *argp++ = (char *) source_file;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145 *argp = NULL;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146 /* Ensure argv length was correctly calculated. */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 if (argp - argv != argc)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148 abort ();
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 if (verbose)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152 char *command = shell_quote_argv (argv);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 printf ("%s\n", command);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 free (command);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 exitstatus = execute ("cscc", "cscc", argv, false, false, false, false,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 true, true);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160 for (i = 0; i < sources_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161 if (argv[argc - sources_count + i] != sources[i])
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162 freesa (argv[argc - sources_count + i]);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 freesa (argv);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 return (exitstatus != 0);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
167 else
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
168 return -1;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
169 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
170
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
171 static int
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
172 compile_csharp_using_mono (const char * const *sources,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
173 unsigned int sources_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
174 const char * const *libdirs,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
175 unsigned int libdirs_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
176 const char * const *libraries,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177 unsigned int libraries_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
178 const char *output_file, bool output_is_library,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
179 bool optimize, bool debug,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
180 bool verbose)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
181 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
182 static bool mcs_tested;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
183 static bool mcs_present;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
185 if (!mcs_tested)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
186 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
187 /* Test for presence of mcs:
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
188 "mcs --version >/dev/null 2>/dev/null" */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
189 char *argv[3];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
190 int exitstatus;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
191
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
192 argv[0] = "mcs";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
193 argv[1] = "--version";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
194 argv[2] = NULL;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
195 exitstatus = execute ("mcs", "mcs", argv, false, false, true, true, true,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
196 false);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197 mcs_present = (exitstatus == 0);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
198 mcs_tested = true;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
199 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201 if (mcs_present)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
202 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
203 unsigned int argc;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 char **argv;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
205 char **argp;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
206 pid_t child;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
207 int fd[1];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
208 FILE *fp;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
209 char *line[2];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
210 size_t linesize[2];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
211 size_t linelen[2];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
212 unsigned int l;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
213 int exitstatus;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
214 unsigned int i;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
215
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
216 argc =
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
217 1 + (output_is_library ? 1 : 0) + 2 + 2 * libdirs_count
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
218 + 2 * libraries_count + (debug ? 1 : 0) + sources_count;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
219 argv = (char **) xallocsa ((argc + 1) * sizeof (char *));
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
220
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
221 argp = argv;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
222 *argp++ = "mcs";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
223 if (output_is_library)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
224 *argp++ = "-target:library";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
225 *argp++ = "-o";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
226 *argp++ = (char *) output_file;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
227 for (i = 0; i < libdirs_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
228 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
229 *argp++ = "-L";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
230 *argp++ = (char *) libdirs[i];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
231 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
232 for (i = 0; i < libraries_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
233 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
234 *argp++ = "-r";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
235 *argp++ = (char *) libraries[i];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
236 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237 if (debug)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
238 *argp++ = "-g";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
239 for (i = 0; i < sources_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
240 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
241 const char *source_file = sources[i];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
242 if (strlen (source_file) >= 9
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
243 && memcmp (source_file + strlen (source_file) - 9, ".resource",
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
244 9) == 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
245 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
246 char *option = (char *) xallocsa (10 + strlen (source_file) + 1);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
247
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
248 memcpy (option, "-resource:", 10);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
249 strcpy (option + 10, source_file);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
250 *argp++ = option;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
251 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
252 else
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
253 *argp++ = (char *) source_file;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
254 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
255 *argp = NULL;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
256 /* Ensure argv length was correctly calculated. */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
257 if (argp - argv != argc)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
258 abort ();
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
259
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
260 if (verbose)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
261 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
262 char *command = shell_quote_argv (argv);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
263 printf ("%s\n", command);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
264 free (command);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
265 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
266
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
267 child = create_pipe_in ("mcs", "mcs", argv, NULL, false, true, true, fd);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
268
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 /* Read the subprocess output, copying it to stderr. Drop the last
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270 line if it starts with "Compilation succeeded". */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
271 fp = fdopen (fd[0], "r");
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
272 if (fp == NULL)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
273 error (EXIT_FAILURE, errno, _("fdopen() failed"));
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
274 line[0] = NULL; linesize[0] = 0;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
275 line[1] = NULL; linesize[1] = 0;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 l = 0;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277 for (;;)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
279 linelen[l] = getline (&line[l], &linesize[l], fp);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
280 if (linelen[l] == (size_t)(-1))
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
281 break;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
282 l = (l + 1) % 2;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
283 if (line[l] != NULL)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
284 fwrite (line[l], 1, linelen[l], stderr);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
285 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
286 l = (l + 1) % 2;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
287 if (line[l] != NULL
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
288 && !(linelen[l] >= 21
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
289 && memcmp (line[l], "Compilation succeeded", 21) == 0))
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
290 fwrite (line[l], 1, linelen[l], stderr);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
291 if (line[0] != NULL)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
292 free (line[0]);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
293 if (line[1] != NULL)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
294 free (line[1]);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
295 fclose (fp);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
296
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
297 /* Remove zombie process from process list, and retrieve exit status. */
6761
14eb5491c867 * lib/wait-process.c, lib/wait-process.h, lib/csharpcomp.c,
Derek R. Price <derek@ximbiot.com>
parents: 6759
diff changeset
298 exitstatus = wait_subprocess (child, "mcs", false, false, true, true);
5913
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
299
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
300 for (i = 0; i < sources_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
301 if (argv[argc - sources_count + i] != sources[i])
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
302 freesa (argv[argc - sources_count + i]);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
303 freesa (argv);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
304
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
305 return (exitstatus != 0);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
306 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
307 else
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
308 return -1;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
309 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
310
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
311 static int
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
312 compile_csharp_using_sscli (const char * const *sources,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
313 unsigned int sources_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
314 const char * const *libdirs,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
315 unsigned int libdirs_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
316 const char * const *libraries,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
317 unsigned int libraries_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
318 const char *output_file, bool output_is_library,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
319 bool optimize, bool debug,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
320 bool verbose)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
321 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
322 static bool csc_tested;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
323 static bool csc_present;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
324
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
325 if (!csc_tested)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
326 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
327 /* Test for presence of csc:
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
328 "csc -help >/dev/null 2>/dev/null \
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
329 && ! { csc -help 2>/dev/null | grep -i chicken > /dev/null; }" */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
330 char *argv[3];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
331 pid_t child;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
332 int fd[1];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
333 int exitstatus;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
334
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
335 argv[0] = "csc";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
336 argv[1] = "-help";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
337 argv[2] = NULL;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
338 child = create_pipe_in ("csc", "csc", argv, DEV_NULL, true, true, false,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
339 fd);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
340 csc_present = false;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
341 if (child != -1)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
342 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
343 /* Read the subprocess output, and test whether it contains the
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
344 string "chicken". */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
345 char c[7];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
346 size_t count = 0;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
347
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
348 csc_present = true;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
349 while (safe_read (fd[0], &c[count], 1) > 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
350 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
351 if (c[count] >= 'A' && c[count] <= 'Z')
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
352 c[count] += 'a' - 'A';
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
353 count++;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
354 if (count == 7)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
355 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
356 if (memcmp (c, "chicken", 7) == 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
357 csc_present = false;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
358 c[0] = c[1]; c[1] = c[2]; c[2] = c[3];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
359 c[3] = c[4]; c[4] = c[5]; c[5] = c[6];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
360 count--;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
361 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
362 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
363
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
364 close (fd[0]);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
365
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
366 /* Remove zombie process from process list, and retrieve exit
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
367 status. */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
368 exitstatus =
6761
14eb5491c867 * lib/wait-process.c, lib/wait-process.h, lib/csharpcomp.c,
Derek R. Price <derek@ximbiot.com>
parents: 6759
diff changeset
369 wait_subprocess (child, "csc", false, true, true, false);
5913
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
370 if (exitstatus != 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
371 csc_present = false;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
372 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
373 csc_tested = true;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
374 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
375
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
376 if (csc_present)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
377 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
378 unsigned int argc;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
379 char **argv;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
380 char **argp;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
381 int exitstatus;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
382 unsigned int i;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
383
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
384 argc =
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
385 1 + 1 + 1 + libdirs_count + libraries_count
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
386 + (optimize ? 1 : 0) + (debug ? 1 : 0) + sources_count;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
387 argv = (char **) xallocsa ((argc + 1) * sizeof (char *));
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
388
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
389 argp = argv;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
390 *argp++ = "csc";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
391 *argp++ = (output_is_library ? "-target:library" : "-target:exe");
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
392 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
393 char *option = (char *) xallocsa (5 + strlen (output_file) + 1);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
394 memcpy (option, "-out:", 5);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
395 strcpy (option + 5, output_file);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
396 *argp++ = option;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
397 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
398 for (i = 0; i < libdirs_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
399 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
400 char *option = (char *) xallocsa (5 + strlen (libdirs[i]) + 1);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
401 memcpy (option, "-lib:", 5);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
402 strcpy (option + 5, libdirs[i]);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
403 *argp++ = option;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
404 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
405 for (i = 0; i < libraries_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
406 {
6465
8fc725193330 Fix portability bug w.r.t. Microsoft's csc compiler.
Bruno Haible <bruno@clisp.org>
parents: 5913
diff changeset
407 char *option = (char *) xallocsa (11 + strlen (libraries[i]) + 4 + 1);
5913
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
408 memcpy (option, "-reference:", 11);
6465
8fc725193330 Fix portability bug w.r.t. Microsoft's csc compiler.
Bruno Haible <bruno@clisp.org>
parents: 5913
diff changeset
409 memcpy (option + 11, libraries[i], strlen (libraries[i]));
8fc725193330 Fix portability bug w.r.t. Microsoft's csc compiler.
Bruno Haible <bruno@clisp.org>
parents: 5913
diff changeset
410 strcpy (option + 11 + strlen (libraries[i]), ".dll");
5913
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
411 *argp++ = option;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
412 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
413 if (optimize)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
414 *argp++ = "-optimize+";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
415 if (debug)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
416 *argp++ = "-debug+";
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
417 for (i = 0; i < sources_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
418 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
419 const char *source_file = sources[i];
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
420 if (strlen (source_file) >= 9
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
421 && memcmp (source_file + strlen (source_file) - 9, ".resource",
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
422 9) == 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
423 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
424 char *option = (char *) xallocsa (10 + strlen (source_file) + 1);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
425
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
426 memcpy (option, "-resource:", 10);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
427 strcpy (option + 10, source_file);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
428 *argp++ = option;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
429 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
430 else
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
431 *argp++ = (char *) source_file;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
432 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
433 *argp = NULL;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
434 /* Ensure argv length was correctly calculated. */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
435 if (argp - argv != argc)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
436 abort ();
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
437
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
438 if (verbose)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
439 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
440 char *command = shell_quote_argv (argv);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
441 printf ("%s\n", command);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
442 free (command);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
443 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
444
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
445 exitstatus = execute ("csc", "csc", argv, false, false, false, false,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
446 true, true);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
447
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
448 for (i = 2; i < 3 + libdirs_count + libraries_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
449 freesa (argv[i]);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
450 for (i = 0; i < sources_count; i++)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
451 if (argv[argc - sources_count + i] != sources[i])
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
452 freesa (argv[argc - sources_count + i]);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
453 freesa (argv);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
454
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
455 return (exitstatus != 0);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
456 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
457 else
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
458 return -1;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
459 }
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
460
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
461 bool
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
462 compile_csharp_class (const char * const *sources,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
463 unsigned int sources_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
464 const char * const *libdirs,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
465 unsigned int libdirs_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
466 const char * const *libraries,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
467 unsigned int libraries_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
468 const char *output_file,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
469 bool optimize, bool debug,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
470 bool verbose)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
471 {
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
472 bool output_is_library =
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
473 (strlen (output_file) >= 4
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
474 && memcmp (output_file + strlen (output_file) - 4, ".dll", 4) == 0);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
475 int result;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
476
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
477 /* First try the C# implementation specified through --enable-csharp. */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
478 #if CSHARP_CHOICE_PNET
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
479 result = compile_csharp_using_pnet (sources, sources_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
480 libdirs, libdirs_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
481 libraries, libraries_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
482 output_file, output_is_library,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
483 optimize, debug, verbose);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
484 if (result >= 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
485 return (bool) result;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
486 #endif
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
487
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
488 #if CSHARP_CHOICE_MONO
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
489 result = compile_csharp_using_mono (sources, sources_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
490 libdirs, libdirs_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
491 libraries, libraries_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
492 output_file, output_is_library,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
493 optimize, debug, verbose);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
494 if (result >= 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
495 return (bool) result;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
496 #endif
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
497
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
498 /* Then try the remaining C# implementations in our standard order. */
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
499 #if !CSHARP_CHOICE_PNET
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
500 result = compile_csharp_using_pnet (sources, sources_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
501 libdirs, libdirs_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
502 libraries, libraries_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
503 output_file, output_is_library,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
504 optimize, debug, verbose);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
505 if (result >= 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
506 return (bool) result;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
507 #endif
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
508
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
509 #if !CSHARP_CHOICE_MONO
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
510 result = compile_csharp_using_mono (sources, sources_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
511 libdirs, libdirs_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
512 libraries, libraries_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
513 output_file, output_is_library,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
514 optimize, debug, verbose);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
515 if (result >= 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
516 return (bool) result;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
517 #endif
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
518
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
519 result = compile_csharp_using_sscli (sources, sources_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
520 libdirs, libdirs_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
521 libraries, libraries_count,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
522 output_file, output_is_library,
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
523 optimize, debug, verbose);
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
524 if (result >= 0)
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
525 return (bool) result;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
526
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
527 error (0, 0, _("C# compiler not found, try installing pnet"));
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
528 return true;
3b9706263c44 New module 'csharpcomp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
529 }