Mercurial > projects > ldc
annotate gen/configfile.cpp @ 1592:91af6d05338c
Fix codegen for foreach with ref value being lowered to for.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 07 Nov 2009 13:51:05 +0100 |
parents | ee6b20e7aedb |
children | 40bd4a0d4870 |
rev | line source |
---|---|
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
1 #include <iostream> |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
2 #include <string> |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
3 #include <cassert> |
1340
206329112670
Fix the ldcbinarypath config file rewriting.
Christian Kamm <kamm incasoftware de>
parents:
1339
diff
changeset
|
4 #include <cstring> |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
5 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
6 #include "llvm/System/Path.h" |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
7 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
8 #include "libconfig.h++" |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
9 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
10 #include "gen/configfile.h" |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
11 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
12 #include "mars.h" |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
13 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
14 namespace sys = llvm::sys; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
15 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
16 ConfigFile::ConfigFile() |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
17 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
18 cfg = new libconfig::Config; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
19 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
20 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
21 ConfigFile::~ConfigFile() |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
22 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
23 delete cfg; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
24 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
25 |
1476
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
26 |
1489
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
27 bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const char* filename) |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
28 { |
1537
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
29 // temporary configuration |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
30 |
1536
49ae9728bea4
Check for ldc.conf next to the ldc binary before home and etc.
Christian Kamm <kamm incasoftware de>
parents:
1531
diff
changeset
|
31 // try the current working dir |
1489
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
32 p = sys::Path::GetCurrentDirectory(); |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
33 p.appendComponent(filename); |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
34 if (p.exists()) |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
35 return true; |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
36 |
1537
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
37 // user configuration |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
38 |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
39 // try ~/.ldc |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
40 p = sys::Path::GetUserHomeDirectory(); |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
41 p.appendComponent(".ldc"); |
1536
49ae9728bea4
Check for ldc.conf next to the ldc binary before home and etc.
Christian Kamm <kamm incasoftware de>
parents:
1531
diff
changeset
|
42 p.appendComponent(filename); |
49ae9728bea4
Check for ldc.conf next to the ldc binary before home and etc.
Christian Kamm <kamm incasoftware de>
parents:
1531
diff
changeset
|
43 if (p.exists()) |
49ae9728bea4
Check for ldc.conf next to the ldc binary before home and etc.
Christian Kamm <kamm incasoftware de>
parents:
1531
diff
changeset
|
44 return true; |
1537
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
45 |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
46 #if _WIN32 |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
47 // try home dir |
1489
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
48 p = sys::Path::GetUserHomeDirectory(); |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
49 p.appendComponent(filename); |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
50 if (p.exists()) |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
51 return true; |
1537
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
52 #endif |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
53 |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
54 // system configuration |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
55 |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
56 #if _WIN32 |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
57 // try the install-prefix |
1489
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
58 p = sys::Path(LDC_INSTALL_PREFIX); |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
59 p.appendComponent(filename); |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
60 if (p.exists()) |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
61 return true; |
1537
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
62 #else |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
63 // try the install-prefix/etc |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
64 p = sys::Path(LDC_INSTALL_PREFIX); |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
65 p.appendComponent("etc"); |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
66 p.appendComponent(filename); |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
67 if (p.exists()) |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
68 return true; |
1490
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
69 |
1536
49ae9728bea4
Check for ldc.conf next to the ldc binary before home and etc.
Christian Kamm <kamm incasoftware de>
parents:
1531
diff
changeset
|
70 // try the install-prefix/etc/ldc |
1489
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
71 p = sys::Path(LDC_INSTALL_PREFIX); |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
72 p.appendComponent("etc"); |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
73 p.appendComponent("ldc"); |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
74 p.appendComponent(filename); |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
75 if (p.exists()) |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
76 return true; |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
77 |
1536
49ae9728bea4
Check for ldc.conf next to the ldc binary before home and etc.
Christian Kamm <kamm incasoftware de>
parents:
1531
diff
changeset
|
78 // try /etc (absolute path) |
1490
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
79 p = sys::Path("/etc"); |
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
80 p.appendComponent(filename); |
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
81 if (p.exists()) |
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
82 return true; |
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
83 |
1536
49ae9728bea4
Check for ldc.conf next to the ldc binary before home and etc.
Christian Kamm <kamm incasoftware de>
parents:
1531
diff
changeset
|
84 // try /etc/ldc (absolute path) |
1490
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
85 p = sys::Path("/etc/ldc"); |
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
86 p.appendComponent(filename); |
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
87 if (p.exists()) |
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
88 return true; |
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
89 #endif |
cd4478b47b10
Look for configuration file in `/etc` and `/etc/ldc` too (absolute paths)
Frits van Bommel <fvbommel wxs.nl>
parents:
1489
diff
changeset
|
90 |
1537
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
91 // try next to the executable |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
92 p = sys::Path::GetMainExecutable(argv0, mainAddr); |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
93 p.eraseComponent(); |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
94 p.appendComponent(filename); |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
95 if (p.exists()) |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
96 return true; |
ee6b20e7aedb
Change back the ldc.conf search path and add ~/.ldc
Christian Kamm <kamm incasoftware de>
parents:
1536
diff
changeset
|
97 |
1489
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
98 return false; |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
99 } |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
100 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
101 bool ConfigFile::read(const char* argv0, void* mainAddr, const char* filename) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
102 { |
1489
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
103 sys::Path p; |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
104 if (!locate(p, argv0, mainAddr, filename)) |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
105 { |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
106 // failed to find cfg, users still have the DFLAGS environment var |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
107 std::cerr << "Error failed to locate the configuration file: " << filename << std::endl; |
a048f31bf9f6
Move locating the configuration file into a separate function. Also look in PREFIX/etc/ldc. Fixes #322.
Christian Kamm <kamm incasoftware de>
parents:
1484
diff
changeset
|
108 return false; |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
109 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
110 |
1484
7d3b47852a7a
Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents:
1477
diff
changeset
|
111 // save config file path for -v output |
7d3b47852a7a
Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents:
1477
diff
changeset
|
112 pathstr = p.toString(); |
7d3b47852a7a
Print the path to the configuration file being used if `-v` is passed.
Frits van Bommel <fvbommel wxs.nl>
parents:
1477
diff
changeset
|
113 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
114 try |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
115 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
116 // read the cfg |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
117 cfg->readFile(p.c_str()); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
118 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
119 // make sure there's a default group |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
120 if (!cfg->exists("default")) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
121 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
122 std::cerr << "no default settings in configuration file" << std::endl; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
123 return false; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
124 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
125 libconfig::Setting& root = cfg->lookup("default"); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
126 if (!root.isGroup()) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
127 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
128 std::cerr << "default is not a group" << std::endl; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
129 return false; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
130 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
131 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
132 // handle switches |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
133 if (root.exists("switches")) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
134 { |
1340
206329112670
Fix the ldcbinarypath config file rewriting.
Christian Kamm <kamm incasoftware de>
parents:
1339
diff
changeset
|
135 std::string binpathkey = "%%ldcbinarypath%%"; |
1476
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
136 |
1340
206329112670
Fix the ldcbinarypath config file rewriting.
Christian Kamm <kamm incasoftware de>
parents:
1339
diff
changeset
|
137 std::string binpath = sys::Path::GetMainExecutable(argv0, mainAddr).getDirname(); |
206329112670
Fix the ldcbinarypath config file rewriting.
Christian Kamm <kamm incasoftware de>
parents:
1339
diff
changeset
|
138 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
139 libconfig::Setting& arr = cfg->lookup("default.switches"); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
140 int len = arr.getLength(); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
141 for (int i=0; i<len; i++) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
142 { |
1337
b6e819244062
In config file: replace %%ldcbinarypath%% with the path to the ldc executable.
Christian Kamm <kamm incasoftware de>
parents:
1114
diff
changeset
|
143 std::string v = arr[i]; |
b6e819244062
In config file: replace %%ldcbinarypath%% with the path to the ldc executable.
Christian Kamm <kamm incasoftware de>
parents:
1114
diff
changeset
|
144 |
b6e819244062
In config file: replace %%ldcbinarypath%% with the path to the ldc executable.
Christian Kamm <kamm incasoftware de>
parents:
1114
diff
changeset
|
145 // replace binpathkey with binpath |
b6e819244062
In config file: replace %%ldcbinarypath%% with the path to the ldc executable.
Christian Kamm <kamm incasoftware de>
parents:
1114
diff
changeset
|
146 size_t p; |
b6e819244062
In config file: replace %%ldcbinarypath%% with the path to the ldc executable.
Christian Kamm <kamm incasoftware de>
parents:
1114
diff
changeset
|
147 while (std::string::npos != (p = v.find(binpathkey))) |
b6e819244062
In config file: replace %%ldcbinarypath%% with the path to the ldc executable.
Christian Kamm <kamm incasoftware de>
parents:
1114
diff
changeset
|
148 v.replace(p, binpathkey.size(), binpath); |
1340
206329112670
Fix the ldcbinarypath config file rewriting.
Christian Kamm <kamm incasoftware de>
parents:
1339
diff
changeset
|
149 |
1337
b6e819244062
In config file: replace %%ldcbinarypath%% with the path to the ldc executable.
Christian Kamm <kamm incasoftware de>
parents:
1114
diff
changeset
|
150 switches.push_back(strdup(v.c_str())); |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
151 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
152 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
153 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
154 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
155 catch(libconfig::FileIOException& fioe) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
156 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
157 std::cerr << "Error reading configuration file: " << filename << std::endl; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
158 return false; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
159 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
160 catch(libconfig::ParseException& pe) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
161 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
162 std::cerr << "Error parsing configuration file: " << filename |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
163 << "(" << pe.getLine() << "): " << pe.getError() << std::endl; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
164 return false; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
165 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
166 catch(...) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
167 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
168 std::cerr << "Unknown exception caught!" << std::endl; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
169 return false; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
170 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
171 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
172 return true; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
173 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
174 |