Browse Source

first version of stormpy (we can parse a prism program)

Former-commit-id: dc13d7f183
tempestpy_adaptions
sjunges 9 years ago
parent
commit
98e3226fd1
  1. 3
      CMakeLists.txt
  2. 4
      src/CMakeLists.txt
  3. 30
      src/python/CMakeLists.txt
  4. 16
      src/python/storm-core.cpp
  5. 3
      src/python/storm-info.cpp
  6. 0
      stormpy/__init__.py
  7. 1
      stormpy/core/__init__.py
  8. 1
      stormpy/info/__init__.py

3
CMakeLists.txt

@ -49,7 +49,8 @@ message(STATUS "StoRM - CMAKE_BUILD_TYPE (ENV): $ENV{CMAKE_BUILD_TYPE}")
# Base path for test files # Base path for test files
set(STORM_CPP_TESTS_BASE_PATH "${PROJECT_SOURCE_DIR}/test") set(STORM_CPP_TESTS_BASE_PATH "${PROJECT_SOURCE_DIR}/test")
set(STORMPY_OUTPUT_DIR "${PROJECT_BINARY_DIR}/stormpy")
set(STORMPY_SOURCE_DIR "${PROJECT_SOURCE_DIR}/stormpy")
############################################################# #############################################################
## ##

4
src/CMakeLists.txt

@ -8,6 +8,7 @@ file(GLOB_RECURSE STORM_HEADERS ${PROJECT_SOURCE_DIR}/src/*.h)
file(GLOB_RECURSE STORM_HEADERS_CLI ${PROJECT_SOURCE_DIR}/src/cli/*.h) file(GLOB_RECURSE STORM_HEADERS_CLI ${PROJECT_SOURCE_DIR}/src/cli/*.h)
file(GLOB_RECURSE STORM_SOURCES_WITHOUT_MAIN ${PROJECT_SOURCE_DIR}/src/*/*.cpp) file(GLOB_RECURSE STORM_SOURCES_WITHOUT_MAIN ${PROJECT_SOURCE_DIR}/src/*/*.cpp)
file(GLOB_RECURSE STORM_SOURCES_CLI ${PROJECT_SOURCE_DIR}/src/cli/*.cpp) file(GLOB_RECURSE STORM_SOURCES_CLI ${PROJECT_SOURCE_DIR}/src/cli/*.cpp)
file(GLOB_RECURSE STORM_SOURCES_PYTHON ${PROJECT_SOURCE_DIR}/src/python/*.cpp)
file(GLOB_RECURSE STORM_MAIN_FILE ${PROJECT_SOURCE_DIR}/src/storm.cpp) file(GLOB_RECURSE STORM_MAIN_FILE ${PROJECT_SOURCE_DIR}/src/storm.cpp)
file(GLOB_RECURSE STORM_ADAPTERS_FILES ${PROJECT_SOURCE_DIR}/src/adapters/*.h ${PROJECT_SOURCE_DIR}/src/adapters/*.cpp) file(GLOB_RECURSE STORM_ADAPTERS_FILES ${PROJECT_SOURCE_DIR}/src/adapters/*.h ${PROJECT_SOURCE_DIR}/src/adapters/*.cpp)
file(GLOB_RECURSE STORM_BUILDER_FILES ${PROJECT_SOURCE_DIR}/src/builder/*.h ${PROJECT_SOURCE_DIR}/src/builder/*.cpp) file(GLOB_RECURSE STORM_BUILDER_FILES ${PROJECT_SOURCE_DIR}/src/builder/*.h ${PROJECT_SOURCE_DIR}/src/builder/*.cpp)
@ -45,6 +46,7 @@ file(GLOB_RECURSE STORM_BUILD_HEADERS ${PROJECT_BINARY_DIR}/include/*.h)
set(STORM_LIB_SOURCES ${STORM_SOURCES_WITHOUT_MAIN}) set(STORM_LIB_SOURCES ${STORM_SOURCES_WITHOUT_MAIN})
list(REMOVE_ITEM STORM_LIB_SOURCES ${STORM_SOURCES_CLI}) list(REMOVE_ITEM STORM_LIB_SOURCES ${STORM_SOURCES_CLI})
list(REMOVE_ITEM STORM_LIB_SOURCES ${STORM_SOURCES_PYTHON})
set(STORM_LIB_HEADERS ${STORM_HEADERS}) set(STORM_LIB_HEADERS ${STORM_HEADERS})
list(REMOVE_ITEM STORM_LIB_HEADERS ${STORM_HEADERS_CLI}) list(REMOVE_ITEM STORM_LIB_HEADERS ${STORM_HEADERS_CLI})
set(STORM_MAIN_SOURCES ${STORM_SOURCES_CLI} ${STORM_MAIN_FILE}) set(STORM_MAIN_SOURCES ${STORM_SOURCES_CLI} ${STORM_MAIN_FILE})
@ -115,3 +117,5 @@ INSTALL(TARGETS storm-main
LIBRARY DESTINATION lib LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib ARCHIVE DESTINATION lib
) )
add_subdirectory(python EXCLUDE_FROM_ALL)

30
src/python/CMakeLists.txt

@ -0,0 +1,30 @@
#############################################################
##
## STORM PYTHON
##
#############################################################
if(STORM_PYTHON)
add_library(stormpy-info SHARED ${CMAKE_CURRENT_SOURCE_DIR}/storm-info.cpp)
target_link_libraries(stormpy-info storm ${BOOST_PYTHON_LIB} ${PYTHON_LIBRARIES})
set_target_properties(stormpy-info PROPERTIES
OUTPUT_NAME _info
LIBRARY_OUTPUT_DIRECTORY ${STORMPY_OUTPUT_DIR}/info
PREFIX ""
SUFFIX ".so"
)
add_library(stormpy-core SHARED ${CMAKE_CURRENT_SOURCE_DIR}/storm-core.cpp)
target_link_libraries(stormpy-core storm ${BOOST_PYTHON_LIB} ${PYTHON_LIBRARIES})
set_target_properties(stormpy-core PROPERTIES
OUTPUT_NAME _core
LIBRARY_OUTPUT_DIRECTORY ${STORMPY_OUTPUT_DIR}/core
PREFIX ""
SUFFIX ".so"
)
add_custom_target(stormpy DEPENDS stormpy-info stormpy-core)
add_custom_command(TARGET stormpy PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${STORMPY_SOURCE_DIR} ${STORMPY_OUTPUT_DIR})
endif()

16
src/python/storm-core.cpp

@ -0,0 +1,16 @@
#include <boost/python.hpp>
#include "../utility/storm.h"
BOOST_PYTHON_MODULE(_core)
{
using namespace boost::python;
def("setUp", storm::utility::setUp);
class_<storm::prism::Program>("Program")
.def("getNumberOfModules", &storm::prism::Program::getNumberOfModules)
;
def("parseProgram", storm::parseProgram);
}

3
src/python/storm-info.cpp

@ -1,10 +1,11 @@
#include <boost/python.hpp> #include <boost/python.hpp>
#include "../utility/storm-version.h" #include "../utility/storm-version.h"
BOOST_PYTHON_MODULE(libstormpy)
BOOST_PYTHON_MODULE(_info)
{ {
using namespace boost::python; using namespace boost::python;
class_<storm::utility::StormVersion>("Version") class_<storm::utility::StormVersion>("Version")
.def("short", &storm::utility::StormVersion::shortVersionString) .def("short", &storm::utility::StormVersion::shortVersionString)
.def("long", &storm::utility::StormVersion::longVersionString)
; ;
} }

0
stormpy/__init__.py

1
stormpy/core/__init__.py

@ -0,0 +1 @@
from stormpy.core._core import *

1
stormpy/info/__init__.py

@ -0,0 +1 @@
from stormpy.info._info import *
Loading…
Cancel
Save