Mercurial > projects > ldc
diff 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 |
line wrap: on
line diff
--- a/gen/main.cpp Thu Mar 12 14:08:57 2009 +0100 +++ b/gen/main.cpp Thu Mar 12 20:37:27 2009 +0100 @@ -21,7 +21,7 @@ #include <windows.h> #endif -#include "mem.h" +#include "rmem.h" #include "root.h" #include "mars.h" @@ -39,6 +39,8 @@ #include "gen/cl_helpers.h" using namespace opts; +#include "gen/configfile.h" + extern void getenv_setargv(const char *envvar, int *pargc, char** *pargv); extern void backend_init(); extern void backend_term(); @@ -144,15 +146,7 @@ VersionCondition::addPredefinedGlobalIdent("D_Version2"); #endif - - // read the inifile -#if DMDV2 - inifile(global.params.argv0, "ldc2.conf"); -#else - inifile(global.params.argv0, "ldc.conf"); -#endif - - // merge DFLAGS into argc/argv + // merge DFLAGS environment variable into argc/argv getenv_setargv("DFLAGS", &argc, &argv); #if 0 for (int i = 0; i < argc; i++) @@ -161,9 +155,38 @@ } #endif + // build complete fixed up list of command line arguments + std::vector<const char*> final_args; + final_args.reserve(argc); + + // insert argc + DFLAGS + final_args.insert(final_args.end(), &argv[0], &argv[argc]); + + // read the configuration file + ConfigFile cfg_file; + + // just ignore errors for now, they are still printed +#if DMDV2 +#define CFG_FILENAME "ldc2.conf" +#else +#define CFG_FILENAME "ldc.conf" +#endif + cfg_file.read(global.params.argv0, (void*)main, CFG_FILENAME); +#undef CFG_FILENAME + + // insert config file additions to the argument list + final_args.insert(final_args.end(), cfg_file.switches_begin(), cfg_file.switches_end()); + +#if 0 + for (size_t i = 0; i < final_args.size(); ++i) + { + printf("final_args[%zu] = %s\n", i, final_args[i]); + } +#endif + // Handle fixed-up arguments! cl::SetVersionPrinter(&printVersion); - cl::ParseCommandLineOptions(argc, argv, "LLVM-based D Compiler\n"); + cl::ParseCommandLineOptions(final_args.size(), (char**)&final_args[0], "LLVM-based D Compiler\n", true); global.params.optimize = (global.params.optimizeLevel >= 0);