Opened 4 years ago

Closed 4 years ago

#5954 closed defect (fixed)

More homogeneous handling of Settings

Reported by: adrpo Owned by: adrpo
Priority: high Milestone: 1.16.0
Component: Interactive Environment Version:
Keywords: Cc: niklwors

Description

Currently we have different handling of settings in Linux and Windows:

  • SettingsImpl__getInstallationDirectoryPath returns %OPENMODELICAHOME% in Windows and the dll location in Linux/Mac
  • SettingsImpl__getModelicaPath returns %OPENMODELICALIBRARY% in Windows and (dll location)/../lib/omlibrary in Linux/Mac
  • environment variabels used in the paths are not replaced

This ticket is to solve these problems:

  • use the same in Windows as in Linux
  • replace environment variables in the returned strings

Change History (12)

comment:1 Changed 4 years ago by adrpo

  • Owner changed from somebody to adrpo
  • Status changed from new to accepted

comment:2 Changed 4 years ago by adrpo

  • Cc niklwors added

comment:3 Changed 4 years ago by adrpo

Niklas, I know you're using setting of OPENMODELICAHOME and OPENMODELICALIBRARY to set a specific place for the OpenModelica home. I want to change this behavior but also want to support your use case.

My proposal is that if you call:

  • SettingsImpl__setInstallationDirectoryPath(installPath) then SettingsImpl__getInstallationDirectoryPath returns this installPath.
  • SettingsImpl__setModelicaPath(modelicaPath then SettingsImpl__getModelicaPath returns this mdoelicaPath

Will this work fine for you? I guess you can just call these functions in main to set your installation to whatever paths you need.

comment:4 Changed 4 years ago by niklwors

I am using different OpenModelica versions on Linux and Windows. At the moment I always set these variables before I run the omc:
On Windows:

set OMDEV=D:/OpenModelica/OMDev
set OPENMODELICAHOME=%OMHOME%/build
set OPENMODELICALIBRARY=%OMHOME%/build/lib/omlibrary
set PATH=%PATH%;%OMHOME%/build/bin;
set OMLIBRARYCOMMON=%OMHOME%/testsuite/simulation/libraries/common/
set REFERENCEFILES=%OMHOME%/testsuite/ReferenceFiles/

On Linux:

export  OPENMODELICAHOME=~/omc/omc-dev/build
export  OMLIBRARYCOMMON=~/omc/omc-dev/testsuite/simulation/libraries/common/
export PATH=~/omc/omc-dev/build/bin:$PATH

The modelica path I do not set. Is there a settings variable missing?

comment:5 Changed 4 years ago by niklwors

@adrpo Does your proposal mean you can switch the omc version via the c-api?

comment:6 Changed 4 years ago by adrpo

Yes, if you can unload the libOpenModelicaCompiler.dll and then load another one.

comment:7 Changed 4 years ago by niklwors

ok, I think your proposal is fine for us. I can test it work after you changed the handling.

comment:8 Changed 4 years ago by adrpo

The only issue that remains is how to find the OpenModelica installation if there is no OPENMODELICAHOME environment variable. We could probably have something like Visual Studio used $(VS140COMNTOOLS), include the version number in the variable. I wonder how OMPython finds OpenModelica in Linux if there is no OPENMODELICAHOME set.

Truth is that if we install OpenModelica in a common place such as Program Files we could probably find all the versions that are present there.

comment:9 Changed 4 years ago by niklwors

or there is an error message if the OPENMODELICAHOME variable is not set

comment:10 Changed 4 years ago by sjoelund.se

On Linux, the other tools first look for env.var OPENMODELICAHOME and if it does not exist, it uses the PATH.

On Windows, you could use the registry. But it's annoying to search it for the clients, I think.

I think OPENMODELICAHOME should never need to be used for the omc executable (it's almost always causing problems by using a different runtime than the expected one).

The library path could be used as env.var. to override the default library path if needed though.

comment:11 Changed 4 years ago by adrpo

More fixes on Windows:
https://github.com/OpenModelica/OpenModelica/pull/893

I don't think reading OPENMODELICALIBRARY is a good idea for now as in Windows, older installations does set it, so it would point to older installations even for newer ones.

comment:12 Changed 4 years ago by adrpo

  • Resolution set to fixed
  • Status changed from accepted to closed
Note: See TracTickets for help on using tickets.