28 #include <ast/parser/parse.hpp>
50 cout <<
"Usage mmoc [options] file" << endl;
51 cout <<
"Compile MicroModelica files and generate a C file that implements a model suitable for the Stand--Alone QSS solver." << endl;
53 cout <<
"-d <flag>, --debug <flag>" << endl;
54 cout <<
" Sets the simulation debug <flag>, the debug information is written in the log file generated " << endl;
55 cout <<
" by the Stand--Alone QSS solver and is an OR combination of the following possibilities: " << endl;
56 cout <<
" SD_DBG_All: Enable all the debug flags" << endl;
57 cout <<
" SD_DBG_Dt: Log dt parameter changes in parallel simulations" << endl;
58 cout <<
" SD_DBG_ExternalEvent: Output step information for each external event in parallel simulations" << endl;
60 <<
" SD_DBG_InitValues: Output the simulation initialization, including initial state and state derivatives values"
62 cout <<
" SD_DBG_Memory: Output memory footprint" << endl;
63 cout <<
" SD_DBG_Synchronize: Output synchronization information in parallel simulations" << endl;
64 cout <<
" SD_DBG_StepInfo: Output for each simulation step:" << endl;
65 cout <<
" ** The step time" << endl;
66 cout <<
" ** The type and index of the variable that changes" << endl;
67 cout <<
" SD_DBG_VarChanges: Output the model's state variable changes and the number of handler executions" << endl;
68 cout <<
" for each event defined in the model" << endl;
69 cout <<
" SD_DBG_WaitFor: Output synchronization information in parallel simulations" << endl;
70 cout <<
" SD_DBG_Weights: Save the output values generated by the SD_DBG_VarChanges into a binary file" << endl;
71 cout <<
"-e, --external-structure-file <file>" << endl;
72 cout <<
" Read model incidence matrices from <file>." << endl;
73 cout <<
"-f, --force " << endl;
74 cout <<
" Force external package compilation." << endl;
75 cout <<
"-h, --help Display this information and exit" << endl;
76 cout <<
"-i <path>, --include <path>" << endl;
77 cout <<
" Include <path> in the library path search. " << endl;
78 cout <<
"-o <file>, --output <file>" << endl;
79 cout <<
" Sets the output to <file>" << endl;
80 cout <<
"-s, --settings-only" << endl;
81 cout <<
" Generate only the settings (.ini) file." << endl;
82 cout <<
"-t, --test" << endl;
83 cout <<
" Don't generate GiNaC expressions for testing code structure." << endl;
84 cout <<
"-v, --version Display version information and exit" << endl;
86 cout <<
"Report bugs to: fernandez@cifasis-conicet.gov.ar" << endl;
87 cout <<
"MMOC Compiler home page: https://github.com/CIFASIS/qss-solver/tree/qss-solver-dev/src/mmoc " << endl;
92 cout <<
"MicroModelica C Compiler 4.5.3" << endl;
93 cout <<
"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>" << endl;
94 cout <<
"This is free software: you are free to change and redistribute it." << endl;
95 cout <<
"There is NO WARRANTY, to the extent permitted by law." << endl;
102 AST_StringListIterator it;
103 Utils& utils = Utils::instance();
104 foreach (it, imports) {
110 AST_StoredDefinition sd =
nullptr;
111 sd = parseFile(file_name, &r);
112 Error::instance().setFile(file_name);
120 list<string> objects = flg.
objects();
121 for (list<string>::iterator it = objects.begin(); it != objects.end(); it++) {
124 Error::instance().setFile(file_name);
129 Package package = ir.definition().package();
137 string compiled_file_name = utils.
generatePath(p,
"pkg_" + i +
".moo");
138 const bool FULL_PATH =
true;
157 for (
string import = objects.
begin(it); !objects.
end(it);
import = objects.
next(it)) {
165 int main(
int argc,
char** argv)
171 bool recompile =
false;
172 bool settings =
false;
175 static struct option long_options[] = {{
"version", no_argument, 0,
'v'}, {
"help", no_argument, 0,
'h'},
176 {
"include", required_argument, 0,
'i'}, {
"external-structure-file", required_argument, 0,
'e'},
177 {
"force", no_argument, 0,
'f'}, {
"settings-only", no_argument, 0,
's'},
178 {
"test", no_argument, 0,
't'}, {
"debug", required_argument, 0,
'd'},
179 {
"output", required_argument, 0,
'o'}, {0, 0, 0, 0}};
180 int option_index = 0;
181 opt = getopt_long(argc, argv,
"vhmfsti:e:d:o:", long_options, &option_index);
182 if (opt == EOF)
break;
194 sscanf(optarg,
"%s", str_arg);
223 string pkg = Utils::instance().environmentVariable(
"MMOC_PACKAGES");
224 if (!pkg.empty() && !flags.
testing()) {
227 AST_StoredDefinition sd;
229 if (argv[optind] !=
nullptr) {
230 file_name = argv[optind];
231 string path = Utils::instance().getFilePath(file_name);
233 sd = parseFile(file_name, &r);
234 Error::instance().setFile(file_name);
242 Files sc(file_name, flags);
246 Logger::instance().setFile(file_name);
249 Error::instance().show();
250 cout <<
"Exit code: " << res << endl;
253 Utils::instance().setCompileFlags(flags);
254 Error::instance().setFile(file_name);
265 Error::instance().show();
266 cout <<
"Exit code: " << r << endl;