Skip to content

Commit

Permalink
- Don't output type min/max values in the xml-file: This is handled w…
Browse files Browse the repository at this point in the history
…hen parsing the files using default values

- Output variable type name and more in the info.xml
- OSX fixes setting @rpath for .dylib files


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18207 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 20, 2013
1 parent 179655e commit 7cf9e7f
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 155 deletions.
109 changes: 0 additions & 109 deletions Compiler/Template/CodegenC.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10253,115 +10253,6 @@ template getCausality(Causality c)
case INPUT(__) then "input"
end getCausality;

template getVariablity(VarKind varKind)
"Returns the variablity Attribute of ScalarVariable."
::=
match varKind
case DISCRETE(__) then "discrete"
case PARAM(__) then "parameter"
case CONST(__) then "constant"
else "continuous"
end getVariablity;

template getAliasVar(AliasVariable aliasvar)
"Returns the alias Attribute of ScalarVariable."
::=
match aliasvar
case NOALIAS(__) then '"noAlias"'
case ALIAS(__) then '"alias" aliasVariable="<%crefStrNoUnderscore(varName)%>"'
case NEGATEDALIAS(__) then '"negatedAlias" aliasVariable="<%crefStrNoUnderscore(varName)%>"'
else '"noAlias"'
end getAliasVar;

template ScalarVariableType(String unit, String displayUnit, Option<DAE.Exp> minValue, Option<DAE.Exp> maxValue, Option<DAE.Exp> initialValue, Option<DAE.Exp> nominalValue, Boolean isFixed, DAE.Type type_)
"Generates code for ScalarVariable Type file for FMU target."
::=
match type_
case T_INTEGER(__) then '<Integer <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeIntegerMinAttribute(minValue)%> <%ScalarVariableTypeIntegerMaxAttribute(maxValue)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_REAL(__) then '<Real <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeNominalAttribute(nominalValue)%> <%ScalarVariableTypeRealMinAttribute(minValue)%> <%ScalarVariableTypeRealMaxAttribute(maxValue)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_BOOL(__) then '<Boolean <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_STRING(__) then '<String <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_ENUMERATION(__) then '<Integer <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
else error(sourceInfo(), 'ScalarVariableType: <%unparseType(type_)%>')
end ScalarVariableType;

template ScalarVariableTypeStartAttribute(Option<DAE.Exp> initialValue, DAE.Type type_)
"generates code for start attribute"
::=
match initialValue
case SOME(exp) then 'useStart="true" start="<%initValXml(exp)%>"'
case NONE() then
match type_
case T_ENUMERATION(__)
case T_INTEGER(__) then 'useStart="false" start="0"'
case T_REAL(__) then 'useStart="false" start="0.0"'
case T_BOOL(__) then 'useStart="false" start="false"'
case T_STRING(__) then 'useStart="false" start=""'
else error(sourceInfo(), 'ScalarVariableTypeStartAttribute: <%unparseType(type_)%>')
end ScalarVariableTypeStartAttribute;

template ScalarVariableTypeFixedAttribute(Boolean isFixed)
"generates code for fixed attribute"
::=
'fixed="<%isFixed%>"'
end ScalarVariableTypeFixedAttribute;

template ScalarVariableTypeNominalAttribute(Option<DAE.Exp> nominalValue)
"generates code for nominal attribute"
::=
match nominalValue
case SOME(exp) then 'useNominal="true" nominal="<%initValXml(exp)%>"'
case NONE() then 'useNominal="false" nominal="1.0"'
end ScalarVariableTypeNominalAttribute;

template ScalarVariableTypeUnitAttribute(String unit)
"generates code for unit attribute"
::=
'<% if unit then 'unit="<%unit%>"' else '' %>'
end ScalarVariableTypeUnitAttribute;

template ScalarVariableTypeDisplayUnitAttribute(String displayUnit)
"generates code for displayUnit attribute"
::=
'<% if displayUnit then 'displayUnit="<%displayUnit%>"' else '' %>'
end ScalarVariableTypeDisplayUnitAttribute;

template ScalarVariableTypeIntegerMinAttribute(Option<DAE.Exp> minValue)
"generates code for min attribute"
::=
match minValue
case SOME(exp) then 'min="<%initValXml(exp)%>"'
// replace bei modelica limits
case NONE() then 'min="-2147483648"'
end ScalarVariableTypeIntegerMinAttribute;

template ScalarVariableTypeIntegerMaxAttribute(Option<DAE.Exp> maxValue)
"generates code for max attribute"
::=
match maxValue
case SOME(exp) then 'max="<%initValXml(exp)%>"'
// replace bei modelica limits
case NONE() then 'max="2147483647"'
end ScalarVariableTypeIntegerMaxAttribute;

template ScalarVariableTypeRealMinAttribute(Option<DAE.Exp> minValue)
"generates code for min attribute"
::=
match minValue
case SOME(exp) then 'min="<%initValXml(exp)%>"'
// replace bei modelica limits
case NONE() then 'min="-1.7976931348623157E+308"'
end ScalarVariableTypeRealMinAttribute;

template ScalarVariableTypeRealMaxAttribute(Option<DAE.Exp> maxValue)
"generates code for max attribute"
::=
match maxValue
case SOME(exp) then 'max="<%initValXml(exp)%>"'
// replace bei modelica limits
case NONE() then 'max="1.7976931348623157E+308"'
end ScalarVariableTypeRealMaxAttribute;

template addRootsTempArray()
::=
let() = System.tmpTickResetIndex(0, 2)
Expand Down
112 changes: 112 additions & 0 deletions Compiler/Template/CodegenUtil.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,118 @@ template initValXml(Exp initialValue)
else error(sourceInfo(), 'initial value of unknown type: <%printExpStr(initialValue)%>')
end initValXml;

/*********************************************************************
*********************************************************************
* Common XML Functions
*********************************************************************
*********************************************************************/

template getVariablity(VarKind varKind)
"Returns the variablity Attribute of ScalarVariable."
::=
match varKind
case DISCRETE(__) then "discrete"
case PARAM(__) then "parameter"
case CONST(__) then "constant"
else "continuous"
end getVariablity;

template getAliasVar(AliasVariable aliasvar)
"Returns the alias Attribute of ScalarVariable."
::=
match aliasvar
case NOALIAS(__) then '"noAlias"'
case ALIAS(__) then '"alias" aliasVariable="<%crefStrNoUnderscore(varName)%>"'
case NEGATEDALIAS(__) then '"negatedAlias" aliasVariable="<%crefStrNoUnderscore(varName)%>"'
else '"noAlias"'
end getAliasVar;

template ScalarVariableType(String unit, String displayUnit, Option<DAE.Exp> minValue, Option<DAE.Exp> maxValue, Option<DAE.Exp> initialValue, Option<DAE.Exp> nominalValue, Boolean isFixed, DAE.Type type_)
"Generates code for ScalarVariable Type file for FMU target."
::=
match type_
case T_INTEGER(__) then '<Integer <%ScalarVariableTypeStartAttribute(initialValue, type_)%><%ScalarVariableTypeFixedAttribute(isFixed)%><%ScalarVariableTypeIntegerMinAttribute(minValue)%><%ScalarVariableTypeIntegerMaxAttribute(maxValue)%><%ScalarVariableTypeUnitAttribute(unit)%><%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_REAL(__) then '<Real <%ScalarVariableTypeStartAttribute(initialValue, type_)%><%ScalarVariableTypeFixedAttribute(isFixed)%><%ScalarVariableTypeNominalAttribute(nominalValue)%><%ScalarVariableTypeRealMinAttribute(minValue)%><%ScalarVariableTypeRealMaxAttribute(maxValue)%><%ScalarVariableTypeUnitAttribute(unit)%><%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_BOOL(__) then '<Boolean <%ScalarVariableTypeStartAttribute(initialValue, type_)%><%ScalarVariableTypeFixedAttribute(isFixed)%><%ScalarVariableTypeUnitAttribute(unit)%><%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_STRING(__) then '<String <%ScalarVariableTypeStartAttribute(initialValue, type_)%><%ScalarVariableTypeFixedAttribute(isFixed)%><%ScalarVariableTypeUnitAttribute(unit)%><%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_ENUMERATION(__) then '<Integer <%ScalarVariableTypeStartAttribute(initialValue, type_)%><%ScalarVariableTypeFixedAttribute(isFixed)%><%ScalarVariableTypeUnitAttribute(unit)%><%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_COMPLEX(complexClassType = ci as ClassInf.EXTERNAL_OBJ(__)) then '<ExternalObject path="<%escapeModelicaStringToXmlString(dotPath(ci.path))%>" />'
else error(sourceInfo(), 'ScalarVariableType: <%unparseType(type_)%>')
end ScalarVariableType;

template ScalarVariableTypeStartAttribute(Option<DAE.Exp> initialValue, DAE.Type type_)
"generates code for start attribute"
::=
match initialValue
case SOME(exp) then 'useStart="true" start="<%initValXml(exp)%>"'
case NONE() then
match type_
case T_ENUMERATION(__)
case T_INTEGER(__) then 'useStart="false" start="0"'
case T_REAL(__) then 'useStart="false" start="0.0"'
case T_BOOL(__) then 'useStart="false" start="false"'
case T_STRING(__) then 'useStart="false" start=""'
else error(sourceInfo(), 'ScalarVariableTypeStartAttribute: <%unparseType(type_)%>')
end ScalarVariableTypeStartAttribute;

template ScalarVariableTypeFixedAttribute(Boolean isFixed)
"generates code for fixed attribute"
::=
' fixed="<%isFixed%>"'
end ScalarVariableTypeFixedAttribute;

template ScalarVariableTypeNominalAttribute(Option<DAE.Exp> nominalValue)
"generates code for nominal attribute"
::=
match nominalValue
case SOME(exp) then ' useNominal="true" nominal="<%initValXml(exp)%>"'
case NONE() then ' useNominal="false" nominal="1.0"'
end ScalarVariableTypeNominalAttribute;

template ScalarVariableTypeUnitAttribute(String unit)
"generates code for unit attribute"
::=
'<% if unit then ' unit="<%unit%>"' %>'
end ScalarVariableTypeUnitAttribute;

template ScalarVariableTypeDisplayUnitAttribute(String displayUnit)
"generates code for displayUnit attribute"
::=
'<% if displayUnit then ' displayUnit="<%displayUnit%>"' %>'
end ScalarVariableTypeDisplayUnitAttribute;

template ScalarVariableTypeIntegerMinAttribute(Option<DAE.Exp> minValue)
"generates code for min attribute"
::=
match minValue
case SOME(exp) then ' min="<%initValXml(exp)%>"'
// case NONE() then ' min="-2147483648"'
end ScalarVariableTypeIntegerMinAttribute;

template ScalarVariableTypeIntegerMaxAttribute(Option<DAE.Exp> maxValue)
"generates code for max attribute"
::=
match maxValue
case SOME(exp) then ' max="<%initValXml(exp)%>"'
// case NONE() then ' max="2147483647"'
end ScalarVariableTypeIntegerMaxAttribute;

template ScalarVariableTypeRealMinAttribute(Option<DAE.Exp> minValue)
"generates code for min attribute"
::=
match minValue
case SOME(exp) then ' min="<%initValXml(exp)%>"'
// case NONE() then ' min="-1.7976931348623157E+308"'
end ScalarVariableTypeRealMinAttribute;

template ScalarVariableTypeRealMaxAttribute(Option<DAE.Exp> maxValue)
"generates code for max attribute"
::=
match maxValue
case SOME(exp) then ' max="<%initValXml(exp)%>"'
// case NONE() then ' max="1.7976931348623157E+308"'
end ScalarVariableTypeRealMaxAttribute;

/*********************************************************************
*********************************************************************
* Paths
Expand Down
9 changes: 6 additions & 3 deletions Compiler/Template/SimCodeDump.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,15 @@ end dumpVarsShort;
template dumpVars(list<SimVar> vars, Boolean withOperations)
::=
vars |> v as SIMVAR(__) =>
let variability = getVariablity(varKind)
<<
<variable name="<%Util.escapeModelicaStringToXmlString(crefStrNoUnderscore(v.name))%>" comment="<%escapeModelicaStringToXmlString(v.comment)%>">
<variable name="<%Util.escapeModelicaStringToXmlString(crefStrNoUnderscore(v.name))%>" comment="<%escapeModelicaStringToXmlString(v.comment)%>" variability = "<%variability%>" isDiscrete = "<%isDiscrete%>">
<%ScalarVariableType(unit, displayUnit, minValue, maxValue, initialValue, nominalValue, isFixed, type_)%>
<%dumpAlias(v.aliasvar)%>
<%dumpElementSource(v.source,withOperations)%>
</variable><%\n%>
<variable name="$PRE._<%Util.escapeModelicaStringToXmlString(crefStrNoUnderscore(v.name))%>" comment="<%escapeModelicaStringToXmlString(v.comment)%>">
<variable name="$PRE.<%Util.escapeModelicaStringToXmlString(crefStrNoUnderscore(v.name))%>" comment="<%escapeModelicaStringToXmlString(v.comment)%>" variability = "<%variability%>" isDiscrete = "true">
<%ScalarVariableType(unit, displayUnit, minValue, maxValue, initialValue, nominalValue, isFixed, type_)%>
<%dumpAlias(v.aliasvar)%>
<%dumpElementSource(v.source,withOperations)%>
</variable><%\n%>
Expand Down Expand Up @@ -271,7 +274,7 @@ template dumpElementSource(ElementSource source, Boolean withOperations)
<%s.partOfLst |> w => '<part-of><%dumpWithin(w)%></part-of>' %>
<%s.instanceOptLst |> SOME(cr) => '<instance><%crefStrNoUnderscore(cr)%></instance>' %>
<%s.connectEquationOptLst |> p => "<connect-equation />"%>
<%s.typeLst |> p => '<type><%dotPath(p)%></type>' ; separator = "\n" %>
<%s.typeLst |> p => '<type><%escapeModelicaStringToXmlString(dotPath(p))%></type>' ; separator = "\n" %>
</source>
<% if withOperations then <<
<operations>
Expand Down
25 changes: 18 additions & 7 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ build/lib/omc/libgc.a: 3rdParty/gc-7.2/.libs/libgc.a mkbuilddirs
3rdParty/gc-7.2/.libs/libgc.a: 3rdParty/gc-7.2/Makefile
$(MAKE) -C 3rdParty/gc-7.2/
build/include/omc/gc.h: 3rdParty/gc-7.2/include/gc.h mkbuilddirs
cp -pP $< $@
cp -pPR $< $@
build/include/omc/gc_config_macros.h: 3rdParty/gc-7.2/include/gc_config_macros.h mkbuilddirs
cp -pP $< $@
cp -pPR $< $@
build/include/omc/gc_version.h: 3rdParty/gc-7.2/include/gc_version.h mkbuilddirs
cp -pP $< $@
cp -pPR $< $@
3rdParty/gc-7.2/Makefile: 3rdParty/gc-7.2/Makefile.in 3rdParty/gc-7.2/configure
(cd 3rdParty/gc-7.2 && ./configure "--host=$(host)" $(GC_THREADS) --disable-gcj-support --disable-java-finalization --enable-large-config CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS) -DTHREAD_LOCAL_ALLOC")

Expand All @@ -91,8 +91,10 @@ build/include/omc/gc_version.h: 3rdParty/gc-7.2/include/gc_version.h mkbuilddirs
build/lib/omc/libipopt.la: 3rdParty/Ipopt-3.11.6/Makefile
$(MAKE) -C 3rdParty/Ipopt-3.11.6
$(MAKE) -C 3rdParty/Ipopt-3.11.6 install
cp -pP 3rdParty/Ipopt-3.11.6/lib/*.* build/lib/omc
cp -rp 3rdParty/Ipopt-3.11.6/include/coin build/include/omc
test ! `uname` = Darwin || install_name_tool -id @rpath/libipopt.1.9.6.dylib 3rdParty/Ipopt-3.11.6/lib/libipopt.1.9.6.dylib
test ! `uname` = Darwin || install_name_tool -id @rpath/libcoinmumps.1.4.11.dylib 3rdParty/Ipopt-3.11.6/lib/libcoinmumps.1.4.11.dylib
cp -pPR 3rdParty/Ipopt-3.11.6/lib/*.* build/lib/omc
cp -pPR 3rdParty/Ipopt-3.11.6/include/coin build/include/omc

ipopt: build/lib/omc/libipopt.la

Expand All @@ -103,7 +105,7 @@ openblas: build/lib/omc/libopenblas_openmodelica.a

fmi: interactive
$(MAKE) -C SimulationRuntime/fmi/import -f $(defaultMakefileTarget)
(cp -p SimulationRuntime/fmi/import/fmuWrapper.h SimulationRuntime/fmi/import/xmlparser.h $(builddir_inc))
(cp -pPR SimulationRuntime/fmi/import/fmuWrapper.h SimulationRuntime/fmi/import/xmlparser.h $(builddir_inc))

fmiclean:
$(MAKE) -C SimulationRuntime/fmi/import/ -f $(defaultMakefileTarget) clean
Expand All @@ -125,6 +127,15 @@ runtimeCPP:

runtimeCPPinstall:
$(MAKE) -C SimulationRuntime/cpp/ -f $(defaultMakefileTarget) install
test ! `uname` = Darwin || install_name_tool -id @rpath/cpp/libOMCppCVode.dylib build/lib/omc/cpp/libOMCppCVode.dylib
test ! `uname` = Darwin || install_name_tool -id @rpath/cpp/libOMCppDataExchange.dylib build/lib/omc/cpp/libOMCppDataExchange.dylib
test ! `uname` = Darwin || install_name_tool -id @rpath/cpp/libOMCppEuler.dylib build/lib/omc/cpp/libOMCppEuler.dylib
test ! `uname` = Darwin || install_name_tool -id @rpath/cpp/libOMCppNewton.dylib build/lib/omc/cpp/libOMCppNewton.dylib
test ! `uname` = Darwin || install_name_tool -id @rpath/cpp/libOMCppSimulationSettings.dylib build/lib/omc/cpp/libOMCppSimulationSettings.dylib
test ! `uname` = Darwin || install_name_tool -id @rpath/cpp/libOMCppSolver.dylib build/lib/omc/cpp/libOMCppSolver.dylib
test ! `uname` = Darwin || install_name_tool -id @rpath/cpp/libOMCppSystem.dylib build/lib/omc/cpp/libOMCppSystem.dylib
test ! `uname` = Darwin || install_name_tool -change libOMCppSolver.dylib @rpath/cpp/libOMCppSolver.dylib build/lib/omc/cpp/libOMCppCVode.dylib
test ! `uname` = Darwin || install_name_tool -change libOMCppSolver.dylib @rpath/cpp/libOMCppSolver.dylib build/lib/omc/cpp/libOMCppEuler.dylib

omc-diff: mkbuilddirs
$(MAKE) -C testsuite/ -f Makefile omc-diff
Expand All @@ -147,7 +158,7 @@ fmil:
test -f 3rdParty/FMIL/build/$(LIBFMILIB) || $(MAKE) -C 3rdParty/FMIL/build
test -d 3rdParty/FMIL/install || $(MAKE) -C 3rdParty/FMIL/build install
test ! -f 3rdParty/FMIL/build/libfmilib_shared.so || cp -up 3rdParty/FMIL/build/libfmilib_shared.so 3rdParty/FMIL/build/libfmilib.so
cp -p 3rdParty/FMIL/build/$(LIBFMILIB) $(builddir_lib)/omc/
cp -pPR 3rdParty/FMIL/build/$(LIBFMILIB) $(builddir_lib)/omc/
#TODO: Only copy required headers, add them in omc/fmi subfolder, and do not copy c/txt-files
#cp -rp 3rdParty/FMIL/install/include/* $(builddir_inc)

Expand Down

0 comments on commit 7cf9e7f

Please sign in to comment.