Skip to content

Commit

Permalink
-renamed cpp shared libs and executable with OMCpp prefix
Browse files Browse the repository at this point in the history
-changed executable call for cpp runtime in CevalScript 


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12380 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
niklwors committed Jul 31, 2012
1 parent 52320a7 commit 62257c6
Show file tree
Hide file tree
Showing 22 changed files with 105 additions and 88 deletions.
14 changes: 8 additions & 6 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -797,7 +797,7 @@ algorithm
outputFormat_str,initfilename,cit,pd,executableSuffixedExe,sim_call,result_file,filename_1,filename,omhome_1,
plotCmd,tmpPlotFile,call,str_1,mp,pathstr,name,cname,fileNamePrefix_s,errMsg,errorStr,uniqueStr,interpolation,
title,xLabel,yLabel,filename2,varNameStr,xml_filename,xml_contents,visvar_str,pwd,omhome,omlib,omcpath,os,
platform,usercflags,senddata,res,workdir,gcc,confcmd,touch_file,uname,filenameprefix,compileDir,from,to,
platform,usercflags,senddata,res,workdir,gcc,confcmd,touch_file,uname,filenameprefix,compileDir,libDir,exeDir,configDir,from,to,
legendStr, gridStr, logXStr, logYStr, x1Str, x2Str, y1Str, y2Str,scriptFile,logFile, simflags2;
list<Values.Value> vals;
Absyn.Path path,p1,classpath,className;
Expand Down Expand Up @@ -1339,13 +1339,15 @@ algorithm

cit = winCitation();
ifcpp=Util.equal(Config.simCodeTarget(),"Cpp");
compileDir=Util.if_(ifcpp,Settings.getInstallationDirectoryPath() +& "/bin/" ,compileDir);
result_file = stringAppendList(List.consOnTrue(not Config.getRunningTestsuite(),compileDir,{executable,"_res.",outputFormat_str}));
simflags2=Util.if_(ifcpp,stringAppendList({compileDir," ","./"," ",result_file}), simflags);
executable1=Util.if_(ifcpp,"Simulation",executable);
exeDir=Util.if_(ifcpp,Settings.getInstallationDirectoryPath() +& "/bin/" ,compileDir);
libDir= Settings.getInstallationDirectoryPath() +& "/lib/omc" ;
configDir=Settings.getInstallationDirectoryPath() +& "/share/omc/runtime/cpp/";
result_file = stringAppendList(List.consOnTrue(not Config.getRunningTestsuite(),compileDir,{executable,"_res.",outputFormat_str}));
simflags2=Util.if_(ifcpp,stringAppendList({libDir," ",compileDir," ",result_file," ",configDir}), simflags);
executable1=Util.if_(ifcpp,"OMCppSimulation",executable);
executableSuffixedExe = stringAppend(executable1, System.getExeExt());
// sim_call = stringAppendList({"sh -c ",cit,"ulimit -t 60; ",cit,pwd,pd,executableSuffixedExe,cit," > output.log 2>&1",cit});
sim_call = stringAppendList({cit,compileDir,executableSuffixedExe,cit," ",simflags2," > output.log 2>&1"});
sim_call = stringAppendList({cit,exeDir,executableSuffixedExe,cit," ",simflags2," > output.log 2>&1"});
System.realtimeTick(RT_CLOCK_SIMULATE_SIMULATION);
SimulationResults.close() "Windows cannot handle reading and writing to the same file from different processes like any real OS :(";
0 = System.systemCall(sim_call);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Template/CodegenCpp.tpl
Expand Up @@ -144,14 +144,14 @@ EXEEXT=<%makefileParams.exeext%>
DLLEXT=<%makefileParams.dllext%>
CFLAGS_BASED_ON_INIT_FILE=<%extraCflags%>
CFLAGS=$(CFLAGS_BASED_ON_INIT_FILE) -I"<%makefileParams.omhome%>/include/omc/cpp" -I"$(BOOST_INCLUDE)" <%makefileParams.includes ; separator=" "%> <%makefileParams.cflags%> <%match sopt case SOME(s as SIMULATION_SETTINGS(__)) then s.cflags %>
LDFLAGS=-L"<%makefileParams.omhome%>/bin"
LDFLAGS=-L"<%makefileParams.omhome%>/lib/omc"

MAINFILE=<%lastIdentOfPath(modelInfo.name)%><% if acceptMetaModelicaGrammar() then ".conv"%>.cpp
FUNCTIONFILE=Functions.cpp

.PHONY: <%lastIdentOfPath(modelInfo.name)%>
<%lastIdentOfPath(modelInfo.name)%>: $(MAINFILE)
<%\t%>$(CXX) -shared -I. -o $(MODELICA_SYSTEM_LIB) $(MAINFILE) $(FUNCTIONFILE) <%algloopcppfilenames(allEquations,simCode)%> $(CFLAGS) $(LDFLAGS) -lSystem -lModelicaExternalC -Wl,-Bstatic -Wl,-Bdynamic
<%\t%>$(CXX) -shared -I. -o $(MODELICA_SYSTEM_LIB) $(MAINFILE) $(FUNCTIONFILE) <%algloopcppfilenames(allEquations,simCode)%> $(CFLAGS) $(LDFLAGS) -lOMCppSystem -lOMCppModelicaExternalC -Wl,-Bstatic -Wl,-Bdynamic

>>
end simulationMakefile;
Expand Down
39 changes: 27 additions & 12 deletions SimulationRuntime/cpp/Source/CMakeLists.txt
Expand Up @@ -25,6 +25,21 @@ SET(INSTALL_OMDEV_LIBS ON)
ENDIF( WIN32 )

SET(MODELICA_MODEL "ModelicaSystem")
SET(LIBPREFIX "OMCpp")
SET(SolverName ${LIBPREFIX}Solver)
SET(SystemName ${LIBPREFIX}System)
set(MathName ${LIBPREFIX}Math)
set(ModelicaExternalName ${LIBPREFIX}ModelicaExternalC)
set(SettingsFactoryName ${LIBPREFIX}SettingsFactory)
set(SimManagerName ${LIBPREFIX}Simulation)
set(CVodeName ${LIBPREFIX}CVode)
set(EulerName ${LIBPREFIX}Euler)
set(IdaName ${LIBPREFIX}Ida)
set(IdasName ${LIBPREFIX}Idas)
set(KinsolName ${LIBPREFIX}Kinsol)
set(ModelicaName ${LIBPREFIX}Modelica)
set(NewtonName ${LIBPREFIX}Newton)

SET(USE_MICO OFF)
SET(REDUCE_DAE OFF)
SET(USE_SUNDIALS ON)
Expand Down Expand Up @@ -126,36 +141,36 @@ add_subdirectory (Solver/CVode/Implementation)
#add Idas solver project
add_subdirectory (Solver/Idas/Implementation)
add_subdirectory (Solver/Ida/Implementation)
GET_TARGET_PROPERTY(libCVode CVode LOCATION)
GET_TARGET_PROPERTY(libCVode ${CVodeName} LOCATION)
GET_FILENAME_COMPONENT(libCVodeName ${libCVode} NAME)
GET_TARGET_PROPERTY(libIdas Idas LOCATION)
GET_TARGET_PROPERTY(libIdas ${IdasName} LOCATION)
GET_FILENAME_COMPONENT(libIdasName ${libIdas} NAME)
GET_TARGET_PROPERTY(libIda Ida LOCATION)
GET_TARGET_PROPERTY(libIda ${IdaName} LOCATION)
GET_FILENAME_COMPONENT(libIdaName ${libIda} NAME)

set (IDAS_LIB ${libIdasName})
set (CVODE_LIB ${libCVodeName})
set (IDA_LIB ${libIdaName})
endIf()

GET_TARGET_PROPERTY(libNewton Newton LOCATION)
GET_TARGET_PROPERTY(libNewton ${NewtonName} LOCATION)
GET_FILENAME_COMPONENT(libNewtonName ${libNewton} NAME)

GET_TARGET_PROPERTY(libEuler Euler LOCATION)
GET_TARGET_PROPERTY(libEuler ${EulerName} LOCATION)
GET_FILENAME_COMPONENT(libEulerName ${libEuler} NAME)



GET_TARGET_PROPERTY(libSetFactory SettingsFactory LOCATION)
GET_TARGET_PROPERTY(libSetFactory ${SettingsFactoryName} LOCATION)
GET_FILENAME_COMPONENT(libSetFactoryName ${libSetFactory} NAME)

GET_TARGET_PROPERTY(libModelica Modelica LOCATION)
GET_TARGET_PROPERTY(libModelica ${ModelicaName} LOCATION)
GET_FILENAME_COMPONENT(libModelicaName ${libModelica} NAME)

GET_TARGET_PROPERTY(libSystem System LOCATION)
GET_TARGET_PROPERTY(libSystem ${SystemName} LOCATION)
GET_FILENAME_COMPONENT(libSystemName ${libSystem} NAME)

GET_TARGET_PROPERTY(libSolver Solver LOCATION)
GET_TARGET_PROPERTY(libSolver ${SolverName} LOCATION)
GET_FILENAME_COMPONENT(libSolverName ${libSolver} NAME)

set (EULER_LIB ${libEulerName})
Expand All @@ -180,11 +195,11 @@ if(INSTALL_OMDEV_LIBS)
endif()

if(USE_MICO)
install (FILES "${MICO_LIBRARY}" DESTINATION bin)
install (FILES "${MICO_LIBRARY}" DESTINATION lib/omc)
endif()

install (FILES "${LAPACK_lapack_LIBRARY}" DESTINATION bin)
install (FILES "${BLAS_blas_LIBRARY}" DESTINATION bin)
install (FILES "${LAPACK_lapack_LIBRARY}" DESTINATION lib/omc)
install (FILES "${BLAS_blas_LIBRARY}" DESTINATION lib/omc)
#install (FILES "${BOOST_SERIALIZATION_LIBRARY_RELEASE}" DESTINATION bin)
endif()

Expand Down
12 changes: 4 additions & 8 deletions SimulationRuntime/cpp/Source/Math/Implementation/CMakeLists.txt
@@ -1,18 +1,14 @@
cmake_minimum_required (VERSION 2.6)

project(Math)
project(${MathName})
# add the solver default implementation library
add_library(Math SHARED ArrayOperations.cpp )
add_library(${MathName} SHARED ArrayOperations.cpp )


install (TARGETS Math DESTINATION bin)
install (TARGETS ${MathName} DESTINATION lib/omc)
install (FILES Functions.h
ArrayOperations.h
DESTINATION include/omc/cpp/Math/Implementation)
install (FILES ../Interfaces/ILapack.h
DESTINATION include/omc/cpp/Math/Interfaces)






7 changes: 4 additions & 3 deletions SimulationRuntime/cpp/Source/ModelicaExternalC/CMakeLists.txt
@@ -1,7 +1,8 @@
cmake_minimum_required (VERSION 2.6)
project(ModelicaExternalC)
add_library(ModelicaExternalC ModelicaTablesImpl.c tables.cpp )

install (TARGETS ModelicaExternalC DESTINATION bin)
project(${ModelicaExternalName})
add_library(${ModelicaExternalName} ModelicaTablesImpl.c tables.cpp )

install (TARGETS ${ModelicaExternalName} DESTINATION lib/omc)

#lib/omc/cpp
@@ -1,14 +1,14 @@
cmake_minimum_required (VERSION 2.6)

project(SettingsFactory)
project(${SettingsFactoryName})
# add the solver default implementation library
add_library(SettingsFactory SHARED GlobalSettings.cpp Factory.cpp )
target_link_libraries( SettingsFactory ${Boost_LIBRARIES})
add_library(${SettingsFactoryName} SHARED GlobalSettings.cpp Factory.cpp )
target_link_libraries( ${SettingsFactoryName} ${Boost_LIBRARIES})


install (TARGETS SettingsFactory DESTINATION bin)
install (TARGETS ${SettingsFactoryName} DESTINATION lib/omc)
install (FILES "../Interfaces/GlobalSettings.xml"
DESTINATION bin/config)
DESTINATION share/omc/runtime/cpp/config)
install (FILES "../Interfaces/IGlobalSettings.h"
DESTINATION include/omc/cpp/SettingsFactory/Interfaces)

Expand Down
Expand Up @@ -18,12 +18,12 @@ SettingsFactory::~SettingsFactory(void)


}
tuple<boost::shared_ptr<IGlobalSettings>,boost::shared_ptr<ISolverSettings> > SettingsFactory::create(fs::path libraries_path)
tuple<boost::shared_ptr<IGlobalSettings>,boost::shared_ptr<ISolverSettings> > SettingsFactory::create(fs::path libraries_path,fs::path config_path)
{


fs::path settingsfile_name("GlobalSettings.xml");
fs::path settingsfile_path = libraries_path;
fs::path settingsfile_path = config_path;
fs::path settingsfolder_name("config");
settingsfile_path/=settingsfolder_name;
settingsfile_path/=settingsfile_name;
Expand Down Expand Up @@ -54,7 +54,7 @@ tuple<boost::shared_ptr<IGlobalSettings>,boost::shared_ptr<ISolverSettings> > Se
_global_settings->getSelectedSolver().append("Settings.xml"));

fs::path solversettingsfile_name(settings_file);
fs::path solversettingsfile_path = libraries_path;
fs::path solversettingsfile_path = config_path;
solversettingsfile_path/=settingsfolder_name;
solversettingsfile_path/=solversettingsfile_name;

Expand Down
Expand Up @@ -7,7 +7,7 @@ class /*BOOST_EXTENSION_SETTINGSFACTORY_DECL*/ SettingsFactory : public ISetting
{
public:
/*DLL_EXPORT*/ SettingsFactory();
/*DLL_EXPORT*/ tuple<boost::shared_ptr<IGlobalSettings>,boost::shared_ptr<ISolverSettings> > create(fs::path libraries_path);
/*DLL_EXPORT*/ tuple<boost::shared_ptr<IGlobalSettings>,boost::shared_ptr<ISolverSettings> > create(fs::path libraries_path,fs::path config_path);
/*DLL_EXPORT*/ ~SettingsFactory(void);
private:
boost::shared_ptr<IGlobalSettings> _global_settings;
Expand Down
Expand Up @@ -8,7 +8,7 @@ class ISettingsFactory
public:
ISettingsFactory() {};
virtual ~ISettingsFactory(void) {};
virtual tuple<boost::shared_ptr<IGlobalSettings>,boost::shared_ptr<ISolverSettings> > create(fs::path libraries_path) =0;
virtual tuple<boost::shared_ptr<IGlobalSettings>,boost::shared_ptr<ISolverSettings> > create(fs::path libraries_path,fs::path config_path) =0;


};
8 changes: 4 additions & 4 deletions SimulationRuntime/cpp/Source/SimManager/CMakeLists.txt
@@ -1,9 +1,9 @@
cmake_minimum_required (VERSION 2.6)

project(SimManager)
add_executable(Simulation Configuration.cpp Main.cpp )
target_link_libraries( Simulation ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
project(${SimManagerName})
add_executable(${SimManagerName} Configuration.cpp Main.cpp )
target_link_libraries( ${SimManagerName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )


install (TARGETS Simulation DESTINATION bin)
install (TARGETS ${SimManagerName} DESTINATION bin)

4 changes: 2 additions & 2 deletions SimulationRuntime/cpp/Source/SimManager/Configuration.cpp
Expand Up @@ -2,7 +2,7 @@
#include "Configuration.h"
#include <boost/algorithm/string.hpp>
#include "LibrariesConfig.h"
Configuration::Configuration(fs::path libraries_path)
Configuration::Configuration(fs::path libraries_path,fs::path config_path)
:_libraries_path(libraries_path)
{
type_map types;
Expand All @@ -21,7 +21,7 @@ Configuration::Configuration(fs::path libraries_path)
throw std::invalid_argument("No such settings library");
}
_settings_factory = boost::shared_ptr<ISettingsFactory>(iter->second.create());
tie(_global_settings,_solver_settings) =_settings_factory->create(libraries_path);
tie(_global_settings,_solver_settings) =_settings_factory->create(libraries_path,config_path);


}
Expand Down
3 changes: 2 additions & 1 deletion SimulationRuntime/cpp/Source/SimManager/Configuration.h
Expand Up @@ -9,7 +9,7 @@
class Configuration
{
public:
Configuration(fs::path libraries_path);
Configuration(fs::path libraries_path, fs::path config_path);
~Configuration(void);
IDAESolver* createSolver(IDAESystem* system);
IGlobalSettings* getGlobalSettings();
Expand All @@ -21,4 +21,5 @@ class Configuration
boost::shared_ptr<IGlobalSettings> _global_settings;
boost::shared_ptr<IDAESolver> _solver;
fs::path _libraries_path;
fs::path _config_path;
};
8 changes: 5 additions & 3 deletions SimulationRuntime/cpp/Source/SimManager/Main.cpp
Expand Up @@ -7,11 +7,11 @@ namespace fs = boost::filesystem;



int nargc=4;
int nargc=5;
int lib_index= 1;
int modelica_index = 2;
int modelname_index = 3;

int config_index = 4;
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <tchar.h>
int _tmain(int argc, _TCHAR* argv[])
Expand All @@ -25,8 +25,10 @@ int main(int argc, const char* argv[])
string runtime_lib_path = argv[lib_index];
fs::path libraries_path = fs::path( runtime_lib_path) ;
fs::path modelica_path = fs::path( argv[modelica_index] ) ;
fs::path config_path = fs::path( argv[config_index] ) ;
libraries_path.make_preferred();
modelica_path.make_preferred();
config_path.make_preferred();
string resultsfilename(argv[modelname_index]);


Expand All @@ -40,7 +42,7 @@ int main(int argc, const char* argv[])
try
{

Configuration config(libraries_path);
Configuration config(libraries_path,config_path);
IGlobalSettings* global_settings = config.getGlobalSettings();
global_settings->setRuntimeLibrarypath(runtime_lib_path);
global_settings->setResultsFileName(resultsfilename);
Expand Down
@@ -1,19 +1,19 @@
cmake_minimum_required (VERSION 2.6)

project(CVode)
project(${CVodeName})
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})

# add the solver default implementation library
add_library(CVode SHARED CVode.cpp CVodeSettings.cpp )
target_link_libraries (CVode Solver ${Boost_LIBRARIES} ${SUNDIALS_LIBS})
add_library(${CVodeName} SHARED CVode.cpp CVodeSettings.cpp )
target_link_libraries (${CVodeName} ${SolverName} ${Boost_LIBRARIES} ${SUNDIALS_LIBS})
#target_link_libraries( Euler ${Boost_serialization_LIBRARY})






install (TARGETS CVode DESTINATION bin)
install (TARGETS ${CVodeName} DESTINATION lib/omc)
#install (FILES "../Interfaces/EulerSettings.xml"
# DESTINATION bin/config)

Expand Down
@@ -1,18 +1,18 @@
cmake_minimum_required (VERSION 2.6)

project(Euler)
project(${EulerName})
# add the solver default implementation library
add_library(Euler SHARED Euler.cpp EulerSettings.cpp )
target_link_libraries (Euler Solver ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} )
add_library(${EulerName} SHARED Euler.cpp EulerSettings.cpp )
target_link_libraries (${EulerName} ${SolverName} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} )
#target_link_libraries( Euler ${Boost_serialization_LIBRARY})
#target_link_libraries( Euler ${Boost_LIBRARIES})
#target_link_libraries( Euler ${LAPACK_LIBRARIES})



install (TARGETS Euler DESTINATION bin)
install (TARGETS ${EulerName} DESTINATION lib/omc)
install (FILES "../Interfaces/EulerSettings.xml"
DESTINATION bin/config)
DESTINATION share/omc/runtime/cpp/config)



Expand Down
@@ -1,12 +1,12 @@
cmake_minimum_required (VERSION 2.6)

project(Ida)
project(${IdaName})
include_directories(${SUNDIALS_INCLUDE_DIR}/ida ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})
# add the solver default implementation library
add_library(Ida SHARED Ida.cpp IdaSettings.cpp )
target_link_libraries (Ida Solver ${Boost_LIBRARIES} ${SUNDIALS_LIBS} )
add_library(${IdaName} SHARED Ida.cpp IdaSettings.cpp )
target_link_libraries (${IdaName} ${SolverName} ${Boost_LIBRARIES} ${SUNDIALS_LIBS} )

install (TARGETS Ida DESTINATION bin)
install (TARGETS ${IdaName} DESTINATION lib/omc)



Expand Down
@@ -1,12 +1,12 @@
cmake_minimum_required (VERSION 2.6)

project(Idas)
project(${IdasName})
include_directories(${SUNDIALS_INCLUDE_DIR}/idas ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})
# add the solver default implementation library
add_library(Idas SHARED Idas.cpp IdasSettings.cpp )
target_link_libraries (Idas Solver ${Boost_LIBRARIES} ${SUNDIALS_LIBS} )
add_library(${IdasName} SHARED Idas.cpp IdasSettings.cpp )
target_link_libraries (${IdasName} ${SolverName} ${Boost_LIBRARIES} ${SUNDIALS_LIBS} )

install (TARGETS Idas DESTINATION bin)
install (TARGETS ${IdasName} DESTINATION lib/omc)



Expand Down

0 comments on commit 62257c6

Please sign in to comment.