Skip to content

Commit

Permalink
extended cpp template, make file for visual studio
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13725 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
niklwors committed Oct 30, 2012
1 parent 9ef3f0a commit f1174e7
Showing 1 changed file with 60 additions and 2 deletions.
62 changes: 60 additions & 2 deletions Compiler/Template/CodegenCpp.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import interface SimCodeTV;
template translateModel(SimCode simCode) ::=
match simCode
case SIMCODE(modelInfo = MODELINFO(__)) then
let target = simulationCodeTarget()
let()= textFile(simulationHeaderFile(simCode), '<%lastIdentOfPath(modelInfo.name)%>.h')
let()= textFile(simulationCppFile(simCode), '<%lastIdentOfPath(modelInfo.name)%>.cpp')
let()= textFile(simulationFunctionsHeaderFile(simCode,modelInfo.functions,literals), 'Functions.h')
let()= textFile(simulationFunctionsFile(simCode, modelInfo.functions,literals), 'Functions.cpp')
let()= textFile(simulationMakefile(simCode), '<%fileNamePrefix%>.makefile')
let()= textFile(simulationMakefile(target,simCode), '<%fileNamePrefix%>.makefile')
// algloopfiles(odeEquations,algebraicEquations,whenClauses,parameterEquations,simCode)
algloopfiles(allEquations,simCode)

Expand Down Expand Up @@ -124,9 +125,66 @@ case SIMCODE(modelInfo=MODELINFO(__)) then

end simulationFunctionsHeaderFile;

template simulationMakefile(SimCode simCode)
template simulationMakefile(String target,SimCode simCode)
"Generates the contents of the makefile for the simulation case."
::=
match target
case "msvc" then
match simCode
case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simulationSettingsOpt = sopt) then
let dirExtra = if modelInfo.directory then '-L"<%modelInfo.directory%>"' //else ""
let libsStr = (makefileParams.libs |> lib => lib ;separator=" ")
let libsPos1 = if not dirExtra then libsStr //else ""
let libsPos2 = if dirExtra then libsStr // else ""
let ParModelicaLibs = if acceptParModelicaGrammar() then '-lOMOCLRuntime -lOpenCL' // else ""
let extraCflags = match sopt case SOME(s as SIMULATION_SETTINGS(__)) then
'<%if s.measureTime then "-D_OMC_MEASURE_TIME "%> <%match s.method
case "inline-euler" then "-D_OMC_INLINE_EULER "
case "inline-rungekutta" then "-D_OMC_INLINE_RK "
case "dassljac" then "-D_OMC_JACOBIAN "%>'

<<
# Makefile generated by OpenModelica

# Simulations use -O3 by default
SIM_OR_DYNLOAD_OPT_LEVEL=
MODELICAUSERCFLAGS=
CXX=cl
EXEEXT=.exe
DLLEXT=.dll
include <%makefileParams.omhome%>/include/omc/cpp/ModelicaConfic.inc
# /Od - Optimization disabled
# /EHa enable C++ EH (w/ SEH exceptions)
# /fp:except - consider floating-point exceptions when generating code
# /arch:SSE2 - enable use of instructions available with SSE2 enabled CPUs
# /I - Include Directories
# /DNOMINMAX - Define NOMINMAX (does what it says)
# /TP - Use C++ Compiler
CFLAGS=/Od /EHa /fp:except /I"<%makefileParams.omhome%>/include/omc/cpp" -I"$(BOOST_INCLUDE)" /I. /DNOMINMAX /TP /DNO_INTERACTIVE_DEPENDENCY

# /ZI enable Edit and Continue debug info
CDFLAGS = /ZI

# /MD - link with MSVCRT.LIB
# /link - [linker options and libraries]
# /LIBPATH: - Directories where libs can be found
LDFLAGS=/MD /link /DLL /NOENTRY /LIBPATH:"<%makefileParams.omhome%>/lib/omc/cpp/" /LIBPATH:"<%makefileParams.omhome%>/bin" OMCppSystem.lib OMCppMath.lib OMCppModelicaExternalC.lib

# /MDd link with MSVCRTD.LIB debug lib
# lib names should not be appended with a d just switch to lib/omc/cpp


FILEPREFIX=<%fileNamePrefix%>
FUNCTIONFILE=Functions.cpp
MAINFILE=<%lastIdentOfPath(modelInfo.name)%><% if acceptMetaModelicaGrammar() then ".conv"%>.cpp
MAINOBJ=$(MODELICA_SYSTEM_LIB)
GENERATEDFILES=$(MAINFILE) $(FUNCTIONFILE) <%algloopcppfilenames(allEquations,simCode)%>

$(MODELICA_SYSTEM_LIB)$(DLLEXT):
<%\t%>$(CXX) /Fe$(MODELICA_SYSTEM_LIB) $(MAINFILE) $(FUNCTIONFILE) <%algloopcppfilenames(allEquations,simCode)%> $(CFLAGS) $(LDFLAGS)
>>
end match
case "gcc" then
match simCode
case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simulationSettingsOpt = sopt) then
let extraCflags = match sopt case SOME(s as SIMULATION_SETTINGS(__)) then
Expand Down

0 comments on commit f1174e7

Please sign in to comment.