Mercurial > projects > ldc
comparison gen/main.cpp @ 1103:b30fe7e1dbb9
- Updated to DMD frontend 1.041.
- Removed dmd/inifile.c , it's not under a free license, replaced with libconfig based config file.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Thu, 12 Mar 2009 20:37:27 +0100 |
parents | aa31e5592994 |
children | dbe4af57b240 |
comparison
equal
deleted
inserted
replaced
1102:ae950bd712d3 | 1103:b30fe7e1dbb9 |
---|---|
19 #include <errno.h> | 19 #include <errno.h> |
20 #elif _WIN32 | 20 #elif _WIN32 |
21 #include <windows.h> | 21 #include <windows.h> |
22 #endif | 22 #endif |
23 | 23 |
24 #include "mem.h" | 24 #include "rmem.h" |
25 #include "root.h" | 25 #include "root.h" |
26 | 26 |
27 #include "mars.h" | 27 #include "mars.h" |
28 #include "module.h" | 28 #include "module.h" |
29 #include "mtype.h" | 29 #include "mtype.h" |
36 #include "gen/toobj.h" | 36 #include "gen/toobj.h" |
37 | 37 |
38 #include "gen/cl_options.h" | 38 #include "gen/cl_options.h" |
39 #include "gen/cl_helpers.h" | 39 #include "gen/cl_helpers.h" |
40 using namespace opts; | 40 using namespace opts; |
41 | |
42 #include "gen/configfile.h" | |
41 | 43 |
42 extern void getenv_setargv(const char *envvar, int *pargc, char** *pargv); | 44 extern void getenv_setargv(const char *envvar, int *pargc, char** *pargv); |
43 extern void backend_init(); | 45 extern void backend_init(); |
44 extern void backend_term(); | 46 extern void backend_term(); |
45 | 47 |
142 VersionCondition::addPredefinedGlobalIdent("all"); | 144 VersionCondition::addPredefinedGlobalIdent("all"); |
143 #if DMDV2 | 145 #if DMDV2 |
144 VersionCondition::addPredefinedGlobalIdent("D_Version2"); | 146 VersionCondition::addPredefinedGlobalIdent("D_Version2"); |
145 #endif | 147 #endif |
146 | 148 |
147 | 149 // merge DFLAGS environment variable into argc/argv |
148 // read the inifile | |
149 #if DMDV2 | |
150 inifile(global.params.argv0, "ldc2.conf"); | |
151 #else | |
152 inifile(global.params.argv0, "ldc.conf"); | |
153 #endif | |
154 | |
155 // merge DFLAGS into argc/argv | |
156 getenv_setargv("DFLAGS", &argc, &argv); | 150 getenv_setargv("DFLAGS", &argc, &argv); |
157 #if 0 | 151 #if 0 |
158 for (int i = 0; i < argc; i++) | 152 for (int i = 0; i < argc; i++) |
159 { | 153 { |
160 printf("argv[%d] = '%s'\n", i, argv[i]); | 154 printf("argv[%d] = '%s'\n", i, argv[i]); |
161 } | 155 } |
162 #endif | 156 #endif |
163 | 157 |
158 // build complete fixed up list of command line arguments | |
159 std::vector<const char*> final_args; | |
160 final_args.reserve(argc); | |
161 | |
162 // insert argc + DFLAGS | |
163 final_args.insert(final_args.end(), &argv[0], &argv[argc]); | |
164 | |
165 // read the configuration file | |
166 ConfigFile cfg_file; | |
167 | |
168 // just ignore errors for now, they are still printed | |
169 #if DMDV2 | |
170 #define CFG_FILENAME "ldc2.conf" | |
171 #else | |
172 #define CFG_FILENAME "ldc.conf" | |
173 #endif | |
174 cfg_file.read(global.params.argv0, (void*)main, CFG_FILENAME); | |
175 #undef CFG_FILENAME | |
176 | |
177 // insert config file additions to the argument list | |
178 final_args.insert(final_args.end(), cfg_file.switches_begin(), cfg_file.switches_end()); | |
179 | |
180 #if 0 | |
181 for (size_t i = 0; i < final_args.size(); ++i) | |
182 { | |
183 printf("final_args[%zu] = %s\n", i, final_args[i]); | |
184 } | |
185 #endif | |
186 | |
164 // Handle fixed-up arguments! | 187 // Handle fixed-up arguments! |
165 cl::SetVersionPrinter(&printVersion); | 188 cl::SetVersionPrinter(&printVersion); |
166 cl::ParseCommandLineOptions(argc, argv, "LLVM-based D Compiler\n"); | 189 cl::ParseCommandLineOptions(final_args.size(), (char**)&final_args[0], "LLVM-based D Compiler\n", true); |
167 | 190 |
168 global.params.optimize = (global.params.optimizeLevel >= 0); | 191 global.params.optimize = (global.params.optimizeLevel >= 0); |
169 | 192 |
170 // Negated options | 193 // Negated options |
171 global.params.link = !compileOnly; | 194 global.params.link = !compileOnly; |