1 // mainDynamic.cxx - One possible mainline. -*- C++ -*-
3 // Copyright (C) 1999, 2000 Red Hat.
4 // This file is part of SID and is licensed under the GPL.
5 // See the file COPYING.SID for conditions for redistribution.
11 #include <sidpinutil.h>
12 #include <sidcomputil.h>
22 using namespace sidutil;
25 // Link to compConfig component directly.
26 extern component_library /* *not* DLLIMPORT */ config_component_library;
29 // Stub functions to set breakpoints on
30 static void sid_pre_configure () {}
31 static void sid_post_configure () {}
32 static void sid_pre_run () {}
33 static void sid_post_run () {}
40 cout << "Usage: sid OPTIONS [FILE] ..." << endl;
41 cout << "OPTIONS:" << endl;
42 cout << "-h print this help" << endl;
43 cout << "-n load/check configuration but do not run simulation" << endl;
44 cout << "-f FILE also read configuration FILE" << endl;
45 cout << "-e LINE also do configuration LINE" << endl;
47 cout << "All -f/-e options are performed first, in sequence." << endl;
48 cout << "FILE names supplied without -f are done last, in sequence." << endl;
54 main(int argc, char* argv[])
56 vector< pair<bool,string> > config_items;
57 bool dry_run_p = false;
68 int c = getopt (argc, argv, "hne:f:");
83 config_items.push_back (make_pair (false, string(optarg)));
87 config_items.push_back (make_pair (true, string(optarg)));
97 // Treat remaining arguments as file names
98 for (unsigned j=optind; j<argc; j++)
100 config_items.push_back (make_pair (true, string(argv[j])));
103 component* main_component =
104 config_component_library.create_component("sid-control-cfgroot");
105 if(main_component == 0)
107 cerr << "Cannot instantiate configuration root component." << endl;
111 sid_pre_configure ();
112 // select & load the config file
113 bool config_ok = true;
116 // NB: There is no problem if config_items is empty. cfgroot will
117 // abort a run if there are no other configured components.
119 for (unsigned k=0; k < config_items.size(); k++)
121 const pair<bool,string>& item = config_items[k];
122 sid::component::status s;
124 if (item.first == true)
125 s = main_component->set_attribute_value ("config-file!", item.second);
127 s = main_component->set_attribute_value ("config-line!", item.second);
129 if(s != sid::component::ok)
135 cerr << "Configuration error. Aborting." << endl;
139 sid_post_configure ();
144 // drive the root's "run" pin.
146 sid::pin* run_pin = main_component->find_pin ("run!");
149 cerr << "Cannot find root run pin." << endl;
153 // run the simulation
155 // the simulation has ended.
159 // delete cfgroot and the rest of the world
160 config_component_library.delete_component (main_component);
165 // Define a stub lt_preloaded_symbols[], as if libtool's
166 // "--dlpreopen libnull.la" linker option was given (for an empty libnull.la).
167 // This must agree with ltmain.sh & libltdl.
172 extern struct symbols lt_preloaded_symbols[];
173 struct symbols lt_preloaded_symbols[] = { 0, 0 };
174 #endif // !SID_STATIC