Opened 5 years ago

Closed 5 years ago

#5954 closed defect (fixed)

More homogeneous handling of Settings

Reported by: Adrian Pop Owned by: Adrian Pop
Priority: high Milestone: 1.16.0
Component: Interactive Environment Version:
Keywords: Cc: Niklas Worschech

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 by Adrian Pop, 5 years ago

Owner: changed from somebody to Adrian Pop
Status: newaccepted

comment:2 by Adrian Pop, 5 years ago

Cc: Niklas Worschech added

comment:3 by Adrian Pop, 5 years ago

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 by Niklas Worschech, 5 years ago

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 by Niklas Worschech, 5 years ago

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

comment:6 by Adrian Pop, 5 years ago

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

comment:7 by Niklas Worschech, 5 years ago

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

comment:8 by Adrian Pop, 5 years ago

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 by Niklas Worschech, 5 years ago

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

comment:10 by Martin Sjölund, 5 years ago

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 by Adrian Pop, 5 years ago

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 by Adrian Pop, 5 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.