Mercurial > projects > ddmd
annotate main.d @ 178:e3afd1303184
Many small bugs fixed
Made all classes derive from TObject to detect memory leaks (functionality is disabled for now)
Began work on overriding backend memory allocations (to avoid memory leaks)
author | korDen |
---|---|
date | Sun, 17 Oct 2010 07:42:00 +0400 |
parents | 96c0fff6897d |
children | cd48cb899aee |
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 ///} | |
340 else if (arg == "multiobj") | |
341 global.params.multiobj = 1; | |
342 else if (arg == "g") | |
343 global.params.symdebug = 1; | |
344 else if (arg == "gc") | |
345 global.params.symdebug = 2; | |
346 else if (arg == "gt") | |
347 { error("use -profile instead of -gt\n"); | |
348 global.params.trace = 1; | |
349 } | |
350 else if (arg == "m64") | |
351 global.params.isX86_64 = 1; | |
352 else if (arg == "profile") | |
353 global.params.trace = 1; | |
354 else if (arg == "v") | |
355 global.params.verbose = 1; | |
356 ///version (DMDV2) { | |
357 else if (arg == "vtls") | |
358 global.params.vtls = 1; | |
359 ///} | |
360 else if (arg == "v1") | |
361 { | |
362 version (DMDV1) { | |
363 global.params.Dversion = 1; | |
364 } else { | |
365 error("use DMD 1.0 series compilers for -v1 switch"); | |
366 break; | |
367 } | |
368 } | |
369 else if (arg == "w") | |
370 global.params.warnings = 1; | |
371 else if (arg == "O") | |
372 global.params.optimize = 1; | |
373 else if (p[1] == 'o') | |
374 { | |
375 switch (p[2]) | |
376 { | |
377 case '-': | |
378 global.params.obj = 0; | |
379 break; | |
380 | |
381 case 'd': | |
382 if (!p[3]) | |
383 goto Lnoarg; | |
384 global.params.objdir = arg[(p - arg.ptr) + 3..$]; | |
385 break; | |
386 | |
387 case 'f': | |
388 { | |
389 if (!p[3]) | |
390 goto Lnoarg; | |
391 | |
392 global.params.objname = arg[(p - arg.ptr) + 3..$]; | |
393 break; | |
394 } | |
395 | |
396 case 'p': | |
397 if (p[3]) | |
398 goto Lerror; | |
399 global.params.preservePaths = 1; | |
400 break; | |
401 | |
402 case 0: | |
403 error("-o no longer supported, use -of or -od"); | |
404 break; | |
405 | |
406 default: | |
407 goto Lerror; | |
408 } | |
409 } | |
410 else if (p[1] == 'D') | |
411 { global.params.doDocComments = 1; | |
412 switch (p[2]) | |
413 { | |
414 case 'd': | |
415 if (!p[3]) | |
416 goto Lnoarg; | |
417 global.params.docdir = arg[(p - arg.ptr) + 3..$]; | |
418 break; | |
419 case 'f': | |
420 if (!p[3]) | |
421 goto Lnoarg; | |
422 global.params.docname = arg[(p - arg.ptr) + 3..$]; | |
423 break; | |
424 | |
425 case 0: | |
426 break; | |
427 | |
428 default: | |
429 goto Lerror; | |
430 } | |
431 } | |
432 ///version (_DH) { | |
433 else if (p[1] == 'H') | |
434 { global.params.doHdrGeneration = 1; | |
435 switch (p[2]) | |
436 { | |
437 case 'd': | |
438 if (!p[3]) | |
439 goto Lnoarg; | |
440 global.params.hdrdir = arg[(p - arg.ptr) + 3..$]; | |
441 break; | |
442 | |
443 case 'f': | |
444 if (!p[3]) | |
445 goto Lnoarg; | |
446 global.params.hdrname = arg[(p - arg.ptr) + 3..$]; | |
447 break; | |
448 | |
449 case 0: | |
450 break; | |
451 | |
452 default: | |
453 goto Lerror; | |
454 } | |
455 } | |
456 ///} | |
79 | 457 else if (p[1] == 'X') |
458 { | |
459 global.params.doXGeneration = 1; | |
460 switch (p[2]) | |
461 { | |
462 case 'f': | |
463 if (!p[3]) | |
464 goto Lnoarg; | |
465 global.params.xfilename = arg[(p - arg.ptr) + 3..$]; | |
466 break; | |
467 | |
468 case 0: | |
469 break; | |
470 | |
471 default: | |
472 goto Lerror; | |
473 } | |
474 } | |
475 | |
0 | 476 else if (arg == "ignore") |
477 global.params.ignoreUnsupportedPragmas = 1; | |
478 else if (arg == "inline") | |
479 global.params.useInline = 1; | |
480 else if (arg == "lib") | |
481 global.params.lib = 1; | |
482 else if (arg == "nofloat") | |
483 global.params.nofloat = 1; | |
484 else if (arg == "quiet") | |
485 global.params.quiet = 1; | |
486 else if (arg == "release") | |
487 global.params.release = 1; | |
488 ///version (DMDV2) { | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
489 else if (arg == "noboundscheck") |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
490 noboundscheck = 1; |
0 | 491 ///} |
492 else if (arg == "unittest") | |
493 global.params.useUnitTests = 1; | |
494 else if (p[1] == 'I') | |
495 { | |
496 global.params.imppath.push(cast(void*)new String(arg[(p - arg.ptr) + 2..$])); /// | |
497 } | |
498 else if (p[1] == 'J') | |
499 { | |
500 if (!global.params.fileImppath) | |
501 global.params.fileImppath = new Array(); | |
502 global.params.fileImppath.push(cast(void*)new String(arg[(p - arg.ptr) + 2..$])); | |
503 } | |
504 else if (memcmp(p + 1, "debug".ptr, 5) == 0 && p[6] != 'l') | |
505 { | |
506 // Parse: | |
507 // -debug | |
508 // -debug=number | |
509 // -debug=identifier | |
510 if (p[6] == '=') | |
511 { | |
512 if (isdigit(p[7])) | |
513 { long level; | |
514 | |
515 errno = 0; | |
516 level = strtol(p + 7, cast(char**)&p, 10); | |
517 if (*p || errno || level > INT_MAX) | |
518 goto Lerror; | |
519 DebugCondition.setGlobalLevel(cast(int)level); | |
520 } | |
521 else if (Lexer.isValidIdentifier(arg[(p - arg.ptr) + 7..$])) /// | |
522 DebugCondition.addGlobalIdent(p + 7); | |
523 else | |
524 goto Lerror; | |
525 } | |
526 else if (p[6]) | |
527 goto Lerror; | |
528 else | |
529 global.params.debuglevel = 1; | |
530 } | |
531 else if (memcmp(p + 1, "version".ptr, 5) == 0) | |
532 { | |
533 // Parse: | |
534 // -version=number | |
535 // -version=identifier | |
536 if (p[8] == '=') | |
537 { | |
538 if (isdigit(p[9])) | |
539 { long level; | |
540 | |
541 errno = 0; | |
542 level = strtol(p + 9, cast(char**)&p, 10); /// | |
543 if (*p || errno || level > INT_MAX) | |
544 goto Lerror; | |
545 VersionCondition.setGlobalLevel(cast(int)level); | |
546 } | |
547 else if (Lexer.isValidIdentifier(arg[(p - arg.ptr) + 9..$])) /// | |
548 VersionCondition.addGlobalIdent(arg[(p - arg.ptr) + 9..$]); | |
549 else | |
550 goto Lerror; | |
551 } | |
552 else | |
553 goto Lerror; | |
554 } | |
555 else if (arg == "-b") | |
556 global.params.debugb = 1; | |
557 else if (arg == "-c") | |
558 global.params.debugc = 1; | |
559 else if (arg == "-f") | |
560 global.params.debugf = 1; | |
561 else if (arg == "-help") | |
562 { usage(); | |
563 exit(EXIT_SUCCESS); | |
564 } | |
565 else if (arg == "-r") | |
566 global.params.debugr = 1; | |
567 else if (arg == "-x") | |
568 global.params.debugx = 1; | |
569 else if (arg == "-y") | |
570 global.params.debugy = 1; | |
571 else if (p[1] == 'L') | |
572 { | |
573 global.params.linkswitches.push(cast(void*)p + 2); | |
574 } | |
575 else if (memcmp(p + 1, "defaultlib=".ptr, 11) == 0) | |
576 { | |
577 global.params.defaultlibname = p + 1 + 11; | |
578 } | |
579 else if (memcmp(p + 1, "debuglib=".ptr, 9) == 0) | |
580 { | |
581 setdebuglib = 1; | |
582 global.params.debuglibname = p + 1 + 9; | |
583 } | |
584 else if (memcmp(p + 1, "deps=".ptr, 5) == 0) | |
585 { | |
586 global.params.moduleDepsFile = arg[(p - arg.ptr) + 1 + 5..$]; | |
587 if (!global.params.moduleDepsFile[0]) | |
588 goto Lnoarg; | |
589 global.params.moduleDeps = new OutBuffer; | |
590 } | |
591 else if (memcmp(p + 1, "man".ptr, 3) == 0) | |
592 { | |
114 | 593 version (Windows) { |
0 | 594 version (DMDV1) { |
595 browse("http://www.digitalmars.com/d/1.0/dmd-windows.html"); | |
596 } else { | |
597 browse("http://www.digitalmars.com/d/2.0/dmd-windows.html"); | |
598 } | |
599 } | |
600 version (linux) { | |
601 version (DMDV1) { | |
602 browse("http://www.digitalmars.com/d/1.0/dmd-linux.html"); | |
603 } else { | |
604 browse("http://www.digitalmars.com/d/2.0/dmd-linux.html"); | |
605 } | |
606 } | |
607 version (__APPLE__) { | |
608 version (DMDV1) { | |
609 browse("http://www.digitalmars.com/d/1.0/dmd-osx.html"); | |
610 } else { | |
611 browse("http://www.digitalmars.com/d/2.0/dmd-osx.html"); | |
612 } | |
613 } | |
614 version (__FreeBSD__) { | |
615 version (DMDV1) { | |
616 browse("http://www.digitalmars.com/d/1.0/dmd-freebsd.html"); | |
617 } else { | |
618 browse("http://www.digitalmars.com/d/2.0/dmd-freebsd.html"); | |
619 } | |
620 } | |
621 exit(EXIT_SUCCESS); | |
622 } | |
623 else if (arg == "run") | |
624 { global.params.run = 1; | |
625 global.params.runargs_length = ((i >= argcstart) ? args.length : argcstart) - i - 1; | |
626 if (global.params.runargs_length) | |
627 { | |
628 files.push(cast(void*)args[i + 1].ptr); | |
629 global.params.runargs = args[i + 2..$]; | |
630 i += global.params.runargs_length; | |
631 global.params.runargs_length--; | |
632 } | |
633 else | |
634 { global.params.run = 0; | |
635 goto Lnoarg; | |
636 } | |
637 } | |
638 else | |
639 { | |
640 Lerror: | |
641 error("unrecognized switch '%s'", args[i]); | |
642 continue; | |
643 | |
644 Lnoarg: | |
645 error("argument expected for switch '%s'", args[i]); | |
646 continue; | |
647 } | |
648 } | |
649 else | |
650 { | |
651 version (TARGET_WINDOS) { | |
652 string ext = FileName.ext(p[0..arg.length]); | |
653 if (ext != null && FileName.compare(ext, "exe") == 0) | |
654 { | |
655 global.params.objname = arg[(p - arg.ptr)..$]; | |
656 continue; | |
657 } | |
658 } | |
659 files.push(cast(void*)new String(arg[(p - arg.ptr)..$])); | |
660 } | |
661 } | |
662 if (global.errors) | |
663 { | |
664 fatal(); | |
665 } | |
666 if (files.dim == 0) | |
667 { usage(); | |
668 return EXIT_FAILURE; | |
669 } | |
670 | |
671 if (!setdebuglib) | |
672 global.params.debuglibname = global.params.defaultlibname; | |
673 | |
674 version (TARGET_OSX) { | |
675 global.params.pic = 1; | |
676 } | |
677 | |
678 if (global.params.release) | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
679 { |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
680 global.params.useInvariants = 0; |
0 | 681 global.params.useIn = 0; |
682 global.params.useOut = 0; | |
683 global.params.useAssert = 0; | |
684 global.params.useArrayBounds = 0; | |
685 global.params.useSwitchError = 0; | |
686 } | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
687 |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
688 if (noboundscheck) |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
689 global.params.useArrayBounds = 0; |
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
690 |
0 | 691 if (global.params.run) |
692 global.params.quiet = 1; | |
693 | |
694 if (global.params.useUnitTests) | |
695 global.params.useAssert = 1; | |
696 | |
697 if (!global.params.obj || global.params.lib) | |
698 global.params.link = 0; | |
699 | |
700 if (global.params.link) | |
701 { | |
702 global.params.exefile = global.params.objname; | |
703 global.params.oneobj = 1; | |
704 if (global.params.objname) | |
705 { | |
706 /* Use this to name the one object file with the same | |
707 * name as the exe file. | |
708 */ | |
709 global.params.objname = FileName.forceExt(global.params.objname, global.obj_ext).toChars(); | |
710 | |
711 /* If output directory is given, use that path rather than | |
712 * the exe file path. | |
713 */ | |
714 if (global.params.objdir) | |
715 { | |
716 string name = FileName.name(global.params.objname); | |
717 global.params.objname = FileName.combine(global.params.objdir, name); | |
718 } | |
719 } | |
720 } | |
721 else if (global.params.lib) | |
722 { | |
723 global.params.libname = global.params.objname; | |
724 global.params.objname = null; | |
725 | |
726 // Haven't investigated handling these options with multiobj | |
727 if (!global.params.cov && !global.params.trace) | |
728 global.params.multiobj = 1; | |
729 } | |
730 else if (global.params.run) | |
731 { | |
732 error("flags conflict with -run"); | |
733 fatal(); | |
734 } | |
735 else | |
736 { | |
737 if (global.params.objname && files.dim > 1) | |
738 { | |
739 global.params.oneobj = 1; | |
740 //error("multiple source files, but only one .obj name"); | |
741 //fatal(); | |
742 } | |
743 } | |
744 if (global.params.isX86_64) | |
745 { | |
746 VersionCondition.addPredefinedGlobalIdent("D_InlineAsm_X86_64"); | |
747 VersionCondition.addPredefinedGlobalIdent("X86_64"); | |
748 VersionCondition.addPredefinedGlobalIdent("D_LP64"); | |
749 version (TARGET_WINDOS) { | |
750 VersionCondition.addPredefinedGlobalIdent("Win64"); | |
751 } | |
752 } | |
753 else | |
754 { | |
755 VersionCondition.addPredefinedGlobalIdent("D_InlineAsm"); | |
756 VersionCondition.addPredefinedGlobalIdent("D_InlineAsm_X86"); | |
757 VersionCondition.addPredefinedGlobalIdent("X86"); | |
758 version (TARGET_WINDOS) { | |
759 VersionCondition.addPredefinedGlobalIdent("Win32"); | |
760 } | |
761 } | |
762 if (global.params.doDocComments) | |
763 VersionCondition.addPredefinedGlobalIdent("D_Ddoc"); | |
764 if (global.params.cov) | |
765 VersionCondition.addPredefinedGlobalIdent("D_Coverage"); | |
766 if (global.params.pic) | |
767 VersionCondition.addPredefinedGlobalIdent("D_PIC"); | |
768 version (DMDV2) { | |
769 if (global.params.useUnitTests) | |
770 VersionCondition.addPredefinedGlobalIdent("unittest"); | |
771 } | |
772 | |
773 // Initialization | |
774 Type.init(); | |
775 Id.initialize(); | |
776 initPrecedence(); | |
170 | 777 global.initClasssym(); |
0 | 778 |
779 backend_init(); | |
780 | |
781 //printf("%d source files\n",files.dim); | |
782 | |
783 // Build import search path | |
784 if (global.params.imppath) | |
785 { | |
786 for (int i = 0; i < global.params.imppath.dim; i++) | |
787 { | |
788 string path = (cast(String)global.params.imppath.data[i]).str; | |
789 string[] a = FileName.splitPath(path); | |
790 | |
791 global.path ~= a; | |
792 } | |
793 } | |
794 | |
795 // Build string import search path | |
796 if (global.params.fileImppath) | |
797 { | |
798 for (int i = 0; i < global.params.fileImppath.dim; i++) | |
799 { | |
800 string path = (cast(String)global.params.fileImppath.data[i]).str; | |
801 string[] a = FileName.splitPath(path); | |
802 | |
803 global.filePath ~= a; | |
804 } | |
805 } | |
806 | |
807 // Create Modules | |
808 Array modules = new Array(); | |
809 modules.reserve(files.dim); | |
810 int firstmodule = 1; | |
811 for (int i = 0; i < files.dim; i++) | |
812 { | |
813 string ext; | |
814 string name; | |
815 | |
816 String s = cast(String) files.data[i]; | |
817 string mp = s.str; | |
818 | |
114 | 819 version (Windows) { |
0 | 820 char[] copy = null; |
821 // Convert / to \ so linker will work | |
822 foreach (j, c; mp) | |
823 { | |
824 if (c == '/') { | |
825 if (copy is null) copy = mp.dup; | |
826 copy[j] = '\\'; | |
827 } | |
828 } | |
829 | |
830 if (copy !is null) mp = assumeUnique(copy); | |
831 } | |
832 string p = mp; | |
833 | |
834 p = FileName.name(p); // strip path | |
835 ext = FileName.ext(p); | |
836 | |
837 if (ext.length != 0) | |
838 { /* Deduce what to do with a file based on its extension | |
839 */ | |
840 if (FileName.equals(ext, global.obj_ext)) | |
841 { | |
842 global.params.objfiles.push(files.data[i]); | |
843 libmodules.push(files.data[i]); | |
844 continue; | |
845 } | |
846 | |
847 if (FileName.equals(ext, global.lib_ext)) | |
848 { | |
849 global.params.libfiles.push(files.data[i]); | |
850 libmodules.push(files.data[i]); | |
851 continue; | |
852 } | |
853 | |
854 if (ext == global.ddoc_ext) | |
855 { | |
856 global.params.ddocfiles.push(files.data[i]); | |
857 continue; | |
858 } | |
79 | 859 |
860 if (FileName.equals(ext, global.json_ext)) | |
861 { | |
862 global.params.doXGeneration = 1; | |
863 global.params.xfilename = (cast(immutable(char)*)files.data[i])[0..0]; | |
864 continue; | |
865 } | |
0 | 866 |
79 | 867 version (TARGET_WINDOS) |
868 { | |
0 | 869 if (FileName.equals(ext, "res")) |
870 { | |
871 global.params.resfile = (cast(immutable(char)*)files.data[i])[0..0]; /// !!! | |
872 continue; | |
873 } | |
874 | |
875 if (FileName.equals(ext, "def")) | |
876 { | |
877 global.params.deffile = (cast(immutable(char)*)files.data[i])[0..0]; | |
878 continue; | |
879 } | |
880 | |
881 if (FileName.equals(ext, "exe")) | |
882 { | |
883 assert(0); // should have already been handled | |
884 } | |
885 } | |
886 | |
887 /* Examine extension to see if it is a valid | |
888 * D source file extension | |
889 */ | |
890 if (FileName.equals(ext, global.mars_ext) || | |
891 FileName.equals(ext, global.hdr_ext) || | |
892 FileName.equals(ext, "dd") || | |
893 FileName.equals(ext, "htm") || | |
894 FileName.equals(ext, "html") || | |
895 FileName.equals(ext, "xhtml")) | |
896 { | |
897 immutable(char)* e = ext.ptr; | |
898 e--; // skip onto '.' | |
899 assert(*e == '.'); | |
900 | |
901 immutable(char)* n = p.ptr; | |
902 | |
903 name = n[0..(e-n)]; // strip extension | |
904 | |
905 if (name.length == 0 || name == ".." || name == ".") | |
906 { | |
907 Linvalid: | |
908 error("invalid file name '%s'", (cast(String)files.data[i]).str); | |
909 fatal(); | |
910 } | |
911 } | |
912 else | |
913 { error("unrecognized file extension %s\n", ext); | |
914 fatal(); | |
915 } | |
916 } | |
917 else | |
918 { | |
919 name = p; | |
920 if (!*name) | |
921 goto Linvalid; | |
922 } | |
923 | |
924 /* At this point, name is the D source file name stripped of | |
925 * its path and extension. | |
926 */ | |
927 | |
928 Identifier id = new Identifier(name, TOK.TOKreserved); | |
929 m = new Module((cast(String) files.data[i]).str, id, global.params.doDocComments, global.params.doHdrGeneration); | |
930 modules.push(cast(void*)m); | |
931 | |
932 if (firstmodule) | |
933 { | |
934 global.params.objfiles.push(cast(void*)m.objfile.name); | |
935 firstmodule = 0; | |
936 } | |
937 } | |
938 | |
939 // Read files | |
940 //version = ASYNCREAD; | |
941 version (ASYNCREAD) { | |
942 // Multi threaded | |
943 AsyncRead *aw = AsyncRead.create(modules.dim); | |
944 for (i = 0; i < modules.dim; i++) | |
945 { | |
946 m = cast(Module *)modules.data[i]; | |
947 aw.addFile(m.srcfile); | |
948 } | |
949 aw.start(); | |
950 } else { | |
951 // Single threaded | |
952 for (int i = 0; i < modules.dim; i++) | |
953 { | |
954 m = cast(Module)modules.data[i]; | |
955 m.read(Loc(0)); | |
956 } | |
957 } | |
958 | |
959 // Parse files | |
960 int anydocfiles = 0; | |
961 for (int i = 0; i < modules.dim; i++) | |
962 { | |
963 m = cast(Module)modules.data[i]; | |
964 if (global.params.verbose) | |
965 writef("parse %s\n", m.toChars()); | |
169 | 966 if (!global.rootModule) |
967 global.rootModule = m; | |
0 | 968 m.importedFrom = m; |
969 if (!global.params.oneobj || i == 0 || m.isDocFile) | |
970 m.deleteObjFile(); | |
971 version (ASYNCREAD) { | |
972 if (aw.read(i)) | |
973 { | |
974 error("cannot read file %s", m.srcfile.name.toChars()); | |
975 } | |
976 } | |
977 | |
978 m.parse(); | |
979 if (m.isDocFile) | |
980 { | |
981 anydocfiles = 1; | |
982 m.gendocfile(); | |
983 | |
984 // Remove m from list of modules | |
985 modules.remove(i); | |
986 i--; | |
987 | |
988 // Remove m's object file from list of object files | |
989 for (int j = 0; j < global.params.objfiles.dim; j++) | |
990 { | |
991 if (m.objfile.name.str == (cast(FileName)global.params.objfiles.data[j]).str) | |
992 { | |
993 global.params.objfiles.remove(j); | |
994 break; | |
995 } | |
996 } | |
997 | |
998 if (global.params.objfiles.dim == 0) | |
999 global.params.link = 0; | |
1000 } | |
1001 } | |
1002 version (ASYNCREAD) { | |
1003 AsyncRead.dispose(aw); | |
1004 } | |
1005 | |
1006 if (anydocfiles && modules.dim && | |
1007 (global.params.oneobj || global.params.objname)) | |
1008 { | |
1009 error("conflicting Ddoc and obj generation options"); | |
1010 fatal(); | |
1011 } | |
1012 if (global.errors) | |
1013 fatal(); | |
79 | 1014 version (_DH) |
1015 { | |
0 | 1016 if (global.params.doHdrGeneration) |
1017 { | |
1018 /* Generate 'header' import files. | |
1019 * Since 'header' import files must be independent of command | |
1020 * line switches and what else is imported, they are generated | |
1021 * before any semantic analysis. | |
1022 */ | |
1023 for (i = 0; i < modules.dim; i++) | |
1024 { | |
79 | 1025 m = cast(Module)modules.data[i]; |
0 | 1026 if (global.params.verbose) |
1027 writef("import %s\n", m.toChars()); | |
1028 m.genhdrfile(); | |
1029 } | |
1030 } | |
1031 if (global.errors) | |
1032 fatal(); | |
1033 } | |
79 | 1034 //load all unconditional imports for better symbol resolving |
1035 for (int i = 0; i < modules.dim; i++) | |
1036 { | |
1037 m = cast(Module)modules.data[i]; | |
1038 if (global.params.verbose) | |
1039 writef("importall %s\n", m.toChars()); | |
1040 m.importAll(null); | |
1041 } | |
1042 if (global.errors) | |
1043 fatal(); | |
164 | 1044 |
0 | 1045 // Do semantic analysis |
1046 for (int i = 0; i < modules.dim; i++) | |
1047 { | |
1048 m = cast(Module)modules.data[i]; | |
1049 if (global.params.verbose) | |
1050 writef("semantic %s\n", m.toChars()); | |
1051 m.semantic(); | |
1052 } | |
1053 if (global.errors) | |
1054 fatal(); | |
164 | 1055 |
0 | 1056 // Do pass 2 semantic analysis |
1057 for (int i = 0; i < modules.dim; i++) | |
1058 { | |
1059 m = cast(Module)modules.data[i]; | |
1060 if (global.params.verbose) | |
1061 writef("semantic2 %s\n", m.toChars()); | |
1062 m.semantic2(); | |
1063 } | |
1064 if (global.errors) | |
1065 fatal(); | |
1066 | |
1067 // Do pass 3 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("semantic3 %s\n", m.toChars()); | |
1073 m.semantic3(); | |
1074 } | |
1075 if (global.errors) | |
1076 fatal(); | |
164 | 1077 |
0 | 1078 if (global.params.moduleDeps !is null) |
1079 { | |
1080 assert(global.params.moduleDepsFile !is null); | |
1081 | |
1082 File deps = new File(global.params.moduleDepsFile); | |
1083 OutBuffer ob = global.params.moduleDeps; | |
1084 deps.setbuffer(cast(void*)ob.data, ob.offset); | |
1085 deps.writev(); | |
1086 } | |
1087 | |
1088 | |
1089 // Scan for functions to inline | |
1090 if (global.params.useInline) | |
1091 { | |
1092 /* The problem with useArrayBounds and useAssert is that the | |
1093 * module being linked to may not have generated them, so if | |
1094 * we inline functions from those modules, the symbols for them will | |
1095 * not be found at link time. | |
1096 */ | |
1097 if (!global.params.useArrayBounds && !global.params.useAssert) | |
1098 { | |
1099 // Do pass 3 semantic analysis on all imported modules, | |
1100 // since otherwise functions in them cannot be inlined | |
169 | 1101 for (int i = 0; i < global.amodules.dim; i++) |
0 | 1102 { |
169 | 1103 m = cast(Module)global.amodules.data[i]; |
0 | 1104 if (global.params.verbose) |
1105 writef("semantic3 %s\n", m.toChars()); | |
1106 m.semantic3(); | |
1107 } | |
1108 if (global.errors) | |
1109 fatal(); | |
1110 } | |
1111 | |
1112 for (int i = 0; i < modules.dim; i++) | |
1113 { | |
1114 m = cast(Module)modules.data[i]; | |
1115 if (global.params.verbose) | |
1116 writef("inline scan %s\n", m.toChars()); | |
1117 | |
1118 m.inlineScan(); | |
1119 } | |
1120 } | |
1121 if (global.errors) | |
1122 fatal(); | |
1123 | |
1124 Library library = null; | |
1125 if (global.params.lib) | |
1126 { | |
1127 library = new Library(); | |
1128 library.setFilename(global.params.objdir, global.params.libname); | |
1129 | |
1130 // Add input object and input library files to output library | |
1131 for (int i = 0; i < libmodules.dim; i++) | |
1132 { | |
1133 string p = (cast(String)libmodules.data[i]).str; | |
1134 library.addObject(p, null, 0); | |
1135 } | |
1136 } | |
1137 | |
1138 // Generate output files | |
79 | 1139 if (global.params.doXGeneration) |
1140 json_generate(modules); | |
1141 | |
0 | 1142 if (global.params.oneobj) |
1143 { | |
1144 for (int i = 0; i < modules.dim; i++) | |
1145 { | |
1146 m = cast(Module)modules.data[i]; | |
1147 if (global.params.verbose) | |
1148 writef("code %s\n", m.toChars()); | |
1149 if (i == 0) | |
1150 obj_start(cast(char*)toStringz(m.srcfile.toChars())); | |
1151 m.genobjfile(0); | |
1152 if (!global.errors && global.params.doDocComments) | |
1153 m.gendocfile(); | |
1154 } | |
1155 if (!global.errors && modules.dim) | |
1156 { | |
1157 obj_end(library, (cast(Module)modules.data[0]).objfile); | |
1158 } | |
1159 } | |
1160 else | |
1161 { | |
1162 for (int i = 0; i < modules.dim; i++) | |
1163 { | |
1164 m = cast(Module)modules.data[i]; | |
1165 if (global.params.verbose) | |
1166 writef("code %s\n", m.toChars()); | |
1167 if (global.params.obj) | |
1168 { | |
1169 obj_start(cast(char*)toStringz(m.srcfile.toChars())); | |
1170 m.genobjfile(global.params.multiobj); | |
1171 obj_end(library, m.objfile); | |
1172 obj_write_deferred(library); | |
1173 } | |
1174 if (global.errors) | |
1175 { | |
1176 if (!global.params.lib) | |
1177 m.deleteObjFile(); | |
1178 } | |
1179 else | |
1180 { | |
1181 if (global.params.doDocComments) | |
1182 m.gendocfile(); | |
1183 } | |
1184 } | |
164 | 1185 } |
0 | 1186 |
1187 if (global.params.lib && !global.errors) | |
1188 library.write(); | |
1189 | |
1190 backend_term(); | |
1191 if (global.errors) | |
1192 fatal(); | |
1193 | |
1194 if (!global.params.objfiles.dim) | |
1195 { | |
1196 if (global.params.link) | |
1197 error("no object files to link"); | |
1198 } | |
1199 else | |
1200 { | |
1201 if (global.params.link) | |
1202 status = runLINK(); | |
1203 | |
1204 if (global.params.run) | |
1205 { | |
1206 if (!status) | |
1207 { | |
1208 status = runProgram(); | |
1209 | |
1210 /* Delete .obj files and .exe file | |
1211 */ | |
1212 for (int i = 0; i < modules.dim; i++) | |
1213 { | |
1214 m = cast(Module)modules.data[i]; | |
1215 m.deleteObjFile(); | |
1216 if (global.params.oneobj) | |
1217 break; | |
1218 } | |
1219 deleteExeFile(); | |
1220 } | |
1221 } | |
1222 } | |
1223 | |
1224 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
|
1225 } |