2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Nathan Binkert
37 #include "base/inifile.hh"
38 #include "base/cprintf.hh"
47 cout
<< "Usage: " << progname
<< " <ini file>\n";
52 char *defines
= getenv("CONFIG_DEFINES");
55 while ((c
= strchr(c
, ' ')) != NULL
) {
65 main(int argc
, char *argv
[])
71 vector
<char *> cppArgs
;
73 vector
<char *> cpp_options
;
74 cpp_options
.reserve(argc
* 2);
76 for (int i
= 1; i
< argc
; ++i
) {
77 char *arg_str
= argv
[i
];
79 // if arg starts with '-', parse as option,
80 // else treat it as a configuration file name and load it
81 if (arg_str
[0] == '-') {
83 // switch on second char
88 // cpp options: record & pass to cpp. Note that these
89 // cannot have spaces, i.e., '-Dname=val' is OK, but
90 // '-D name=val' is not. I don't consider this a
91 // problem, since even though gnu cpp accepts the
92 // latter, other cpp implementations do not (Tru64,
94 cppArgs
.push_back(arg_str
);
98 // command-line configuration parameter:
99 // '--<section>:<parameter>=<value>'
101 if (!simConfigDB
.add(arg_str
+ 2)) {
104 "Could not parse configuration argument '%s'\n"
105 "Expecting --<section>:<parameter>=<value>\n",
116 // no '-', treat as config file name
118 if (!simConfigDB
.loadCPP(arg_str
, cppArgs
)) {
119 cprintf("Error processing file %s\n", arg_str
);
128 if (simConfigDB.find(C, E, value)) \
129 cout << ">" << value << "<\n"; \
131 cout << "Not Found!\n"
133 FIND("General", "Test2");
134 FIND("Junk", "Test3");
135 FIND("Junk", "Test4");
136 FIND("General", "Test1");
137 FIND("Junk2", "test3");
138 FIND("General", "Test3");