Mercurial > projects > ddmd
annotate dmd/Util.d @ 16:5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Sun, 04 Apr 2010 22:41:11 +0100 |
parents | 2cc604139636 |
children | fd4acc376c45 |
rev | line source |
---|---|
0 | 1 module dmd.Util; |
2 | |
3 import dmd.Loc; | |
4 import dmd.Library; | |
5 import dmd.File; | |
6 import dmd.String; | |
7 import dmd.OutBuffer; | |
8 import dmd.FileName; | |
9 import dmd.Global; | |
10 import dmd.PREC; | |
11 import dmd.TOK; | |
12 | |
13 import std.process : getenv; | |
14 import std.c.string; | |
15 import std.stdio : writef, writefln, write; | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
16 version (Windows) |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
17 { |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
18 import std.c.process : spawnl, spawnlp; |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
19 } |
0 | 20 import core.stdc.stdlib; |
21 import core.stdc.ctype; | |
22 import core.stdc.stdarg; | |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
23 public import core.stdc.stdio; |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
24 version (Bug4054) import core.memory; |
0 | 25 |
26 extern(C) int putenv(char*); | |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
27 /+version (LOG) |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
28 { |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
29 static if( !is(typeof(printf)) ) |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
30 extern (C) int printf(const char*,...); |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
31 }+/ |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
32 //version = LOG; |
0 | 33 |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
34 version (TARGET_OSX) |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
35 { |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
36 version = TARGET_FOS; // FreeBSD, OS X, Solaris |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
37 } |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
38 version (TARGET_FREEBSD) |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
39 { |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
40 version = TARGET_FOS; // FreeBSD, OS X, Solaris |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
41 } |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
42 version (TARGET_SOLARIS) |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
43 { |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
44 version = TARGET_FOS; // FreeBSD, OS X, Solaris |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
45 } |
0 | 46 |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
47 version (POSIX) |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
48 { |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
49 import dmd.Array; |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
50 import dmd.Gnuc; |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
51 import core.sys.posix.stdlib; |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
52 version (TARGET_FOS) import core.stdc.limits; |
0 | 53 } |
54 | |
55 enum MAX_PATH = 256; /// | |
56 | |
57 version (Windows) { | |
58 import core.sys.windows.windows : GetModuleFileNameA; | |
59 } | |
60 | |
61 string fromStringz(const(char)* s) | |
62 { | |
63 return s[0..strlen(s)].idup; | |
64 } | |
65 | |
66 void warning(T...)(string format, T t) | |
67 { | |
68 assert(false); | |
69 } | |
70 | |
71 void warning(T...)(Loc loc, string format, T t) | |
72 { | |
73 assert(false); | |
74 } | |
75 | |
76 void error(T...)(Loc loc, string format, T t) | |
77 { | |
78 if (!global.gag) | |
79 { | |
80 string p = loc.toChars(); | |
81 | |
82 if (p.length != 0) | |
83 writef("%s: ", p); | |
84 | |
85 write("Error: "); | |
86 writefln(format, t); | |
87 | |
88 //halt(); | |
89 } | |
90 global.errors++; | |
91 } | |
92 | |
93 char* strupr(char* s) | |
94 { | |
95 char* t = s; | |
96 | |
97 while (*s) | |
98 { | |
99 *s = cast(char)toupper(*s); | |
100 s++; | |
101 } | |
102 | |
103 return t; | |
104 } | |
105 | |
106 char[] skipspace(char[] p) | |
107 { | |
108 foreach (i, c; p) { | |
109 if (!isspace(c)) { | |
110 return p[i..$]; | |
111 } | |
112 } | |
113 | |
114 return null; | |
115 } | |
116 | |
117 char* skipspace(char* p) | |
118 { | |
119 while (isspace(*p)) | |
120 p++; | |
121 | |
122 return p; | |
123 } | |
124 | |
125 void inifile(string argv0, string inifile) | |
126 { | |
127 char *path; // need path for @P macro | |
128 string filename; | |
129 int i; | |
130 int k; | |
131 int envsection = 0; | |
132 | |
133 version (LOG) { | |
134 writef("inifile(argv0 = '%s', inifile = '%s')\n", argv0, inifile); | |
135 } | |
136 if (FileName.absolute(inifile)) { | |
137 filename = inifile; | |
138 } else { | |
139 /* Look for inifile in the following sequence of places: | |
140 * o current directory | |
141 * o home directory | |
142 * o directory off of argv0 | |
143 * o /etc/ | |
144 */ | |
145 if (FileName.exists(inifile)) { | |
146 filename = inifile; | |
147 } else { | |
148 filename = FileName.combine(getenv("HOME"), inifile); | |
149 if (!FileName.exists(filename)) { | |
150 version (_WIN32) { // This fix by Tim Matthews | |
151 char resolved_name_b[MAX_PATH + 1]; | |
152 auto resolved_name = resolved_name_b[].idup; | |
153 if (GetModuleFileNameA(null, resolved_name_b.ptr, MAX_PATH + 1) && FileName.exists(resolved_name)) | |
154 { | |
155 filename = FileName.replaceName(resolved_name, inifile); | |
156 if (FileName.exists(filename)) { | |
157 goto Ldone; | |
158 } | |
159 } | |
160 } | |
161 filename = FileName.replaceName(argv0, inifile); | |
162 if (!FileName.exists(filename)) { | |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
163 version (POSIX) { /// linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
164 version (POSIX) { /// __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 // This fix by Thomas Kuehne |
0 | 165 /* argv0 might be a symbolic link, |
166 * so try again looking past it to the real path | |
167 */ | |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
168 version (TARGET_FOS) {/// #if __APPLE__ || __FreeBSD__ || __sun&&__SVR4 |
0 | 169 char resolved_name[PATH_MAX + 1]; |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
170 char* real_argv0 = realpath(toStringz(argv0), resolved_name); |
0 | 171 } else { |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
172 char* real_argv0 = realpath(toStringz(argv0), null); |
0 | 173 } |
174 //printf("argv0 = %s, real_argv0 = %p\n", argv0, real_argv0); | |
175 if (real_argv0) { | |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
176 filename = FileName.replaceName(fromStringz(real_argv0), inifile); |
0 | 177 version (linux) { |
2 | 178 ///free(real_argv0); |
0 | 179 } |
180 if (FileName.exists(filename)) { | |
181 goto Ldone; | |
182 } | |
183 } | |
184 } else { | |
185 static assert (false, "use of glibc non-standard extension realpath(char*, null)"); | |
186 } | |
187 if (true) { | |
188 // Search PATH for argv0 | |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
189 const(char)* p = toStringz(getenv("PATH")); |
0 | 190 version (LOG) { |
191 writef("\tPATH='%s'\n", p); | |
192 } | |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
193 auto paths = FileName.splitPath(fromStringz(p)); |
0 | 194 filename = FileName.searchPath(paths, argv0, 0); |
195 if (!filename) { | |
196 goto Letc; // argv0 not found on path | |
197 } | |
198 | |
199 filename = FileName.replaceName(filename, inifile); | |
200 if (FileName.exists(filename)) { | |
201 goto Ldone; | |
202 } | |
203 } | |
204 } | |
205 // Search /etc/ for inifile | |
206 Letc: | |
207 filename = FileName.combine("/etc/", inifile); | |
208 | |
209 Ldone: | |
210 ; | |
211 } | |
212 } | |
213 } | |
214 } | |
215 | |
216 path = cast(char*)toStringz(FileName.path(filename)); | |
217 | |
218 version (LOG) { | |
219 writef("\tpath = '%s', filename = '%s'\n", fromStringz(path), filename); | |
220 } | |
221 | |
222 scope File file = new File(filename); | |
223 | |
224 if (file.read()) { | |
225 return; // error reading file | |
226 } | |
227 | |
228 scope OutBuffer buf = new OutBuffer(); | |
229 | |
230 // Parse into lines | |
231 int eof = 0; | |
232 for (i = 0; i < file.len && !eof; i++) | |
233 { | |
234 int linestart = i; | |
235 | |
236 for (; i < file.len; i++) | |
237 { | |
238 switch (file.buffer[i]) | |
239 { | |
240 case '\r': | |
241 break; | |
242 | |
243 case '\n': | |
244 // Skip if it was preceded by '\r' | |
245 if (i && file.buffer[i - 1] == '\r') | |
246 goto Lskip; | |
247 break; | |
248 | |
249 case 0: | |
250 case 0x1A: | |
251 eof = 1; | |
252 break; | |
253 | |
254 default: | |
255 continue; | |
256 } | |
257 break; | |
258 } | |
259 | |
260 // The line is file.buffer[linestart..i] | |
261 char *line; | |
262 int len; | |
263 char *p; | |
264 char* pn; | |
265 | |
266 line = cast(char*)&file.buffer[linestart]; | |
267 len = i - linestart; | |
268 | |
269 buf.reset(); | |
270 | |
271 // First, expand the macros. | |
272 // Macros are bracketed by % characters. | |
273 | |
274 for (k = 0; k < len; k++) | |
275 { | |
276 if (line[k] == '%') | |
277 { | |
278 int j; | |
279 | |
280 for (j = k + 1; j < len; j++) | |
281 { | |
282 if (line[j] == '%') | |
283 { | |
284 if (j - k == 3 && memicmp(&line[k + 1], "@P", 2) == 0) | |
285 { | |
286 // %@P% is special meaning the path to the .ini file | |
287 p = path; | |
288 if (!*p) | |
289 p = cast(char*)"."; | |
290 } | |
291 else | |
292 { | |
293 int l = j - k; | |
294 char tmp[10]; // big enough most of the time | |
295 | |
296 if (l <= tmp.sizeof) | |
297 p = tmp.ptr; | |
298 else | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
299 { |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
300 version (Bug4054) |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
301 p = cast(char*)GC.malloc(l); |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
302 else |
0 | 303 p = cast(char*)alloca(l); |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
304 } |
0 | 305 l--; |
306 memcpy(p, &line[k + 1], l); | |
307 p[l] = 0; | |
308 strupr(p); | |
309 p = core.stdc.stdlib.getenv(p); | |
310 if (!p) | |
311 p = cast(char*)""; | |
312 } | |
313 buf.writestring(p[0..strlen(p)]); /// | |
314 k = j; | |
315 goto L1; | |
316 } | |
317 } | |
318 } | |
319 buf.writeByte(line[k]); | |
320 L1: | |
321 ; | |
322 } | |
323 | |
324 // Remove trailing spaces | |
325 while (buf.offset && isspace(buf.data[buf.offset - 1])) | |
326 buf.offset--; | |
327 | |
328 char[] pp = buf.getString(); | |
329 | |
330 // The expanded line is in p. | |
331 // Now parse it for meaning. | |
332 | |
333 pp = skipspace(pp); | |
334 if (pp.length != 0) { | |
335 switch (pp[0]) | |
336 { | |
337 case ';': // comment | |
338 break; | |
339 | |
340 case '[': // look for [Environment] | |
341 pp = skipspace(pp[1..$]); | |
342 for (pn = pp.ptr; isalnum(*pn); pn++) { | |
343 ; | |
344 } | |
345 | |
346 if (pn - pp.ptr == 11 && | |
347 memicmp(pp.ptr, "Environment", 11) == 0 && | |
348 *skipspace(pn) == ']' | |
349 ) | |
350 envsection = 1; | |
351 else | |
352 envsection = 0; | |
353 break; | |
354 | |
355 default: | |
356 if (envsection) | |
357 { | |
358 pn = pp.ptr; | |
359 | |
360 // Convert name to upper case; | |
361 // remove spaces bracketing = | |
362 auto p2 = pn; | |
363 for ( ; *p2; p2++) | |
364 { if (islower(*p2)) | |
365 *p2 &= ~0x20; | |
366 else if (isspace(*p)) | |
367 memmove(p2, p2 + 1, strlen(p2)); | |
368 else if (*p2 == '=') | |
369 { | |
370 p2++; | |
371 while (isspace(*p2)) | |
372 memmove(p2, p2 + 1, strlen(p2)); | |
373 break; | |
374 } | |
375 } | |
376 | |
377 //putenv(pn); | |
378 putenv(cast(char*)toStringz(pp)); | |
379 | |
380 version (LOG) { | |
381 writef("\tputenv('%s')\n", pn[0..strlen(pn)]); | |
382 //printf("getenv(\"TEST\") = '%s'\n",getenv("TEST")); | |
383 } | |
384 } | |
385 break; | |
386 } | |
387 } | |
388 | |
389 Lskip: | |
390 ; | |
391 } | |
392 } | |
393 | |
394 ///int response_expand(int *pargc, char ***pargv); | |
395 void browse(const(char)* url) | |
396 { | |
397 assert(false); | |
398 } | |
399 | |
400 string[] getenv_setargv(string envvar, string[] args) | |
401 { | |
402 char *p; | |
403 | |
404 string[] argv = args.dup; | |
405 int argc = args.length; | |
406 | |
407 int wildcard; // do wildcard expansion | |
408 int instring; | |
409 int slash; | |
410 char c; | |
411 int j; | |
412 | |
413 string ienv = getenv(envvar); | |
414 if (ienv is null) | |
415 return args; | |
416 | |
417 char[] env = ienv.dup; // create our own writable copy | |
418 | |
419 j = 1; // leave argv[0] alone | |
420 char* e = env.ptr; | |
421 while (1) | |
422 { | |
423 wildcard = 1; | |
424 switch (*e) | |
425 { | |
426 case ' ': | |
427 case '\t': | |
428 e++; | |
429 break; | |
430 | |
431 case 0: | |
432 goto Ldone; | |
433 | |
434 case '"': | |
435 wildcard = 0; | |
436 default: | |
437 argv ~= assumeUnique(e[0..strlen(e)]); // append | |
438 //argv.insert(j, env); // insert at position j | |
439 j++; | |
440 argc++; | |
441 p = e; | |
442 slash = 0; | |
443 instring = 0; | |
444 c = 0; | |
445 | |
446 char* ecopy = e; | |
447 | |
448 while (1) | |
449 { | |
450 c = *e++; | |
451 switch (c) | |
452 { | |
453 case '"': | |
454 p -= (slash >> 1); | |
455 if (slash & 1) | |
456 { | |
457 p--; | |
458 goto Laddc; | |
459 } | |
460 instring ^= 1; | |
461 slash = 0; | |
462 continue; | |
463 | |
464 case '\\': | |
465 slash++; | |
466 *p++ = c; | |
467 continue; | |
468 | |
469 case ' ': | |
470 case '\t': | |
471 if (instring) | |
472 goto Laddc; | |
473 case 0: | |
474 *p = 0; | |
475 if (argv.length != 0) { | |
476 argv[$-1].length = p - argv[$-1].ptr; | |
477 } | |
478 //if (wildcard) | |
479 //wildcardexpand(); // not implemented | |
480 if (c == 0) goto Ldone; | |
481 break; | |
482 | |
483 default: | |
484 Laddc: | |
485 slash = 0; | |
486 *p++ = c; | |
487 continue; | |
488 } | |
489 break; | |
490 } | |
491 } | |
492 } | |
493 | |
494 Ldone: | |
495 return argv; | |
496 } | |
497 | |
498 void error(T...)(string format, T t) | |
499 { | |
500 writefln(format, t); | |
501 exit(EXIT_FAILURE); | |
502 } | |
503 | |
504 void usage() | |
505 { | |
506 writef("Digital Mars D Compiler %s\n%s %s\n", global.version_, global.copyright, global.written); | |
507 writef( | |
508 "Documentation: http://www.digitalmars.com/d/2.0/index.html\n" | |
509 "Usage:\n" | |
510 " dmd files.d ... { -switch }\n" | |
511 "\n" | |
512 " files.d D source files\n" | |
513 " @cmdfile read arguments from cmdfile\n" | |
514 " -c do not link\n" | |
515 " -cov do code coverage analysis\n" | |
516 " -D generate documentation\n" | |
517 " -Dddocdir write documentation file to docdir directory\n" | |
518 " -Dffilename write documentation file to filename\n" | |
519 " -d allow deprecated features\n" | |
520 " -debug compile in debug code\n" | |
521 " -debug=level compile in debug code <= level\n" | |
522 " -debug=ident compile in debug code identified by ident\n" | |
523 " -debuglib=name set symbolic debug library to name\n" | |
524 " -defaultlib=name set default library to name\n" | |
525 " -deps=filename write module dependencies to filename\n" | |
526 " -g add symbolic debug info\n" | |
527 " -gc add symbolic debug info, pretend to be C\n" | |
528 " -H generate 'header' file\n" | |
529 " -Hdhdrdir write 'header' file to hdrdir directory\n" | |
530 " -Hffilename write 'header' file to filename\n" | |
531 " --help print help\n" | |
532 " -Ipath where to look for imports\n" | |
533 " -ignore ignore unsupported pragmas\n" | |
534 " -inline do function inlining\n" | |
535 " -Jpath where to look for string imports\n" | |
536 " -Llinkerflag pass linkerflag to link\n" | |
537 " -lib generate library rather than object files\n" | |
538 " -man open web browser on manual page\n" | |
539 " -nofloat do not emit reference to floating point\n" | |
540 " -O optimize\n" | |
541 " -o- do not write object file\n" | |
542 " -odobjdir write object & library files to directory objdir\n" | |
543 " -offilename name output file to filename\n" | |
544 " -op do not strip paths from source file\n" | |
545 " -profile profile runtime performance of generated code\n" | |
546 " -quiet suppress unnecessary messages\n" | |
547 " -release compile release version\n" | |
548 " -run srcfile args... run resulting program, passing args\n" | |
549 " -safe safe memory model\n" | |
550 " -unittest compile in unit tests\n" | |
551 " -v verbose\n" | |
552 " -version=level compile in version code >= level\n" | |
553 " -version=ident compile in version code identified by ident\n" | |
554 " -vtls list all variables going into thread local storage\n" | |
555 " -w enable warnings\n" | |
556 ); | |
557 } | |
558 | |
559 void fatal() | |
560 { | |
561 static if (false) { | |
562 halt(); | |
563 } else { | |
564 exit(EXIT_FAILURE); | |
565 } | |
566 } | |
567 | |
568 void halt() | |
569 { | |
570 assert(false); | |
571 } | |
572 | |
573 void initPrecedence() | |
574 { | |
575 precedence[TOK.TOKdotvar] = PREC.PREC_primary; | |
576 precedence[TOK.TOKimport] = PREC.PREC_primary; | |
577 precedence[TOK.TOKidentifier] = PREC.PREC_primary; | |
578 precedence[TOK.TOKthis] = PREC.PREC_primary; | |
579 precedence[TOK.TOKsuper] = PREC.PREC_primary; | |
580 precedence[TOK.TOKint64] = PREC.PREC_primary; | |
581 precedence[TOK.TOKfloat64] = PREC.PREC_primary; | |
582 precedence[TOK.TOKnull] = PREC.PREC_primary; | |
583 precedence[TOK.TOKstring] = PREC.PREC_primary; | |
584 precedence[TOK.TOKarrayliteral] = PREC.PREC_primary; | |
585 precedence[TOK.TOKtypeid] = PREC.PREC_primary; | |
586 precedence[TOK.TOKis] = PREC.PREC_primary; | |
587 precedence[TOK.TOKassert] = PREC.PREC_primary; | |
588 precedence[TOK.TOKfunction] = PREC.PREC_primary; | |
589 precedence[TOK.TOKvar] = PREC.PREC_primary; | |
590 version (DMDV2) { | |
591 precedence[TOK.TOKdefault] = PREC.PREC_primary; | |
592 } | |
593 | |
594 // post | |
595 precedence[TOK.TOKdotti] = PREC.PREC_primary; | |
596 precedence[TOK.TOKdot] = PREC.PREC_primary; | |
597 // precedence[TOK.TOKarrow] = PREC.PREC_primary; | |
598 precedence[TOK.TOKplusplus] = PREC.PREC_primary; | |
599 precedence[TOK.TOKminusminus] = PREC.PREC_primary; | |
600 precedence[TOK.TOKcall] = PREC.PREC_primary; | |
601 precedence[TOK.TOKslice] = PREC.PREC_primary; | |
602 precedence[TOK.TOKarray] = PREC.PREC_primary; | |
603 | |
604 precedence[TOK.TOKaddress] = PREC.PREC_unary; | |
605 precedence[TOK.TOKstar] = PREC.PREC_unary; | |
606 precedence[TOK.TOKneg] = PREC.PREC_unary; | |
607 precedence[TOK.TOKuadd] = PREC.PREC_unary; | |
608 precedence[TOK.TOKnot] = PREC.PREC_unary; | |
609 precedence[TOK.TOKtobool] = PREC.PREC_add; | |
610 precedence[TOK.TOKtilde] = PREC.PREC_unary; | |
611 precedence[TOK.TOKdelete] = PREC.PREC_unary; | |
612 precedence[TOK.TOKnew] = PREC.PREC_unary; | |
613 precedence[TOK.TOKcast] = PREC.PREC_unary; | |
614 | |
615 precedence[TOK.TOKmul] = PREC.PREC_mul; | |
616 precedence[TOK.TOKdiv] = PREC.PREC_mul; | |
617 precedence[TOK.TOKmod] = PREC.PREC_mul; | |
618 | |
619 precedence[TOK.TOKadd] = PREC.PREC_add; | |
620 precedence[TOK.TOKmin] = PREC.PREC_add; | |
621 precedence[TOK.TOKcat] = PREC.PREC_add; | |
622 | |
623 precedence[TOK.TOKshl] = PREC.PREC_shift; | |
624 precedence[TOK.TOKshr] = PREC.PREC_shift; | |
625 precedence[TOK.TOKushr] = PREC.PREC_shift; | |
626 | |
627 precedence[TOK.TOKlt] = PREC.PREC_rel; | |
628 precedence[TOK.TOKle] = PREC.PREC_rel; | |
629 precedence[TOK.TOKgt] = PREC.PREC_rel; | |
630 precedence[TOK.TOKge] = PREC.PREC_rel; | |
631 precedence[TOK.TOKunord] = PREC.PREC_rel; | |
632 precedence[TOK.TOKlg] = PREC.PREC_rel; | |
633 precedence[TOK.TOKleg] = PREC.PREC_rel; | |
634 precedence[TOK.TOKule] = PREC.PREC_rel; | |
635 precedence[TOK.TOKul] = PREC.PREC_rel; | |
636 precedence[TOK.TOKuge] = PREC.PREC_rel; | |
637 precedence[TOK.TOKug] = PREC.PREC_rel; | |
638 precedence[TOK.TOKue] = PREC.PREC_rel; | |
639 precedence[TOK.TOKin] = PREC.PREC_rel; | |
640 | |
641 static if (false) { | |
642 precedence[TOK.TOKequal] = PREC.PREC_equal; | |
643 precedence[TOK.TOKnotequal] = PREC.PREC_equal; | |
644 precedence[TOK.TOKidentity] = PREC.PREC_equal; | |
645 precedence[TOK.TOKnotidentity] = PREC.PREC_equal; | |
646 } else { | |
647 /* Note that we changed precedence, so that < and != have the same | |
648 * precedence. This change is in the parser, too. | |
649 */ | |
650 precedence[TOK.TOKequal] = PREC.PREC_rel; | |
651 precedence[TOK.TOKnotequal] = PREC.PREC_rel; | |
652 precedence[TOK.TOKidentity] = PREC.PREC_rel; | |
653 precedence[TOK.TOKnotidentity] = PREC.PREC_rel; | |
654 } | |
655 | |
656 precedence[TOK.TOKand] = PREC.PREC_and; | |
657 | |
658 precedence[TOK.TOKxor] = PREC.PREC_xor; | |
659 | |
660 precedence[TOK.TOKor] = PREC.PREC_or; | |
661 | |
662 precedence[TOK.TOKandand] = PREC.PREC_andand; | |
663 | |
664 precedence[TOK.TOKoror] = PREC.PREC_oror; | |
665 | |
666 precedence[TOK.TOKquestion] = PREC.PREC_cond; | |
667 | |
668 precedence[TOK.TOKassign] = PREC.PREC_assign; | |
669 precedence[TOK.TOKconstruct] = PREC.PREC_assign; | |
670 precedence[TOK.TOKblit] = PREC.PREC_assign; | |
671 precedence[TOK.TOKaddass] = PREC.PREC_assign; | |
672 precedence[TOK.TOKminass] = PREC.PREC_assign; | |
673 precedence[TOK.TOKcatass] = PREC.PREC_assign; | |
674 precedence[TOK.TOKmulass] = PREC.PREC_assign; | |
675 precedence[TOK.TOKdivass] = PREC.PREC_assign; | |
676 precedence[TOK.TOKmodass] = PREC.PREC_assign; | |
677 precedence[TOK.TOKshlass] = PREC.PREC_assign; | |
678 precedence[TOK.TOKshrass] = PREC.PREC_assign; | |
679 precedence[TOK.TOKushrass] = PREC.PREC_assign; | |
680 precedence[TOK.TOKandass] = PREC.PREC_assign; | |
681 precedence[TOK.TOKorass] = PREC.PREC_assign; | |
682 precedence[TOK.TOKxorass] = PREC.PREC_assign; | |
683 | |
684 precedence[TOK.TOKcomma] = PREC.PREC_expr; | |
685 } | |
686 | |
687 int runLINK() | |
688 { | |
689 version (_WIN32) { | |
690 string p; | |
691 int i; | |
692 int status; | |
693 scope OutBuffer cmdbuf = new OutBuffer(); | |
694 | |
695 global.params.libfiles.push(cast(void*)new String("user32")); | |
696 global.params.libfiles.push(cast(void*)new String("kernel32")); | |
697 | |
698 for (i = 0; i < global.params.objfiles.dim; i++) | |
699 { | |
700 if (i) | |
701 cmdbuf.writeByte('+'); | |
702 p = (cast(String)global.params.objfiles.data[i]).str; | |
703 string ext = FileName.ext(p); | |
704 if (ext) | |
705 // Write name sans extension | |
706 writeFilename(cmdbuf, p[0..p.length - ext.length - 1]); | |
707 else | |
708 writeFilename(cmdbuf, p); | |
709 } | |
710 cmdbuf.writeByte(','); | |
711 if (global.params.exefile) | |
712 writeFilename(cmdbuf, global.params.exefile); | |
713 else | |
714 { | |
715 /* Generate exe file name from first obj name. | |
716 * No need to add it to cmdbuf because the linker will default to it. | |
717 */ | |
718 string n = (cast(String)global.params.objfiles.data[0]).str; | |
719 n = FileName.name(n); | |
720 FileName fn = FileName.forceExt(n, "exe"); | |
721 global.params.exefile = fn.toChars(); | |
722 } | |
723 | |
724 // Make sure path to exe file exists | |
725 { | |
726 string pp = FileName.path(global.params.exefile); | |
727 FileName.ensurePathExists(pp); | |
728 } | |
729 | |
730 cmdbuf.writeByte(','); | |
731 if (global.params.run) | |
732 cmdbuf.writestring("nul"); | |
733 | |
734 // if (mapfile) | |
735 // cmdbuf.writestring(output); | |
736 cmdbuf.writeByte(','); | |
737 | |
738 for (i = 0; i < global.params.libfiles.dim; i++) | |
739 { | |
740 if (i) | |
741 cmdbuf.writeByte('+'); | |
742 writeFilename(cmdbuf, (cast(String)global.params.libfiles.data[i]).str); | |
743 } | |
744 | |
745 if (global.params.deffile) | |
746 { | |
747 cmdbuf.writeByte(','); | |
748 writeFilename(cmdbuf, global.params.deffile); | |
749 } | |
750 | |
751 /* Eliminate unnecessary trailing commas */ | |
752 while (1) | |
753 { | |
754 i = cmdbuf.offset; | |
755 if (!i || cmdbuf.data[i - 1] != ',') | |
756 break; | |
757 cmdbuf.offset--; | |
758 } | |
759 | |
760 if (global.params.resfile) | |
761 { | |
762 cmdbuf.writestring("/RC:"); | |
763 writeFilename(cmdbuf, global.params.resfile); | |
764 } | |
765 | |
766 static if (false) { | |
767 if (mapfile) | |
768 cmdbuf.writestring("/m"); | |
769 if (debuginfo) | |
770 cmdbuf.writestring("/li"); | |
771 if (codeview) | |
772 { | |
773 cmdbuf.writestring("/co"); | |
774 if (codeview3) | |
775 cmdbuf.writestring(":3"); | |
776 } | |
777 } else { | |
778 if (global.params.symdebug) | |
779 cmdbuf.writestring("/co"); | |
780 } | |
781 | |
782 cmdbuf.writestring("/noi"); | |
783 for (i = 0; i < global.params.linkswitches.dim; i++) | |
784 { | |
785 cmdbuf.writestring((cast(String)global.params.linkswitches.data[i]).str); | |
786 } | |
787 cmdbuf.writeByte(';'); | |
788 | |
789 p = cmdbuf.toChars(); | |
790 | |
791 FileName lnkfilename = null; | |
792 size_t plen = p.length; | |
793 if (plen > 7000) | |
794 { | |
795 lnkfilename = FileName.forceExt(global.params.exefile, "lnk"); | |
796 scope File flnk = new File(lnkfilename); | |
797 flnk.setbuffer(cast(void*)p.ptr, plen); | |
798 flnk.ref_ = 1; | |
799 if (flnk.write()) | |
800 error("error writing file %s", lnkfilename); | |
801 if (lnkfilename.len() < plen) | |
802 p = std.string.format("@%s", lnkfilename.toChars()); | |
803 } | |
804 | |
805 string linkcmd = getenv("LINKCMD"); | |
806 if (!linkcmd) | |
807 linkcmd = "link"; | |
808 | |
809 status = executecmd(linkcmd, p, 1); | |
810 if (lnkfilename) | |
811 { | |
812 remove(toStringz(lnkfilename.toChars())); | |
813 ///delete lnkfilename; | |
814 } | |
815 return status; | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
816 } else version (POSIX) {/// linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
817 assert(false, "Unimplemented"); |
0 | 818 /+ |
819 pid_t childpid; | |
820 int i; | |
821 int status; | |
822 | |
823 // Build argv[] | |
824 Array argv; | |
825 | |
826 const char *cc = getenv("CC"); | |
827 if (!cc) | |
828 cc = "gcc"; | |
829 argv.push((void *)cc); | |
830 argv.insert(1, global.params.objfiles); | |
831 | |
832 // None of that a.out stuff. Use explicit exe file name, or | |
833 // generate one from name of first source file. | |
834 argv.push((void *)"-o"); | |
835 if (global.params.exefile) | |
836 { | |
837 argv.push(global.params.exefile); | |
838 } | |
839 else | |
840 { // Generate exe file name from first obj name | |
841 char *n = (char *)global.params.objfiles.data[0]; | |
842 char *e; | |
843 char *ex; | |
844 | |
845 n = FileName.name(n); | |
846 e = FileName.ext(n); | |
847 if (e) | |
848 { | |
849 e--; // back up over '.' | |
850 ex = (char *)mem.malloc(e - n + 1); | |
851 memcpy(ex, n, e - n); | |
852 ex[e - n] = 0; | |
853 } | |
854 else | |
855 ex = (char *)"a.out"; // no extension, so give up | |
856 argv.push(ex); | |
857 global.params.exefile = ex; | |
858 } | |
859 | |
860 // Make sure path to exe file exists | |
861 { char *p = FileName.path(global.params.exefile); | |
862 FileName.ensurePathExists(p); | |
863 mem.free(p); | |
864 } | |
865 | |
866 if (global.params.symdebug) | |
867 argv.push((void *)"-g"); | |
868 | |
869 if (global.params.isX86_64) | |
870 argv.push((void *)"-m64"); | |
871 else | |
872 argv.push((void *)"-m32"); | |
873 | |
874 if (0 && global.params.exefile) | |
875 { | |
876 /* This switch enables what is known as 'smart linking' | |
877 * in the Windows world, where unreferenced sections | |
878 * are removed from the executable. It eliminates unreferenced | |
879 * functions, essentially making a 'library' out of a module. | |
880 * Although it is documented to work with ld version 2.13, | |
881 * in practice it does not, but just seems to be ignored. | |
882 * Thomas Kuehne has verified that it works with ld 2.16.1. | |
883 * BUG: disabled because it causes exception handling to fail | |
884 */ | |
885 argv.push((void *)"-Xlinker"); | |
886 argv.push((void *)"--gc-sections"); | |
887 } | |
888 | |
889 for (i = 0; i < global.params.linkswitches.dim; i++) | |
890 { char *p = (char *)global.params.linkswitches.data[i]; | |
891 if (!p || !p[0] || !(p[0] == '-' && p[1] == 'l')) | |
892 // Don't need -Xlinker if switch starts with -l | |
893 argv.push((void *)"-Xlinker"); | |
894 argv.push((void *) p); | |
895 } | |
896 | |
897 /* Add each library, prefixing it with "-l". | |
898 * The order of libraries passed is: | |
899 * 1. any libraries passed with -L command line switch | |
900 * 2. libraries specified on the command line | |
901 * 3. libraries specified by pragma(lib), which were appended | |
902 * to global.params.libfiles. | |
903 * 4. standard libraries. | |
904 */ | |
905 for (i = 0; i < global.params.libfiles.dim; i++) | |
906 { char *p = (char *)global.params.libfiles.data[i]; | |
907 size_t plen = strlen(p); | |
908 if (plen > 2 && p[plen - 2] == '.' && p[plen -1] == 'a') | |
909 argv.push((void *)p); | |
910 else | |
911 { | |
912 char *s = (char *)mem.malloc(plen + 3); | |
913 s[0] = '-'; | |
914 s[1] = 'l'; | |
915 memcpy(s + 2, p, plen + 1); | |
916 argv.push((void *)s); | |
917 } | |
918 } | |
919 | |
920 /* Standard libraries must go after user specified libraries | |
921 * passed with -l. | |
922 */ | |
923 const char *libname = (global.params.symdebug) | |
924 ? global.params.debuglibname | |
925 : global.params.defaultlibname; | |
926 char *buf = (char *)malloc(2 + strlen(libname) + 1); | |
927 strcpy(buf, "-l"); | |
928 strcpy(buf + 2, libname); | |
929 argv.push((void *)buf); // turns into /usr/lib/libphobos2.a | |
930 | |
931 // argv.push((void *)"-ldruntime"); | |
932 argv.push((void *)"-lpthread"); | |
933 argv.push((void *)"-lm"); | |
934 | |
935 if (!global.params.quiet || global.params.verbose) | |
936 { | |
937 // Print it | |
938 for (i = 0; i < argv.dim; i++) | |
939 printf("%s ", (char *)argv.data[i]); | |
940 printf("\n"); | |
941 fflush(stdout); | |
942 } | |
943 | |
944 argv.push(null); | |
945 childpid = fork(); | |
946 if (childpid == 0) | |
947 { | |
948 execvp((char *)argv.data[0], (char **)argv.data); | |
949 perror((char *)argv.data[0]); // failed to execute | |
950 return -1; | |
951 } | |
952 | |
953 waitpid(childpid, &status, 0); | |
954 | |
955 status=WEXITSTATUS(status); | |
956 if (status) | |
957 printf("--- errorlevel %d\n", status); | |
958 return status; | |
959 +/ | |
960 } else { | |
961 writef ("Linking is not yet supported for this version of DMD.\n"); | |
962 return -1; | |
963 } | |
964 } | |
965 | |
966 int runProgram() | |
967 { | |
968 assert(false); | |
969 } | |
970 | |
971 void deleteExeFile() | |
972 { | |
973 assert(false); | |
974 } | |
975 | |
976 /**************************************** | |
977 * Write filename to cmdbuf, quoting if necessary. | |
978 */ | |
979 | |
980 void writeFilename(OutBuffer buf, string filename) | |
981 { | |
982 auto len = filename.length; | |
983 /* Loop and see if we need to quote | |
984 */ | |
985 for (size_t i = 0; i < len; i++) | |
986 { | |
987 char c = filename[i]; | |
988 | |
989 if (isalnum(c) || c == '_') | |
990 continue; | |
991 | |
992 /* Need to quote | |
993 */ | |
994 buf.writeByte('"'); | |
995 buf.writestring(filename); | |
996 buf.writeByte('"'); | |
997 return; | |
998 } | |
999 | |
1000 /* No quoting necessary | |
1001 */ | |
1002 buf.writestring(filename); | |
1003 } | |
1004 | |
1005 /****************************** | |
1006 * Execute a rule. Return the status. | |
1007 * cmd program to run | |
1008 * args arguments to cmd, as a string | |
1009 * useenv if cmd knows about _CMDLINE environment variable | |
1010 */ | |
1011 | |
1012 version (_WIN32) { | |
1013 int executecmd(string cmd, string args, int useenv) | |
1014 { | |
1015 int status; | |
1016 size_t len = args.length; | |
1017 | |
1018 if (!global.params.quiet || global.params.verbose) | |
1019 { | |
1020 printf("%s %s\n", cmd, args); | |
1021 fflush(stdout); | |
1022 } | |
1023 | |
1024 if (len > 255) | |
1025 { | |
1026 char* q; | |
1027 static char[9] envname = "@_CMDLINE"; | |
1028 | |
1029 envname[0] = '@'; | |
1030 switch (useenv) | |
1031 { | |
1032 case 0: goto L1; | |
1033 case 2: envname[0] = '%'; break; | |
1034 default: break; /// | |
1035 } | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
1036 version (Bug4054) |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
1037 q = cast(char*) GC.malloc(envname.sizeof + len + 1); |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
1038 else |
0 | 1039 q = cast(char*) alloca(envname.sizeof + len + 1); |
1040 sprintf(q, "%s=%s", envname.ptr + 1, args); | |
1041 status = putenv(q); | |
1042 if (status == 0) | |
1043 args = envname[].idup; | |
1044 else | |
1045 { | |
1046 L1: | |
1047 error("command line length of %d is too long",len); | |
1048 } | |
1049 } | |
1050 | |
1051 status = executearg0(cmd, args); | |
1052 version (_WIN32) { | |
1053 if (status == -1) { | |
1054 auto cmdZ = toStringz(cmd); | |
1055 auto argsZ = toStringz(args); | |
1056 status = spawnlp(0, cmdZ, cmdZ, argsZ, null); | |
1057 } | |
1058 } | |
1059 // if (global.params.verbose) | |
1060 // printf("\n"); | |
1061 if (status) | |
1062 { | |
1063 if (status == -1) | |
1064 printf("Can't run '%s', check PATH\n", cmd); | |
1065 else | |
1066 printf("--- errorlevel %d\n", status); | |
1067 } | |
1068 return status; | |
1069 } | |
1070 } | |
1071 | |
1072 /************************************** | |
1073 * Attempt to find command to execute by first looking in the directory | |
1074 * where DMD was run from. | |
1075 * Returns: | |
1076 * -1 did not find command there | |
1077 * !=-1 exit status from command | |
1078 */ | |
1079 | |
1080 version (_WIN32) { | |
1081 int executearg0(string cmd, string args) | |
1082 { | |
1083 string file; | |
1084 string argv0 = global.params.argv0; | |
1085 | |
1086 //printf("argv0='%s', cmd='%s', args='%s'\n",argv0,cmd,args); | |
1087 | |
1088 // If cmd is fully qualified, we don't do this | |
1089 if (FileName.absolute(cmd)) | |
1090 return -1; | |
1091 | |
1092 file = FileName.replaceName(argv0, cmd); | |
1093 | |
1094 //printf("spawning '%s'\n",file); | |
1095 version (_WIN32) { | |
1096 auto fileZ = toStringz(file); | |
1097 auto argsZ = toStringz(args); | |
1098 return spawnl(0, fileZ, fileZ, argsZ, null); | |
1099 } else version (XXX) { ///#elif linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 | |
1100 assert(false); | |
1101 /+ | |
1102 char *full; | |
1103 int cmdl = strlen(cmd); | |
1104 | |
1105 full = (char*) mem.malloc(cmdl + strlen(args) + 2); | |
1106 if (full == null) | |
1107 return 1; | |
1108 strcpy(full, cmd); | |
1109 full [cmdl] = ' '; | |
1110 strcpy(full + cmdl + 1, args); | |
1111 | |
1112 int result = system(full); | |
1113 | |
1114 mem.free(full); | |
1115 return result; | |
1116 +/ | |
1117 } else { | |
1118 static assert(false); | |
1119 } | |
1120 } | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
2
diff
changeset
|
1121 } |