preprocessor: add support for MinGW. #1226

time-shift
Houtan Bastani 2016-10-14 11:25:23 +02:00
parent bfe182f464
commit accd70a4c7
4 changed files with 28 additions and 21 deletions

View File

@ -42,8 +42,8 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
WarningConsolidation &warnings_arg, bool nostrict, bool check_model_changes, WarningConsolidation &warnings_arg, bool nostrict, bool check_model_changes,
bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode, bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
LanguageOutputType lang, int params_derivs_order LanguageOutputType lang, int params_derivs_order
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
, bool cygwin, bool msvc , bool cygwin, bool msvc, bool mingw
#endif #endif
); );
@ -58,8 +58,8 @@ usage()
<< " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test]" << " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test]"
<< " [-D<variable>[=<value>]] [-I/path] [nostrict] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=C|C++|julia]" << " [-D<variable>[=<value>]] [-I/path] [nostrict] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=C|C++|julia]"
<< " [params_derivs_order=0|1|2]" << " [params_derivs_order=0|1|2]"
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
<< " [cygwin] [msvc]" << " [cygwin] [msvc] [mingw]"
#endif #endif
<< endl; << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -96,9 +96,10 @@ main(int argc, char **argv)
bool console = false; bool console = false;
bool nograph = false; bool nograph = false;
bool nointeractive = false; bool nointeractive = false;
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
bool cygwin = false; bool cygwin = false;
bool msvc = false; bool msvc = false;
bool mingw = false;
#endif #endif
string parallel_config_file; string parallel_config_file;
bool parallel = false; bool parallel = false;
@ -167,11 +168,13 @@ main(int argc, char **argv)
nograph = true; nograph = true;
else if (!strcmp(argv[arg], "nointeractive")) else if (!strcmp(argv[arg], "nointeractive"))
nointeractive = true; nointeractive = true;
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
else if (!strcmp(argv[arg], "cygwin")) else if (!strcmp(argv[arg], "cygwin"))
cygwin = true; cygwin = true;
else if (!strcmp(argv[arg], "msvc")) else if (!strcmp(argv[arg], "msvc"))
msvc = true; msvc = true;
else if (!strcmp(argv[arg], "mingw"))
mingw = true;
#endif #endif
else if (strlen(argv[arg]) >= 8 && !strncmp(argv[arg], "conffile", 8)) else if (strlen(argv[arg]) >= 8 && !strncmp(argv[arg], "conffile", 8))
{ {
@ -331,8 +334,8 @@ main(int argc, char **argv)
no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive, no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive,
parallel, config_file, warnings, nostrict, check_model_changes, minimal_workspace, parallel, config_file, warnings, nostrict, check_model_changes, minimal_workspace,
compute_xrefs, output_mode, language, params_derivs_order compute_xrefs, output_mode, language, params_derivs_order
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
, cygwin, msvc , cygwin, msvc, mingw
#endif #endif
); );

View File

@ -31,8 +31,8 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
WarningConsolidation &warnings, bool nostrict, bool check_model_changes, WarningConsolidation &warnings, bool nostrict, bool check_model_changes,
bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode, bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode,
LanguageOutputType language, int params_derivs_order LanguageOutputType language, int params_derivs_order
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
, bool cygwin, bool msvc , bool cygwin, bool msvc, bool mingw
#endif #endif
) )
{ {
@ -59,8 +59,8 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
else else
mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph, mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph,
nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
, cygwin, msvc , cygwin, msvc, mingw
#endif #endif
); );

View File

@ -561,7 +561,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
bool console, bool nograph, bool nointeractive, const ConfigFile &config_file, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
bool check_model_changes, bool minimal_workspace, bool compute_xrefs bool check_model_changes, bool minimal_workspace, bool compute_xrefs
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc , bool cygwin, bool msvc, bool mingw
#endif #endif
) const ) const
{ {
@ -723,22 +723,22 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
{ {
if (dynamic_model.isUnaryOpUsed(oAcosh)) if (dynamic_model.isUnaryOpUsed(oAcosh))
{ {
cerr << "ERROR: acosh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl; cerr << "ERROR: acosh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin or MinGW compiler instead." << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (dynamic_model.isUnaryOpUsed(oAsinh)) if (dynamic_model.isUnaryOpUsed(oAsinh))
{ {
cerr << "ERROR: asinh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl; cerr << "ERROR: asinh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin or MinGW compiler instead." << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (dynamic_model.isUnaryOpUsed(oAtanh)) if (dynamic_model.isUnaryOpUsed(oAtanh))
{ {
cerr << "ERROR: atanh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl; cerr << "ERROR: atanh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin or MinGW compiler instead." << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (dynamic_model.isTrinaryOpUsed(oNormcdf)) if (dynamic_model.isTrinaryOpUsed(oNormcdf))
{ {
cerr << "ERROR: normcdf() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl; cerr << "ERROR: normcdf() function is not supported with USE_DLL option and MSVC compiler; use Cygwin MinGW compiler instead." << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -748,15 +748,18 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
// When check_model_changes is true, don't force compile if MEX is fresher than source // When check_model_changes is true, don't force compile if MEX is fresher than source
if (use_dll) if (use_dll)
{ {
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
if (msvc) if (msvc)
// MATLAB/Windows + Microsoft Visual C++ // MATLAB/Windows + Microsoft Visual C++
mOutputFile << "dyn_mex('msvc', '" << basename << "', " << !check_model_changes << ")" << endl; mOutputFile << "dyn_mex('msvc', '" << basename << "', " << !check_model_changes << ")" << endl;
else if (cygwin) else if (cygwin)
// MATLAB/Windows + Cygwin g++ // MATLAB/Windows + Cygwin g++
mOutputFile << "dyn_mex('cygwin', '" << basename << "', " << !check_model_changes << ")" << endl; mOutputFile << "dyn_mex('cygwin', '" << basename << "', " << !check_model_changes << ")" << endl;
else if (mingw)
// MATLAB/Windows + MinGW g++
mOutputFile << "dyn_mex('mingw', '" << basename << "', " << !check_model_changes << ")" << endl;
else else
mOutputFile << " error('When using the USE_DLL option, you must give either ''cygwin'' or ''msvc'' option to the ''dynare'' command')" << endl; mOutputFile << " error('When using the USE_DLL option, you must give the ''cygwin'', ''msvc'', or ''mingw'' option to the ''dynare'' command')" << endl;
#else #else
// other configurations // other configurations
mOutputFile << "dyn_mex('', '" << basename << "', " << !check_model_changes << ")" << endl; mOutputFile << "dyn_mex('', '" << basename << "', " << !check_model_changes << ")" << endl;

View File

@ -143,13 +143,14 @@ public:
\param nointeractive Should Dynare request user input? \param nointeractive Should Dynare request user input?
\param cygwin Should the MEX command of use_dll be adapted for Cygwin? \param cygwin Should the MEX command of use_dll be adapted for Cygwin?
\param msvc Should the MEX command of use_dll be adapted for MSVC? \param msvc Should the MEX command of use_dll be adapted for MSVC?
\param mingw Should the MEX command of use_dll be adapted for MinGW?
\param compute_xrefs if true, equation cross references will be computed \param compute_xrefs if true, equation cross references will be computed
*/ */
void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn, void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn,
bool console, bool nograph, bool nointeractive, const ConfigFile &config_file, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
bool check_model_changes, bool minimal_workspace, bool compute_xrefs bool check_model_changes, bool minimal_workspace, bool compute_xrefs
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
, bool cygwin, bool msvc , bool cygwin, bool msvc, bool mingw
#endif #endif
) const; ) const;
void writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language) const; void writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language) const;