Mercurial > projects > ddmd
annotate main.d @ 182:b64060ab22df
Now compileable with dmd2.050
author | korDen |
---|---|
date | Sat, 30 Oct 2010 05:05:32 +0400 |
parents | cd48cb899aee |
children | 190ba98276b3 |
rev | line source |
---|---|
0 | 1 module main; |
2 | |
99 | 3 import dmd.Macro; |
0 | 4 import dmd.Array; |
5 import dmd.Module; | |
6 import dmd.Global; | |
7 import dmd.VersionCondition; | |
8 import dmd.DebugCondition; | |
9 import dmd.Loc; | |
10 import dmd.Lexer; | |
11 import dmd.OutBuffer; | |
12 import dmd.FileName; | |
13 import dmd.Type; | |
14 import dmd.File; | |
15 import dmd.Id; | |
16 import dmd.Identifier; | |
79 | 17 import dmd.Json; |
0 | 18 import dmd.Library; |
19 import dmd.TOK; | |
20 import dmd.String; | |
21 import dmd.backend.glue; | |
22 | |
23 import std.stdarg; | |
24 import std.string : toStringz; | |
34 | 25 import std.exception; |
0 | 26 |
27 import core.stdc.string; | |
28 import core.stdc.stdio; | |
29 import core.stdc.ctype; | |
30 import core.stdc.errno; | |
31 import core.stdc.stdlib; | |
32 import core.stdc.limits; | |
33 | |
34 import core.memory; | |
35 | |
70 | 36 import dbg.CallStackInfo; |
0 | 37 |
38 import dmd.Util; | |
39 | |
40 enum ExitCode | |
41 { | |
42 EXIT_SUCCESS = 0, | |
43 } | |
44 | |
164 | 45 version = CrashHandler; |
46 | |
47 version (CrashHandler) { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
48 version(Linux) |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
49 { |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
50 extern (C) extern __gshared bool rt_trapExceptions; |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
51 |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
52 static this() { |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
53 rt_trapExceptions = false; |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
54 } |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
55 |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
56 } |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
57 |
164 | 58 |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
59 version(Windows) |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
60 { |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
61 |
70 | 62 version (Windows) |
63 { | |
64 private import core.stdc.wchar_; | |
65 | |
66 extern (Windows) alias int function() FARPROC; | |
67 extern (Windows) FARPROC GetProcAddress(void*, in char*); | |
68 extern (Windows) void* LoadLibraryA(in char*); | |
69 extern (Windows) int FreeLibrary(void*); | |
70 extern (Windows) void* LocalFree(void*); | |
71 extern (Windows) wchar_t* GetCommandLineW(); | |
72 extern (Windows) wchar_t** CommandLineToArgvW(wchar_t*, int*); | |
73 extern (Windows) export int WideCharToMultiByte(uint, uint, wchar_t*, int, char*, int, char*, int); | |
74 pragma(lib, "shell32.lib"); // needed for CommandLineToArgvW | |
75 } | |
76 | |
77 shared bool _d_isHalting = false; | |
78 __gshared string[] _d_args = null; | |
79 | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
80 version(Posix) |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
81 { |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
82 extern (C) void _STI_monitor_staticctor(); |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
83 extern (C) void _STD_monitor_staticdtor(); |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
84 extern (C) void _STI_critical_init(); |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
85 extern (C) void _STD_critical_term(); |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
86 } |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
87 |
70 | 88 extern (C) void gc_init(); |
89 extern (C) void gc_term(); | |
90 extern (C) void _minit(); | |
91 extern (C) void _moduleCtor(); | |
92 extern (C) void _moduleDtor(); | |
93 extern (C) bool runModuleUnitTests(); | |
94 extern (C) void thread_joinAll(); | |
95 | |
96 import rt.memory; | |
97 | |
98 extern (C) int main(int argc, char** argv) | |
99 { | |
100 char[][] args; | |
101 int result; | |
102 | |
103 version (OSX) | |
104 { /* OSX does not provide a way to get at the top of the | |
105 * stack, except for the magic value 0xC0000000. | |
106 * But as far as the gc is concerned, argv is at the top | |
107 * of the main thread's stack, so save the address of that. | |
108 */ | |
109 __osx_stack_end = cast(void*)&argv; | |
110 } | |
111 | |
112 version (FreeBSD) version (D_InlineAsm_X86) | |
113 { | |
114 /* | |
115 * FreeBSD/i386 sets the FPU precision mode to 53 bit double. | |
116 * Make it 64 bit extended. | |
117 */ | |
118 ushort fpucw; | |
119 asm | |
120 { | |
121 fstsw fpucw; | |
122 or fpucw, 0b11_00_111111; // 11: use 64 bit extended-precision | |
123 // 111111: mask all FP exceptions | |
124 fldcw fpucw; | |
125 } | |
126 } | |
127 | |
128 version (Posix) | |
129 { | |
130 _STI_monitor_staticctor(); | |
131 _STI_critical_init(); | |
132 } | |
0 | 133 |
70 | 134 version (Windows) |
135 { | |
136 wchar_t* wcbuf = GetCommandLineW(); | |
137 size_t wclen = wcslen(wcbuf); | |
138 int wargc = 0; | |
139 wchar_t** wargs = CommandLineToArgvW(wcbuf, &wargc); | |
140 assert(wargc == argc); | |
141 | |
142 char* cargp = null; | |
143 size_t cargl = WideCharToMultiByte(65001, 0, wcbuf, wclen, null, 0, null, 0); | |
144 | |
145 cargp = cast(char*) alloca(cargl); | |
146 args = ((cast(char[]*) alloca(wargc * (char[]).sizeof)))[0 .. wargc]; | |
147 | |
148 for (size_t i = 0, p = 0; i < wargc; i++) | |
149 { | |
150 int wlen = wcslen(wargs[i]); | |
151 int clen = WideCharToMultiByte(65001, 0, &wargs[i][0], wlen, null, 0, null, 0); | |
152 args[i] = cargp[p .. p+clen]; | |
153 p += clen; assert(p <= cargl); | |
154 WideCharToMultiByte(65001, 0, &wargs[i][0], wlen, &args[i][0], clen, null, 0); | |
155 } | |
156 LocalFree(wargs); | |
157 wargs = null; | |
158 wargc = 0; | |
159 } | |
160 else version (Posix) | |
161 { | |
162 char[]* am = cast(char[]*) malloc(argc * (char[]).sizeof); | |
163 scope(exit) free(am); | |
164 | |
165 for (size_t i = 0; i < argc; i++) | |
166 { | |
167 auto len = strlen(argv[i]); | |
168 am[i] = argv[i][0 .. len]; | |
169 } | |
170 args = am[0 .. argc]; | |
171 } | |
172 _d_args = cast(string[]) args; | |
173 | |
174 void runMain() | |
175 { | |
164 | 176 CrashHandlerInit(); |
165
25ede4f66bda
Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents:
164
diff
changeset
|
177 // while (true) |
25ede4f66bda
Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents:
164
diff
changeset
|
178 { |
25ede4f66bda
Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents:
164
diff
changeset
|
179 result = main(_d_args); |
25ede4f66bda
Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents:
164
diff
changeset
|
180 } |
70 | 181 } |
182 | |
183 void runAll() | |
184 { | |
185 gc_init(); | |
186 initStaticDataGC(); | |
187 version (Windows) | |
188 _minit(); | |
189 _moduleCtor(); | |
190 _moduleTlsCtor(); | |
191 if (runModuleUnitTests()) | |
192 runMain(); | |
193 else | |
194 result = EXIT_FAILURE; | |
195 _moduleTlsDtor(); | |
196 thread_joinAll(); | |
197 _d_isHalting = true; | |
198 _moduleDtor(); | |
199 gc_term(); | |
200 } | |
201 | |
202 runAll(); | |
203 | |
204 version (Posix) | |
205 { | |
206 _STD_critical_term(); | |
207 _STD_monitor_staticdtor(); | |
208 } | |
209 return result; | |
0 | 210 } |
25 | 211 |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
212 } |
164 | 213 } |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
70
diff
changeset
|
214 |
0 | 215 int main(string[] args) |
216 { | |
165
25ede4f66bda
Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents:
164
diff
changeset
|
217 GC.disable(); |
25ede4f66bda
Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents:
164
diff
changeset
|
218 |
0 | 219 Array files = new Array(); |
220 Array libmodules = new Array(); | |
221 Module m; | |
222 int status = ExitCode.EXIT_SUCCESS; | |
223 int argcstart = args.length; | |
224 int setdebuglib = 0; | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
225 byte noboundscheck = 0; |
0 | 226 |
227 global = new Global(); | |
228 | |
229 /// if (response_expand(&argc,&argv)) // expand response files | |
230 /// error("can't open response file"); | |
231 | |
232 files.reserve(args.length - 1); | |
233 | |
234 // Set default values | |
235 global.params.argv0 = args[0]; | |
236 global.params.link = 1; | |
237 global.params.useAssert = 1; | |
238 global.params.useInvariants = 1; | |
239 global.params.useIn = 1; | |
240 global.params.useOut = 1; | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
241 global.params.useArrayBounds = 2; // default to all functions |
0 | 242 global.params.useSwitchError = 1; |
243 global.params.useInline = 0; | |
244 global.params.obj = 1; | |
245 global.params.Dversion = 2; | |
246 global.params.quiet = 1; | |
247 | |
248 global.params.linkswitches = new Array(); | |
249 global.params.libfiles = new Array(); | |
250 global.params.objfiles = new Array(); | |
251 global.params.ddocfiles = new Array(); | |
252 | |
253 version (TARGET_WINDOS) { | |
254 global.params.defaultlibname = "phobos"; | |
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:
4
diff
changeset
|
255 } else version (POSIX) { //#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS |
0 | 256 global.params.defaultlibname = "phobos2"; |
257 } else version (TARGET_NET) { | |
258 } else { | |
259 static assert(false, "fix this"); | |
260 } | |
261 | |
262 // Predefine version identifiers | |
263 VersionCondition.addPredefinedGlobalIdent("DigitalMars"); | |
264 | |
265 version (TARGET_WINDOS) { | |
266 VersionCondition.addPredefinedGlobalIdent("Windows"); | |
267 global.params.isWindows = 1; | |
268 version (TARGET_NET) { | |
269 // TARGET_NET macro is NOT mutually-exclusive with TARGET_WINDOS | |
270 VersionCondition.addPredefinedGlobalIdent("D_NET"); | |
271 } | |
272 } else version (TARGET_LINUX) { | |
273 VersionCondition.addPredefinedGlobalIdent("Posix"); | |
274 VersionCondition.addPredefinedGlobalIdent("linux"); | |
275 global.params.isLinux = 1; | |
276 } else version (TARGET_OSX) { | |
277 VersionCondition.addPredefinedGlobalIdent("Posix"); | |
278 VersionCondition.addPredefinedGlobalIdent("OSX"); | |
279 global.params.isOSX = 1; | |
280 | |
281 // For legacy compatibility | |
282 VersionCondition.addPredefinedGlobalIdent("darwin"); | |
283 } else version (TARGET_FREEBSD) { | |
284 VersionCondition.addPredefinedGlobalIdent("Posix"); | |
285 VersionCondition.addPredefinedGlobalIdent("FreeBSD"); | |
286 global.params.isFreeBSD = 1; | |
287 } else version (TARGET_SOLARIS) { | |
288 VersionCondition.addPredefinedGlobalIdent("Posix"); | |
289 VersionCondition.addPredefinedGlobalIdent("Solaris"); | |
290 global.params.isSolaris = 1; | |
291 } else { | |
292 static assert (false, "fix this"); | |
293 } | |
294 | |
295 VersionCondition.addPredefinedGlobalIdent("LittleEndian"); | |
296 //VersionCondition.addPredefinedGlobalIdent("D_Bits"); | |
297 version (DMDV2) { | |
298 VersionCondition.addPredefinedGlobalIdent("D_Version2"); | |
299 } | |
300 VersionCondition.addPredefinedGlobalIdent("all"); | |
301 | |
114 | 302 version (Windows) |
303 { | |
304 inifile(args[0], "sc.ini"); | |
305 } | |
306 else version (Posix) ///linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 | |
307 { | |
308 inifile(args[0], "dmd.conf"); | |
309 } | |
310 else | |
311 { | |
312 static assert (false, "fix this"); | |
0 | 313 } |
314 args = getenv_setargv("DFLAGS", args); | |
315 | |
316 version (disabled) { | |
317 for (i = 0; i < argc; i++) | |
318 { | |
319 writef("argv[%d] = '%s'\n", i, argv[i]); | |
320 } | |
321 } | |
322 | |
323 foreach(i; 1..args.length) | |
324 { | |
325 auto arg = args[i]; | |
326 auto p = arg.ptr; | |
327 if (*p == '-') | |
328 { | |
329 arg = arg[1..$]; | |
330 if (arg == "d") | |
331 global.params.useDeprecated = 1; | |
332 else if (arg == "c") | |
333 global.params.link = 0; | |
334 else if (arg == "cov") | |
335 global.params.cov = 1; | |
336 ///version (XXX) {// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS | |
337 /// else if (arg == "fPIC") | |
338 /// global.params.pic = 1; | |
339 ///} | |
179 | 340 else if (arg == "map") |
341 global.params.map = 1; | |
0 | 342 else if (arg == "multiobj") |
343 global.params.multiobj = 1; | |
344 else if (arg == "g") | |
345 global.params.symdebug = 1; | |
346 else if (arg == "gc") | |
347 global.params.symdebug = 2; | |
348 else if (arg == "gt") | |
349 { error("use -profile instead of -gt\n"); | |
350 global.params.trace = 1; | |
351 } | |
352 else if (arg == "m64") | |
353 global.params.isX86_64 = 1; | |
354 else if (arg == "profile") | |
355 global.params.trace = 1; | |
356 else if (arg == "v") | |
357 global.params.verbose = 1; | |
358 ///version (DMDV2) { | |
359 else if (arg == "vtls") | |
360 global.params.vtls = 1; | |
361 ///} | |
362 else if (arg == "v1") | |
363 { | |
364 version (DMDV1) { | |
365 global.params.Dversion = 1; | |
366 } else { | |
367 error("use DMD 1.0 series compilers for -v1 switch"); | |
368 break; | |
369 } | |
370 } | |
371 else if (arg == "w") | |
372 global.params.warnings = 1; | |
373 else if (arg == "O") | |
374 global.params.optimize = 1; | |
375 else if (p[1] == 'o') | |
376 { | |
377 switch (p[2]) | |
378 { | |
379 case '-': | |
380 global.params.obj = 0; | |
381 break; | |
382 | |
383 case 'd': | |
384 if (!p[3]) | |
385 goto Lnoarg; | |
386 global.params.objdir = arg[(p - arg.ptr) + 3..$]; | |
387 break; | |
388 | |
389 case 'f': | |
390 { | |
391 if (!p[3]) | |
392 goto Lnoarg; | |
393 | |
394 global.params.objname = arg[(p - arg.ptr) + 3..$]; | |
395 break; | |
396 } | |
397 | |
398 case 'p': | |
399 if (p[3]) | |
400 goto Lerror; | |
401 global.params.preservePaths = 1; | |
402 break; | |
403 | |
404 case 0: | |
405 error("-o no longer supported, use -of or -od"); | |
406 break; | |
407 | |
408 default: | |
409 goto Lerror; | |
410 } | |
411 } | |
412 else if (p[1] == 'D') | |
413 { global.params.doDocComments = 1; | |
414 switch (p[2]) | |
415 { | |
416 case 'd': | |
417 if (!p[3]) | |
418 goto Lnoarg; | |
419 global.params.docdir = arg[(p - arg.ptr) + 3..$]; | |
420 break; | |
421 case 'f': | |
422 if (!p[3]) | |
423 goto Lnoarg; | |
424 global.params.docname = arg[(p - arg.ptr) + 3..$]; | |
425 break; | |
426 | |
427 case 0: | |
428 break; | |
429 | |
430 default: | |
431 goto Lerror; | |
432 } | |
433 } | |
434 ///version (_DH) { | |
435 else if (p[1] == 'H') | |
436 { global.params.doHdrGeneration = 1; | |
437 switch (p[2]) | |
438 { | |
439 case 'd': | |
440 if (!p[3]) | |
441 goto Lnoarg; | |
442 global.params.hdrdir = arg[(p - arg.ptr) + 3..$]; | |
443 break; | |
444 | |
445 case 'f': | |
446 if (!p[3]) | |
447 goto Lnoarg; | |
448 global.params.hdrname = arg[(p - arg.ptr) + 3..$]; | |
449 break; | |
450 | |
451 case 0: | |
452 break; | |
453 | |
454 default: | |
455 goto Lerror; | |
456 } | |
457 } | |
458 ///} | |
79 | 459 else if (p[1] == 'X') |
460 { | |
461 global.params.doXGeneration = 1; | |
462 switch (p[2]) | |
463 { | |
464 case 'f': | |
465 if (!p[3]) | |
466 goto Lnoarg; | |
467 global.params.xfilename = arg[(p - arg.ptr) + 3..$]; | |
468 break; | |
469 | |
470 case 0: | |
471 break; | |
472 | |
473 default: | |
474 goto Lerror; | |
475 } | |
476 } | |
477 | |
0 | 478 else if (arg == "ignore") |
479 global.params.ignoreUnsupportedPragmas = 1; | |
480 else if (arg == "inline") | |
481 global.params.useInline = 1; | |
482 else if (arg == "lib") | |
483 global.params.lib = 1; | |
484 else if (arg == "nofloat") | |
485 global.params.nofloat = 1; | |
486 else if (arg == "quiet") | |
487 global.params.quiet = 1; | |
488 else if (arg == "release") | |
489 global.params.release = 1; | |
490 ///version (DMDV2) { | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
491 else if (arg == "noboundscheck") |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
492 noboundscheck = 1; |
0 | 493 ///} |
494 else if (arg == "unittest") | |
495 global.params.useUnitTests = 1; | |
496 else if (p[1] == 'I') | |
497 { | |
498 global.params.imppath.push(cast(void*)new String(arg[(p - arg.ptr) + 2..$])); /// | |
499 } | |
500 else if (p[1] == 'J') | |
501 { | |
502 if (!global.params.fileImppath) | |
503 global.params.fileImppath = new Array(); | |
504 global.params.fileImppath.push(cast(void*)new String(arg[(p - arg.ptr) + 2..$])); | |
505 } | |
506 else if (memcmp(p + 1, "debug".ptr, 5) == 0 && p[6] != 'l') | |
507 { | |
508 // Parse: | |
509 // -debug | |
510 // -debug=number | |
511 // -debug=identifier | |
512 if (p[6] == '=') | |
513 { | |
514 if (isdigit(p[7])) | |
515 { long level; | |
516 | |
517 errno = 0; | |
518 level = strtol(p + 7, cast(char**)&p, 10); | |
519 if (*p || errno || level > INT_MAX) | |
520 goto Lerror; | |
521 DebugCondition.setGlobalLevel(cast(int)level); | |
522 } | |
523 else if (Lexer.isValidIdentifier(arg[(p - arg.ptr) + 7..$])) /// | |
524 DebugCondition.addGlobalIdent(p + 7); | |
525 else | |
526 goto Lerror; | |
527 } | |
528 else if (p[6]) | |
529 goto Lerror; | |
530 else | |
531 global.params.debuglevel = 1; | |
532 } | |
533 else if (memcmp(p + 1, "version".ptr, 5) == 0) | |
534 { | |
535 // Parse: | |
536 // -version=number | |
537 // -version=identifier | |
538 if (p[8] == '=') | |
539 { | |
540 if (isdigit(p[9])) | |
541 { long level; | |
542 | |
543 errno = 0; | |
544 level = strtol(p + 9, cast(char**)&p, 10); /// | |
545 if (*p || errno || level > INT_MAX) | |
546 goto Lerror; | |
547 VersionCondition.setGlobalLevel(cast(int)level); | |
548 } | |
549 else if (Lexer.isValidIdentifier(arg[(p - arg.ptr) + 9..$])) /// | |
550 VersionCondition.addGlobalIdent(arg[(p - arg.ptr) + 9..$]); | |
551 else | |
552 goto Lerror; | |
553 } | |
554 else | |
555 goto Lerror; | |
556 } | |
557 else if (arg == "-b") | |
558 global.params.debugb = 1; | |
559 else if (arg == "-c") | |
560 global.params.debugc = 1; | |
561 else if (arg == "-f") | |
562 global.params.debugf = 1; | |
563 else if (arg == "-help") | |
564 { usage(); | |
565 exit(EXIT_SUCCESS); | |
566 } | |
567 else if (arg == "-r") | |
568 global.params.debugr = 1; | |
569 else if (arg == "-x") | |
570 global.params.debugx = 1; | |
571 else if (arg == "-y") | |
572 global.params.debugy = 1; | |
573 else if (p[1] == 'L') | |
574 { | |
575 global.params.linkswitches.push(cast(void*)p + 2); | |
576 } | |
577 else if (memcmp(p + 1, "defaultlib=".ptr, 11) == 0) | |
578 { | |
579 global.params.defaultlibname = p + 1 + 11; | |
580 } | |
581 else if (memcmp(p + 1, "debuglib=".ptr, 9) == 0) | |
582 { | |
583 setdebuglib = 1; | |
584 global.params.debuglibname = p + 1 + 9; | |
585 } | |
586 else if (memcmp(p + 1, "deps=".ptr, 5) == 0) | |
587 { | |
588 global.params.moduleDepsFile = arg[(p - arg.ptr) + 1 + 5..$]; | |
589 if (!global.params.moduleDepsFile[0]) | |
590 goto Lnoarg; | |
591 global.params.moduleDeps = new OutBuffer; | |
592 } | |
593 else if (memcmp(p + 1, "man".ptr, 3) == 0) | |
594 { | |
114 | 595 version (Windows) { |
0 | 596 version (DMDV1) { |
597 browse("http://www.digitalmars.com/d/1.0/dmd-windows.html"); | |
598 } else { | |
599 browse("http://www.digitalmars.com/d/2.0/dmd-windows.html"); | |
600 } | |
601 } | |
602 version (linux) { | |
603 version (DMDV1) { | |
604 browse("http://www.digitalmars.com/d/1.0/dmd-linux.html"); | |
605 } else { | |
606 browse("http://www.digitalmars.com/d/2.0/dmd-linux.html"); | |
607 } | |
608 } | |
609 version (__APPLE__) { | |
610 version (DMDV1) { | |
611 browse("http://www.digitalmars.com/d/1.0/dmd-osx.html"); | |
612 } else { | |
613 browse("http://www.digitalmars.com/d/2.0/dmd-osx.html"); | |
614 } | |
615 } | |
616 version (__FreeBSD__) { | |
617 version (DMDV1) { | |
618 browse("http://www.digitalmars.com/d/1.0/dmd-freebsd.html"); | |
619 } else { | |
620 browse("http://www.digitalmars.com/d/2.0/dmd-freebsd.html"); | |
621 } | |
622 } | |
623 exit(EXIT_SUCCESS); | |
624 } | |
625 else if (arg == "run") | |
626 { global.params.run = 1; | |
627 global.params.runargs_length = ((i >= argcstart) ? args.length : argcstart) - i - 1; | |
628 if (global.params.runargs_length) | |
629 { | |
630 files.push(cast(void*)args[i + 1].ptr); | |
631 global.params.runargs = args[i + 2..$]; | |
632 i += global.params.runargs_length; | |
633 global.params.runargs_length--; | |
634 } | |
635 else | |
636 { global.params.run = 0; | |
637 goto Lnoarg; | |
638 } | |
639 } | |
640 else | |
641 { | |
642 Lerror: | |
643 error("unrecognized switch '%s'", args[i]); | |
644 continue; | |
645 | |
646 Lnoarg: | |
647 error("argument expected for switch '%s'", args[i]); | |
648 continue; | |
649 } | |
650 } | |
651 else | |
652 { | |
653 version (TARGET_WINDOS) { | |
654 string ext = FileName.ext(p[0..arg.length]); | |
655 if (ext != null && FileName.compare(ext, "exe") == 0) | |
656 { | |
657 global.params.objname = arg[(p - arg.ptr)..$]; | |
658 continue; | |
659 } | |
660 } | |
661 files.push(cast(void*)new String(arg[(p - arg.ptr)..$])); | |
662 } | |
663 } | |
664 if (global.errors) | |
665 { | |
666 fatal(); | |
667 } | |
668 if (files.dim == 0) | |
669 { usage(); | |
670 return EXIT_FAILURE; | |
671 } | |
672 | |
673 if (!setdebuglib) | |
674 global.params.debuglibname = global.params.defaultlibname; | |
675 | |
676 version (TARGET_OSX) { | |
677 global.params.pic = 1; | |
678 } | |
679 | |
680 if (global.params.release) | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
681 { |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
682 global.params.useInvariants = 0; |
0 | 683 global.params.useIn = 0; |
684 global.params.useOut = 0; | |
685 global.params.useAssert = 0; | |
686 global.params.useArrayBounds = 0; | |
687 global.params.useSwitchError = 0; | |
688 } | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
689 |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
690 if (noboundscheck) |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
691 global.params.useArrayBounds = 0; |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
692 |
0 | 693 if (global.params.run) |
694 global.params.quiet = 1; | |
695 | |
696 if (global.params.useUnitTests) | |
697 global.params.useAssert = 1; | |
698 | |
699 if (!global.params.obj || global.params.lib) | |
700 global.params.link = 0; | |
701 | |
702 if (global.params.link) | |
703 { | |
704 global.params.exefile = global.params.objname; | |
705 global.params.oneobj = 1; | |
706 if (global.params.objname) | |
707 { | |
708 /* Use this to name the one object file with the same | |
709 * name as the exe file. | |
710 */ | |
711 global.params.objname = FileName.forceExt(global.params.objname, global.obj_ext).toChars(); | |
712 | |
713 /* If output directory is given, use that path rather than | |
714 * the exe file path. | |
715 */ | |
716 if (global.params.objdir) | |
717 { | |
718 string name = FileName.name(global.params.objname); | |
719 global.params.objname = FileName.combine(global.params.objdir, name); | |
720 } | |
721 } | |
722 } | |
723 else if (global.params.lib) | |
724 { | |
725 global.params.libname = global.params.objname; | |
726 global.params.objname = null; | |
727 | |
728 // Haven't investigated handling these options with multiobj | |
729 if (!global.params.cov && !global.params.trace) | |
730 global.params.multiobj = 1; | |
731 } | |
732 else if (global.params.run) | |
733 { | |
734 error("flags conflict with -run"); | |
735 fatal(); | |
736 } | |
737 else | |
738 { | |
739 if (global.params.objname && files.dim > 1) | |
740 { | |
741 global.params.oneobj = 1; | |
742 //error("multiple source files, but only one .obj name"); | |
743 //fatal(); | |
744 } | |
745 } | |
746 if (global.params.isX86_64) | |
747 { | |
748 VersionCondition.addPredefinedGlobalIdent("D_InlineAsm_X86_64"); | |
749 VersionCondition.addPredefinedGlobalIdent("X86_64"); | |
750 VersionCondition.addPredefinedGlobalIdent("D_LP64"); | |
751 version (TARGET_WINDOS) { | |
752 VersionCondition.addPredefinedGlobalIdent("Win64"); | |
753 } | |
754 } | |
755 else | |
756 { | |
757 VersionCondition.addPredefinedGlobalIdent("D_InlineAsm"); | |
758 VersionCondition.addPredefinedGlobalIdent("D_InlineAsm_X86"); | |
759 VersionCondition.addPredefinedGlobalIdent("X86"); | |
760 version (TARGET_WINDOS) { | |
761 VersionCondition.addPredefinedGlobalIdent("Win32"); | |
762 } | |
763 } | |
764 if (global.params.doDocComments) | |
765 VersionCondition.addPredefinedGlobalIdent("D_Ddoc"); | |
766 if (global.params.cov) | |
767 VersionCondition.addPredefinedGlobalIdent("D_Coverage"); | |
768 if (global.params.pic) | |
769 VersionCondition.addPredefinedGlobalIdent("D_PIC"); | |
770 version (DMDV2) { | |
771 if (global.params.useUnitTests) | |
772 VersionCondition.addPredefinedGlobalIdent("unittest"); | |
773 } | |
774 | |
775 // Initialization | |
776 Type.init(); | |
777 Id.initialize(); | |
778 initPrecedence(); | |
170 | 779 global.initClasssym(); |
0 | 780 |
781 backend_init(); | |
782 | |
783 //printf("%d source files\n",files.dim); | |
784 | |
785 // Build import search path | |
786 if (global.params.imppath) | |
787 { | |
788 for (int i = 0; i < global.params.imppath.dim; i++) | |
789 { | |
790 string path = (cast(String)global.params.imppath.data[i]).str; | |
791 string[] a = FileName.splitPath(path); | |
792 | |
793 global.path ~= a; | |
794 } | |
795 } | |
796 | |
797 // Build string import search path | |
798 if (global.params.fileImppath) | |
799 { | |
800 for (int i = 0; i < global.params.fileImppath.dim; i++) | |
801 { | |
802 string path = (cast(String)global.params.fileImppath.data[i]).str; | |
803 string[] a = FileName.splitPath(path); | |
804 | |
805 global.filePath ~= a; | |
806 } | |
807 } | |
808 | |
809 // Create Modules | |
810 Array modules = new Array(); | |
811 modules.reserve(files.dim); | |
812 int firstmodule = 1; | |
813 for (int i = 0; i < files.dim; i++) | |
814 { | |
815 string ext; | |
816 string name; | |
817 | |
818 String s = cast(String) files.data[i]; | |
819 string mp = s.str; | |
820 | |
114 | 821 version (Windows) { |
0 | 822 char[] copy = null; |
823 // Convert / to \ so linker will work | |
824 foreach (j, c; mp) | |
825 { | |
826 if (c == '/') { | |
827 if (copy is null) copy = mp.dup; | |
828 copy[j] = '\\'; | |
829 } | |
830 } | |
831 | |
832 if (copy !is null) mp = assumeUnique(copy); | |
833 } | |
834 string p = mp; | |
835 | |
836 p = FileName.name(p); // strip path | |
837 ext = FileName.ext(p); | |
838 | |
839 if (ext.length != 0) | |
840 { /* Deduce what to do with a file based on its extension | |
841 */ | |
842 if (FileName.equals(ext, global.obj_ext)) | |
843 { | |
844 global.params.objfiles.push(files.data[i]); | |
845 libmodules.push(files.data[i]); | |
846 continue; | |
847 } | |
848 | |
849 if (FileName.equals(ext, global.lib_ext)) | |
850 { | |
851 global.params.libfiles.push(files.data[i]); | |
852 libmodules.push(files.data[i]); | |
853 continue; | |
854 } | |
855 | |
856 if (ext == global.ddoc_ext) | |
857 { | |
858 global.params.ddocfiles.push(files.data[i]); | |
859 continue; | |
860 } | |
79 | 861 |
862 if (FileName.equals(ext, global.json_ext)) | |
863 { | |
864 global.params.doXGeneration = 1; | |
179 | 865 global.params.xfilename = (cast(String)files.data[i]).str; |
866 continue; | |
867 } | |
868 | |
869 if (FileName.equals(ext, global.map_ext)) | |
870 { | |
871 global.params.mapfile = (cast(String)files.data[i]).str; | |
79 | 872 continue; |
873 } | |
0 | 874 |
79 | 875 version (TARGET_WINDOS) |
876 { | |
0 | 877 if (FileName.equals(ext, "res")) |
878 { | |
179 | 879 global.params.resfile = (cast(String)files.data[i]).str; |
0 | 880 continue; |
881 } | |
882 | |
883 if (FileName.equals(ext, "def")) | |
884 { | |
179 | 885 global.params.deffile = (cast(String)files.data[i]).str; |
0 | 886 continue; |
887 } | |
888 | |
889 if (FileName.equals(ext, "exe")) | |
890 { | |
891 assert(0); // should have already been handled | |
892 } | |
893 } | |
894 | |
895 /* Examine extension to see if it is a valid | |
896 * D source file extension | |
897 */ | |
898 if (FileName.equals(ext, global.mars_ext) || | |
899 FileName.equals(ext, global.hdr_ext) || | |
900 FileName.equals(ext, "dd") || | |
901 FileName.equals(ext, "htm") || | |
902 FileName.equals(ext, "html") || | |
903 FileName.equals(ext, "xhtml")) | |
904 { | |
905 immutable(char)* e = ext.ptr; | |
906 e--; // skip onto '.' | |
907 assert(*e == '.'); | |
908 | |
909 immutable(char)* n = p.ptr; | |
910 | |
911 name = n[0..(e-n)]; // strip extension | |
912 | |
913 if (name.length == 0 || name == ".." || name == ".") | |
914 { | |
915 Linvalid: | |
916 error("invalid file name '%s'", (cast(String)files.data[i]).str); | |
917 fatal(); | |
918 } | |
919 } | |
920 else | |
921 { error("unrecognized file extension %s\n", ext); | |
922 fatal(); | |
923 } | |
924 } | |
925 else | |
926 { | |
927 name = p; | |
928 if (!*name) | |
929 goto Linvalid; | |
930 } | |
931 | |
932 /* At this point, name is the D source file name stripped of | |
933 * its path and extension. | |
934 */ | |
935 | |
936 Identifier id = new Identifier(name, TOK.TOKreserved); | |
937 m = new Module((cast(String) files.data[i]).str, id, global.params.doDocComments, global.params.doHdrGeneration); | |
938 modules.push(cast(void*)m); | |
939 | |
940 if (firstmodule) | |
941 { | |
942 global.params.objfiles.push(cast(void*)m.objfile.name); | |
943 firstmodule = 0; | |
944 } | |
945 } | |
946 | |
947 // Read files | |
948 //version = ASYNCREAD; | |
949 version (ASYNCREAD) { | |
950 // Multi threaded | |
951 AsyncRead *aw = AsyncRead.create(modules.dim); | |
952 for (i = 0; i < modules.dim; i++) | |
953 { | |
954 m = cast(Module *)modules.data[i]; | |
955 aw.addFile(m.srcfile); | |
956 } | |
957 aw.start(); | |
958 } else { | |
959 // Single threaded | |
960 for (int i = 0; i < modules.dim; i++) | |
961 { | |
962 m = cast(Module)modules.data[i]; | |
963 m.read(Loc(0)); | |
964 } | |
965 } | |
966 | |
967 // Parse files | |
968 int anydocfiles = 0; | |
969 for (int i = 0; i < modules.dim; i++) | |
970 { | |
971 m = cast(Module)modules.data[i]; | |
972 if (global.params.verbose) | |
973 writef("parse %s\n", m.toChars()); | |
169 | 974 if (!global.rootModule) |
975 global.rootModule = m; | |
0 | 976 m.importedFrom = m; |
977 if (!global.params.oneobj || i == 0 || m.isDocFile) | |
978 m.deleteObjFile(); | |
979 version (ASYNCREAD) { | |
980 if (aw.read(i)) | |
981 { | |
982 error("cannot read file %s", m.srcfile.name.toChars()); | |
983 } | |
984 } | |
985 | |
986 m.parse(); | |
987 if (m.isDocFile) | |
988 { | |
989 anydocfiles = 1; | |
990 m.gendocfile(); | |
991 | |
992 // Remove m from list of modules | |
993 modules.remove(i); | |
994 i--; | |
995 | |
996 // Remove m's object file from list of object files | |
997 for (int j = 0; j < global.params.objfiles.dim; j++) | |
998 { | |
999 if (m.objfile.name.str == (cast(FileName)global.params.objfiles.data[j]).str) | |
1000 { | |
1001 global.params.objfiles.remove(j); | |
1002 break; | |
1003 } | |
1004 } | |
1005 | |
1006 if (global.params.objfiles.dim == 0) | |
1007 global.params.link = 0; | |
1008 } | |
1009 } | |
1010 version (ASYNCREAD) { | |
1011 AsyncRead.dispose(aw); | |
1012 } | |
1013 | |
1014 if (anydocfiles && modules.dim && | |
1015 (global.params.oneobj || global.params.objname)) | |
1016 { | |
1017 error("conflicting Ddoc and obj generation options"); | |
1018 fatal(); | |
1019 } | |
1020 if (global.errors) | |
1021 fatal(); | |
79 | 1022 version (_DH) |
1023 { | |
0 | 1024 if (global.params.doHdrGeneration) |
1025 { | |
1026 /* Generate 'header' import files. | |
1027 * Since 'header' import files must be independent of command | |
1028 * line switches and what else is imported, they are generated | |
1029 * before any semantic analysis. | |
1030 */ | |
1031 for (i = 0; i < modules.dim; i++) | |
1032 { | |
79 | 1033 m = cast(Module)modules.data[i]; |
0 | 1034 if (global.params.verbose) |
1035 writef("import %s\n", m.toChars()); | |
1036 m.genhdrfile(); | |
1037 } | |
1038 } | |
1039 if (global.errors) | |
1040 fatal(); | |
1041 } | |
79 | 1042 //load all unconditional imports for better symbol resolving |
1043 for (int i = 0; i < modules.dim; i++) | |
1044 { | |
1045 m = cast(Module)modules.data[i]; | |
1046 if (global.params.verbose) | |
1047 writef("importall %s\n", m.toChars()); | |
1048 m.importAll(null); | |
1049 } | |
1050 if (global.errors) | |
1051 fatal(); | |
164 | 1052 |
0 | 1053 // Do semantic analysis |
1054 for (int i = 0; i < modules.dim; i++) | |
1055 { | |
1056 m = cast(Module)modules.data[i]; | |
1057 if (global.params.verbose) | |
1058 writef("semantic %s\n", m.toChars()); | |
1059 m.semantic(); | |
1060 } | |
1061 if (global.errors) | |
1062 fatal(); | |
164 | 1063 |
179 | 1064 global.dprogress = 1; |
1065 Module.runDeferredSemantic(); | |
1066 | |
0 | 1067 // Do pass 2 semantic analysis |
1068 for (int i = 0; i < modules.dim; i++) | |
1069 { | |
1070 m = cast(Module)modules.data[i]; | |
1071 if (global.params.verbose) | |
1072 writef("semantic2 %s\n", m.toChars()); | |
1073 m.semantic2(); | |
1074 } | |
1075 if (global.errors) | |
1076 fatal(); | |
1077 | |
1078 // Do pass 3 semantic analysis | |
1079 for (int i = 0; i < modules.dim; i++) | |
1080 { | |
1081 m = cast(Module)modules.data[i]; | |
1082 if (global.params.verbose) | |
1083 writef("semantic3 %s\n", m.toChars()); | |
1084 m.semantic3(); | |
1085 } | |
1086 if (global.errors) | |
1087 fatal(); | |
164 | 1088 |
0 | 1089 if (global.params.moduleDeps !is null) |
1090 { | |
1091 assert(global.params.moduleDepsFile !is null); | |
1092 | |
1093 File deps = new File(global.params.moduleDepsFile); | |
1094 OutBuffer ob = global.params.moduleDeps; | |
1095 deps.setbuffer(cast(void*)ob.data, ob.offset); | |
1096 deps.writev(); | |
1097 } | |
1098 | |
1099 | |
1100 // Scan for functions to inline | |
1101 if (global.params.useInline) | |
1102 { | |
1103 /* The problem with useArrayBounds and useAssert is that the | |
1104 * module being linked to may not have generated them, so if | |
1105 * we inline functions from those modules, the symbols for them will | |
1106 * not be found at link time. | |
1107 */ | |
1108 if (!global.params.useArrayBounds && !global.params.useAssert) | |
1109 { | |
1110 // Do pass 3 semantic analysis on all imported modules, | |
1111 // since otherwise functions in them cannot be inlined | |
169 | 1112 for (int i = 0; i < global.amodules.dim; i++) |
0 | 1113 { |
169 | 1114 m = cast(Module)global.amodules.data[i]; |
0 | 1115 if (global.params.verbose) |
1116 writef("semantic3 %s\n", m.toChars()); | |
1117 m.semantic3(); | |
1118 } | |
1119 if (global.errors) | |
1120 fatal(); | |
1121 } | |
1122 | |
1123 for (int i = 0; i < modules.dim; i++) | |
1124 { | |
1125 m = cast(Module)modules.data[i]; | |
1126 if (global.params.verbose) | |
1127 writef("inline scan %s\n", m.toChars()); | |
1128 | |
1129 m.inlineScan(); | |
1130 } | |
1131 } | |
1132 if (global.errors) | |
1133 fatal(); | |
1134 | |
1135 Library library = null; | |
1136 if (global.params.lib) | |
1137 { | |
1138 library = new Library(); | |
1139 library.setFilename(global.params.objdir, global.params.libname); | |
1140 | |
1141 // Add input object and input library files to output library | |
1142 for (int i = 0; i < libmodules.dim; i++) | |
1143 { | |
1144 string p = (cast(String)libmodules.data[i]).str; | |
1145 library.addObject(p, null, 0); | |
1146 } | |
1147 } | |
1148 | |
1149 // Generate output files | |
79 | 1150 if (global.params.doXGeneration) |
1151 json_generate(modules); | |
1152 | |
0 | 1153 if (global.params.oneobj) |
1154 { | |
1155 for (int i = 0; i < modules.dim; i++) | |
1156 { | |
1157 m = cast(Module)modules.data[i]; | |
1158 if (global.params.verbose) | |
1159 writef("code %s\n", m.toChars()); | |
1160 if (i == 0) | |
1161 obj_start(cast(char*)toStringz(m.srcfile.toChars())); | |
1162 m.genobjfile(0); | |
1163 if (!global.errors && global.params.doDocComments) | |
1164 m.gendocfile(); | |
1165 } | |
1166 if (!global.errors && modules.dim) | |
1167 { | |
1168 obj_end(library, (cast(Module)modules.data[0]).objfile); | |
1169 } | |
1170 } | |
1171 else | |
1172 { | |
1173 for (int i = 0; i < modules.dim; i++) | |
1174 { | |
1175 m = cast(Module)modules.data[i]; | |
1176 if (global.params.verbose) | |
1177 writef("code %s\n", m.toChars()); | |
1178 if (global.params.obj) | |
1179 { | |
1180 obj_start(cast(char*)toStringz(m.srcfile.toChars())); | |
1181 m.genobjfile(global.params.multiobj); | |
1182 obj_end(library, m.objfile); | |
1183 obj_write_deferred(library); | |
1184 } | |
1185 if (global.errors) | |
1186 { | |
1187 if (!global.params.lib) | |
1188 m.deleteObjFile(); | |
1189 } | |
1190 else | |
1191 { | |
1192 if (global.params.doDocComments) | |
1193 m.gendocfile(); | |
1194 } | |
1195 } | |
164 | 1196 } |
0 | 1197 |
1198 if (global.params.lib && !global.errors) | |
1199 library.write(); | |
1200 | |
1201 backend_term(); | |
1202 if (global.errors) | |
1203 fatal(); | |
1204 | |
1205 if (!global.params.objfiles.dim) | |
1206 { | |
1207 if (global.params.link) | |
1208 error("no object files to link"); | |
1209 } | |
1210 else | |
1211 { | |
1212 if (global.params.link) | |
1213 status = runLINK(); | |
1214 | |
1215 if (global.params.run) | |
1216 { | |
1217 if (!status) | |
1218 { | |
1219 status = runProgram(); | |
1220 | |
1221 /* Delete .obj files and .exe file | |
1222 */ | |
1223 for (int i = 0; i < modules.dim; i++) | |
1224 { | |
1225 m = cast(Module)modules.data[i]; | |
1226 m.deleteObjFile(); | |
1227 if (global.params.oneobj) | |
1228 break; | |
1229 } | |
1230 deleteExeFile(); | |
1231 } | |
1232 } | |
1233 } | |
1234 | |
1235 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:
4
diff
changeset
|
1236 } |