annotate lib/csharpcomp.c @ 7586:4a8b5467d8b2

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