Skip to content

Commit

Permalink
- change version to beta4
Browse files Browse the repository at this point in the history
- improve checkSettings() 
  + give the compiler version
  + show PATH variable
- set Windows paths right after OMC is started
  + do some checks too to see if we find the needed MinGW things.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15029 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Jan 31, 2013
1 parent 070bd19 commit 5b0bd37
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 25 deletions.
100 changes: 80 additions & 20 deletions Compiler/Main/Main.mo
Expand Up @@ -988,6 +988,68 @@ algorithm
end matchcontinue;
end readSettingsFile;


public function setWindowsPaths
"@author: adrpo
set the windows paths for MinGW.
do some checks on where needed things are present.
BIG WARNING: if MinGW gcc version from OMDev or OpenModelica/MinGW
changes you will need to change here!"
input String inOMHome;
algorithm
_ := matchcontinue(inOMHome)
local
String oldPath,newPath,mingwPath,omHome,omdevPath;

// check if we have OMDEV set
case (omHome)
equation
_ = System.setEnv("OPENMODELICAHOME",omHome,true);
omdevPath = Util.makeValueOrDefault(System.readEnv,"OMDEV","");
// we have something!
false = stringEq(omdevPath, "");
// do we have bin?
true = System.directoryExists(omdevPath +& "\\tools\\mingw\\bin");
// do we have the correct libexec stuff?
true = System.directoryExists(omdevPath +& "\\tools\\mingw\\libexec\\gcc\\mingw32\\4.4.0");
oldPath = System.readEnv("PATH");
newPath = stringAppendList({omHome,"\\bin;",
omHome,"\\lib;",
omdevPath,"\\tools\\mingw\\bin;",
omdevPath,"\\tools\\mingw\\libexec\\gcc\\mingw32\\4.4.0\\;",
oldPath});
_ = System.setEnv("PATH",newPath,true);
then
();

case (omHome)
equation
_ = System.setEnv("OPENMODELICAHOME",omHome,true);
oldPath = System.readEnv("PATH");
// do we have bin?
true = System.directoryExists(omHome +& "\\mingw\\bin");
// do we have the correct libexec stuff?
true = System.directoryExists(omHome +& "\\mingw\\libexec\\gcc\\mingw32\\4.4.0");
newPath = stringAppendList({omHome,"\\bin;",
omHome,"\\lib;",
omHome,"\\mingw\\bin;",
omHome,"\\mingw\\libexec\\gcc\\mingw32\\4.4.0\\;",
oldPath});
_ = System.setEnv("PATH",newPath,true);
then
();

else
equation
print("We could not find any of:\n");
print("\t$OPENMODELICAHOME/MinGW/bin and $OPENMODELICAHOME/MinGW/libexec/gcc/mingw32/4.4.0\n");
print("\t$OMDEV/tools/MinGW/bin and $OMDEV/tools/MinGW/libexec/gcc/mingw32/4.4.0\n");
then
();

end matchcontinue;
end setWindowsPaths;

public function main
"function: main
This is the main function that the MetaModelica Compiler (MMC) runtime system calls to
Expand Down Expand Up @@ -1022,17 +1084,33 @@ algorithm
_ := matchcontinue (args)
local
String errstr;
String omhome,oldpath,newpath;
String omhome;
Interactive.SymbolTable symbolTable;

/* Version requested using --version*/
// Version requested using --version
case _ // try first to see if we had a version request among flags.
equation
true = Config.versionRequest();
print(Settings.getVersionNr());
print("\n");
then ();

// Setup mingw path only once
// adrpo: NEVER MOVE THIS CASE FROM HERE OR PUT ANY OTHER CASES BEFORE IT
// without asking Adrian.Pop@liu.se
case _
equation
true = "Windows_NT" ==& System.os();
omhome = Settings.getInstallationDirectoryPath();
setWindowsPaths(omhome);

// setup an file database (for in-memory use :memory: as name)
//Database.open(0, "omc.db");
//_ = Database.query(0, "create table if not exists Inst(id string not null, value real not null)");
//_ = Database.query(0, "begin transaction;");
then
fail();

case _
equation
true = not System.userIsRoot() or Config.getRunningTestsuite();
Expand All @@ -1052,24 +1130,6 @@ algorithm
symbolTable = readSettings(args);
interactivemodeCorba(symbolTable);
then ();

// Setup mingw path only once.
case _
equation
omhome = Settings.getInstallationDirectoryPath();
_ = System.setEnv("OPENMODELICAHOME",omhome,true) "sendData work-around";
// print("OMHOME:" +& omhome +& "|");
true = "Windows_NT" ==& System.os();
oldpath = System.readEnv("PATH");
newpath = stringAppendList({omhome,"\\mingw\\bin;",omhome,"\\lib;",oldpath});
_ = System.setEnv("PATH",newpath,true);

// setup an file database (for in-memory use :memory: as name)
//Database.open(0, "omc.db");
//_ = Database.query(0, "create table if not exists Inst(id string not null, value real not null)");
//_ = Database.query(0, "begin transaction;");
then
fail();

case _::_
equation
Expand Down
29 changes: 26 additions & 3 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -870,7 +870,8 @@ algorithm
call,str_1,mp,pathstr,name,cname,errMsg,errorStr,
title,xLabel,yLabel,filename2,varNameStr,xml_filename,xml_contents,visvar_str,pwd,omhome,omlib,omcpath,os,
platform,usercflags,senddata,res,workdir,gcc,confcmd,touch_file,uname,filenameprefix,compileDir,libDir,exeDir,configDir,from,to,
legendStr, gridStr, logXStr, logYStr, x1Str, x2Str, y1Str, y2Str,scriptFile,logFile, simflags2, outputFile;
legendStr, gridStr, logXStr, logYStr, x1Str, x2Str, y1Str, y2Str,scriptFile,logFile, simflags2, outputFile,
systemPath, gccVersion;
list<Values.Value> vals;
Absyn.Path path,classpath,className,baseClassPath;
SCode.Program scodeP,sp;
Expand Down Expand Up @@ -2125,10 +2126,28 @@ algorithm
/* Checks the installation of OpenModelica and tries to find common errors */
case (cache,env,"checkSettings",{},st,_)
equation
vars_1 = {"OPENMODELICAHOME","OPENMODELICALIBRARY","OMC_PATH","OMDEV_PATH","OMC_FOUND","MODELICAUSERCFLAGS","WORKING_DIRECTORY","CREATE_FILE_WORKS","REMOVE_FILE_WORKS","OS","SYSTEM_INFO","RTLIBS","C_COMPILER","C_COMPILER_RESPONDING","HAVE_CORBA","CONFIGURE_CMDLINE"};
vars_1 = {"OPENMODELICAHOME",
"OPENMODELICALIBRARY",
"OMC_PATH",
"SYSTEM_PATH",
"OMDEV_PATH",
"OMC_FOUND",
"MODELICAUSERCFLAGS",
"WORKING_DIRECTORY",
"CREATE_FILE_WORKS",
"REMOVE_FILE_WORKS",
"OS",
"SYSTEM_INFO",
"RTLIBS",
"C_COMPILER",
"C_COMPILER_VERSION",
"C_COMPILER_RESPONDING",
"HAVE_CORBA",
"CONFIGURE_CMDLINE"};
omhome = Settings.getInstallationDirectoryPath();
omlib = Settings.getModelicaPath(Config.getRunningTestsuite());
omcpath = omhome +& "/bin/omc" +& System.getExeExt();
systemPath = Util.makeValueOrDefault(System.readEnv,"PATH","");
omdev = Util.makeValueOrDefault(System.readEnv,"OMDEV","");
omcfound = System.regularFileExists(omcpath);
os = System.os();
Expand All @@ -2143,11 +2162,14 @@ algorithm
senddata = System.getRTLibs();
gcc = System.getCCompiler();
have_corba = Corba.haveCorba();
gcc_res = 0 == System.systemCall(gcc +& " -v > /dev/null 2>&1");
gcc_res = 0 == System.systemCall(gcc +& " -v > " +& touch_file +& " 2>&1");
gccVersion = System.readFile(touch_file);
_ = System.systemCall("rm " +& touch_file);
confcmd = System.configureCommandLine();
vals = {Values.STRING(omhome),
Values.STRING(omlib),
Values.STRING(omcpath),
Values.STRING(systemPath),
Values.STRING(omdev),
Values.BOOL(omcfound),
Values.STRING(usercflags),
Expand All @@ -2158,6 +2180,7 @@ algorithm
Values.STRING(uname),
Values.STRING(senddata),
Values.STRING(gcc),
Values.STRING(gccVersion),
Values.BOOL(gcc_res),
Values.BOOL(have_corba),
Values.STRING(confcmd)};
Expand Down
4 changes: 2 additions & 2 deletions Compiler/runtime/config.h
Expand Up @@ -98,9 +98,9 @@
#endif

#ifdef CONFIG_REVISION
#define CONFIG_VERSION "1.9.0 Beta3+dev (r" CONFIG_REVISION ")"
#define CONFIG_VERSION "1.9.0 beta4 (r" CONFIG_REVISION ")"
#else
#define CONFIG_VERSION "1.9.0 Beta3+dev"
#define CONFIG_VERSION "1.9.0 beta4"
#endif


Expand Down

0 comments on commit 5b0bd37

Please sign in to comment.