Skip to content

Commit

Permalink
- add case to generate nmake makefile for visual studio 2010
Browse files Browse the repository at this point in the history
 todo: copy libs 
  libexpat.lib from OMDEV/lib/expat-win32-msvc to lib
  sundials_kinsol.lib sundials_nvecserial.lib from OMDEV/lib/3rdParty/Sundials/lib/release/vc100 to lib
  f2c.lib initialization.lib  math-support.lib meta.lib ModelicaExternalC.lib results.lib simulation.lib solver.lib util.lib from OMDEV/lib/c_runtime_msvc to lib
 improve Compile.bat to call vcvarsall.bat and nmake in case of target=msvc 
 add dlls (expat,kinsol) to path


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13504 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Oct 19, 2012
1 parent 650bcf4 commit 4c52004
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
62 changes: 59 additions & 3 deletions Compiler/Template/CodegenC.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ template translateModel(SimCode simCode)
match simCode
case SIMCODE(modelInfo=modelInfo as MODELINFO(__)) then
let guid = getUUIDStr()

let()= textFile(simulationMakefile(simCode), '<%fileNamePrefix%>.makefile') // write the makefile first!
let target = simulationCodeTarget()
let()= textFile(simulationMakefile(target, simCode), '<%fileNamePrefix%>.makefile') // write the makefile first!

let()= textFile(simulationFunctionsHeaderFile(fileNamePrefix, modelInfo.functions, recordDecls), '<%fileNamePrefix%>_functions.h')

Expand Down Expand Up @@ -2351,9 +2351,64 @@ template functionHeadersParModelica(String filePrefix, list<Function> functions)
/* adrpo: leave a newline at the end of file to get rid of the warning */
end functionHeadersParModelica;

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

# /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" /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 /LIBPATH:"<%makefileParams.omhome%>/lib/omc/" f2c.lib initialization.lib libexpat.lib math-support.lib meta.lib ModelicaExternalC.lib results.lib simulation.lib solver.lib sundials_kinsol.lib sundials_nvecserial.lib util.lib

# /MDd link with MSVCRTD.LIB debug lib
# lib names should be appended with a d


FILEPREFIX=<%fileNamePrefix%>
MAINFILE=$(FILEPREFIX).c
MAINOBJ=$(FILEPREFIX).obj
GENERATEDFILES=$(MAINFILE) $(FILEPREFIX)_functions.c $(FILEPREFIX)_functions.h $(FILEPREFIX)_records.c $(FILEPREFIX).makefile

$(FILEPREFIX)$(EXEEXT): $(MAINOBJ) $(FILEPREFIX)_records.c $(FILEPREFIX)_functions.c $(FILEPREFIX)_functions.h
$(CXX) /Fe$(FILEPREFIX)$(EXEEXT) $(MAINFILE) $(FILEPREFIX)_records.c $(CFLAGS) $(LDFLAGS)
>>
else
match simCode
case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simulationSettingsOpt = sopt) then
let dirExtra = if modelInfo.directory then '-L"<%modelInfo.directory%>"' //else ""
Expand All @@ -2366,6 +2421,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
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

Expand Down
4 changes: 3 additions & 1 deletion SimulationRuntime/c/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ RUNTIME_HEADERS = ./f2c.h \
./simulation/solver/delay.h \
./simulation/solver/model_help.h \
./simulation/solver/simulation_inline_solver.h \
./simulation/results/simulation_result.h \
./util/base_array.h \
./util/boolean_array.h \
./util/division.h \
Expand All @@ -53,7 +54,8 @@ RUNTIME_HEADERS = ./f2c.h \
./util/rtclock.h \
./util/string_array.h \
./util/utility.h \
./util/varinfo.h
./util/varinfo.h \
./linearization/linearize.h

RUNTIME_HEADERS_FMU = \
./simulation/solver/initialization/initialization.h \
Expand Down

0 comments on commit 4c52004

Please sign in to comment.