Mercurial > projects > ldc
annotate gen/configfile.cpp @ 1477:6023f65a3aee
Fix indentation, removing tabs.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Fri, 05 Jun 2009 02:54:34 +0200 |
parents | df0ffca8a636 |
children | 7d3b47852a7a |
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 |
1473
8309ebaa23d5
Fix for finding ldc.conf file with mingw
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1340
diff
changeset
|
14 #if _WIN32 |
8309ebaa23d5
Fix for finding ldc.conf file with mingw
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1340
diff
changeset
|
15 #include <windows.h> |
8309ebaa23d5
Fix for finding ldc.conf file with mingw
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1340
diff
changeset
|
16 #undef GetCurrentDirectory |
8309ebaa23d5
Fix for finding ldc.conf file with mingw
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1340
diff
changeset
|
17 #endif |
8309ebaa23d5
Fix for finding ldc.conf file with mingw
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1340
diff
changeset
|
18 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
19 namespace sys = llvm::sys; |
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 cfg = new libconfig::Config; |
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 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
26 ConfigFile::~ConfigFile() |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
27 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
28 delete cfg; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
29 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
30 |
1476
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
31 #if _WIN32 |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
32 sys::Path ConfigGetExePath(sys::Path p) |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
33 { |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
34 char buf[MAX_PATH]; |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
35 GetModuleFileName(NULL, buf, MAX_PATH); |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
36 p = buf; |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
37 p.eraseComponent(); |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
38 return p; |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
39 } |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
40 #endif |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
41 |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
42 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
43 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
|
44 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
45 |
1476
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
46 #if _WIN32 |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
47 std::string exeDirectoryName; |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
48 #endif |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
49 // try to find the config file |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
50 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
51 // 1) try the current working dir |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
52 sys::Path p = sys::Path::GetCurrentDirectory(); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
53 p.appendComponent(filename); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
54 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
55 if (!p.exists()) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
56 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
57 // 2) try the user home dir |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
58 p = sys::Path::GetUserHomeDirectory(); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
59 p.appendComponent(filename); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
60 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
61 if (!p.exists()) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
62 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
63 // 3) try the install-prefix/etc |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
64 p = sys::Path(LDC_INSTALL_PREFIX); |
1114 | 65 #if !_WIN32 |
66 // Does Window need something similar? | |
67 p.appendComponent("etc"); | |
68 #endif | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
69 p.appendComponent(filename); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
70 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
71 if (!p.exists()) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
72 { |
1473
8309ebaa23d5
Fix for finding ldc.conf file with mingw
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1340
diff
changeset
|
73 #if _WIN32 |
1477
6023f65a3aee
Fix indentation, removing tabs.
Frits van Bommel <fvbommel wxs.nl>
parents:
1476
diff
changeset
|
74 p = ConfigGetExePath(p); |
6023f65a3aee
Fix indentation, removing tabs.
Frits van Bommel <fvbommel wxs.nl>
parents:
1476
diff
changeset
|
75 exeDirectoryName = p.toString(); |
6023f65a3aee
Fix indentation, removing tabs.
Frits van Bommel <fvbommel wxs.nl>
parents:
1476
diff
changeset
|
76 #else |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
77 // 4) try next to the executable |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
78 p = sys::Path::GetMainExecutable(argv0, mainAddr); |
1476
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
79 p.eraseComponent(); |
1473
8309ebaa23d5
Fix for finding ldc.conf file with mingw
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1340
diff
changeset
|
80 #endif |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
81 p.appendComponent(filename); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
82 if (!p.exists()) |
1473
8309ebaa23d5
Fix for finding ldc.conf file with mingw
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1340
diff
changeset
|
83 { |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
84 // 5) fail load cfg, users still have the DFLAGS environment var |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
85 std::cerr << "Error failed to locate the configuration file: " << filename << std::endl; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
86 return false; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
87 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
88 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
89 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
90 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
91 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
92 try |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
93 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
94 // read the cfg |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
95 cfg->readFile(p.c_str()); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
96 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
97 // 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
|
98 if (!cfg->exists("default")) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
99 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
100 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
|
101 return false; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
102 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
103 libconfig::Setting& root = cfg->lookup("default"); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
104 if (!root.isGroup()) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
105 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
106 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
|
107 return false; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
108 } |
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 // handle switches |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
111 if (root.exists("switches")) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
112 { |
1340
206329112670
Fix the ldcbinarypath config file rewriting.
Christian Kamm <kamm incasoftware de>
parents:
1339
diff
changeset
|
113 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
|
114 |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
115 #if _WIN32 |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
116 std::string binpath; |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
117 //This will happen if ldc.conf is found somewhere other than |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
118 //beside the ldc executable |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
119 if (exeDirectoryName == "") |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
120 { |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
121 sys::Path p; |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
122 p = ConfigGetExePath(p); |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
123 exeDirectoryName = p.toString(); |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
124 } |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
125 binpath = exeDirectoryName; |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
126 #else |
1340
206329112670
Fix the ldcbinarypath config file rewriting.
Christian Kamm <kamm incasoftware de>
parents:
1339
diff
changeset
|
127 std::string binpath = sys::Path::GetMainExecutable(argv0, mainAddr).getDirname(); |
1476
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
128 #endif |
df0ffca8a636
There was another fix needed here for reading %%ldcbinarypath%%
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1475
diff
changeset
|
129 |
1340
206329112670
Fix the ldcbinarypath config file rewriting.
Christian Kamm <kamm incasoftware de>
parents:
1339
diff
changeset
|
130 |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
131 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
|
132 int len = arr.getLength(); |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
133 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
|
134 { |
1337
b6e819244062
In config file: replace %%ldcbinarypath%% with the path to the ldc executable.
Christian Kamm <kamm incasoftware de>
parents:
1114
diff
changeset
|
135 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
|
136 |
b6e819244062
In config file: replace %%ldcbinarypath%% with the path to the ldc executable.
Christian Kamm <kamm incasoftware de>
parents:
1114
diff
changeset
|
137 // 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
|
138 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
|
139 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
|
140 v.replace(p, binpathkey.size(), binpath); |
1340
206329112670
Fix the ldcbinarypath config file rewriting.
Christian Kamm <kamm incasoftware de>
parents:
1339
diff
changeset
|
141 |
1337
b6e819244062
In config file: replace %%ldcbinarypath%% with the path to the ldc executable.
Christian Kamm <kamm incasoftware de>
parents:
1114
diff
changeset
|
142 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
|
143 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
144 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
145 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
146 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
147 catch(libconfig::FileIOException& fioe) |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
148 { |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
149 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
|
150 return false; |
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 catch(libconfig::ParseException& pe) |
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 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
|
155 << "(" << pe.getLine() << "): " << pe.getError() << std::endl; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
156 return false; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
157 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
158 catch(...) |
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 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
|
161 return false; |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
162 } |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
163 |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff
changeset
|
164 return true; |
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 |