From 98e3226fd197f72e0e24d2006e159b45918c159b Mon Sep 17 00:00:00 2001 From: sjunges Date: Fri, 4 Sep 2015 10:54:23 +0200 Subject: [PATCH] first version of stormpy (we can parse a prism program) Former-commit-id: dc13d7f183cc989da6f3a1a1903e802e9e4bf1e8 --- CMakeLists.txt | 3 ++- src/CMakeLists.txt | 4 ++++ src/python/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ src/python/storm-core.cpp | 16 ++++++++++++++++ src/python/storm-info.cpp | 3 ++- stormpy/__init__.py | 0 stormpy/core/__init__.py | 1 + stormpy/info/__init__.py | 1 + 8 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/python/CMakeLists.txt create mode 100644 src/python/storm-core.cpp create mode 100644 stormpy/__init__.py create mode 100644 stormpy/core/__init__.py create mode 100644 stormpy/info/__init__.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 77ccb1cf2..5b506affe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,8 @@ message(STATUS "StoRM - CMAKE_BUILD_TYPE (ENV): $ENV{CMAKE_BUILD_TYPE}") # Base path for test files 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") ############################################################# ## diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 454fe8262..181e03cee 100644 --- a/src/CMakeLists.txt +++ b/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_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_PYTHON ${PROJECT_SOURCE_DIR}/src/python/*.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_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}) list(REMOVE_ITEM STORM_LIB_SOURCES ${STORM_SOURCES_CLI}) +list(REMOVE_ITEM STORM_LIB_SOURCES ${STORM_SOURCES_PYTHON}) set(STORM_LIB_HEADERS ${STORM_HEADERS}) list(REMOVE_ITEM STORM_LIB_HEADERS ${STORM_HEADERS_CLI}) set(STORM_MAIN_SOURCES ${STORM_SOURCES_CLI} ${STORM_MAIN_FILE}) @@ -115,3 +117,5 @@ INSTALL(TARGETS storm-main LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) + +add_subdirectory(python EXCLUDE_FROM_ALL) \ No newline at end of file diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt new file mode 100644 index 000000000..72a1ab63b --- /dev/null +++ b/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() diff --git a/src/python/storm-core.cpp b/src/python/storm-core.cpp new file mode 100644 index 000000000..be512bf22 --- /dev/null +++ b/src/python/storm-core.cpp @@ -0,0 +1,16 @@ + +#include +#include "../utility/storm.h" + +BOOST_PYTHON_MODULE(_core) +{ + using namespace boost::python; + def("setUp", storm::utility::setUp); + + class_("Program") + .def("getNumberOfModules", &storm::prism::Program::getNumberOfModules) + ; + + def("parseProgram", storm::parseProgram); + +} \ No newline at end of file diff --git a/src/python/storm-info.cpp b/src/python/storm-info.cpp index 027f5541e..c9d3acc99 100644 --- a/src/python/storm-info.cpp +++ b/src/python/storm-info.cpp @@ -1,10 +1,11 @@ #include #include "../utility/storm-version.h" -BOOST_PYTHON_MODULE(libstormpy) +BOOST_PYTHON_MODULE(_info) { using namespace boost::python; class_("Version") .def("short", &storm::utility::StormVersion::shortVersionString) + .def("long", &storm::utility::StormVersion::longVersionString) ; } \ No newline at end of file diff --git a/stormpy/__init__.py b/stormpy/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/stormpy/core/__init__.py b/stormpy/core/__init__.py new file mode 100644 index 000000000..ab88a96bd --- /dev/null +++ b/stormpy/core/__init__.py @@ -0,0 +1 @@ +from stormpy.core._core import * \ No newline at end of file diff --git a/stormpy/info/__init__.py b/stormpy/info/__init__.py new file mode 100644 index 000000000..0ebe48cb2 --- /dev/null +++ b/stormpy/info/__init__.py @@ -0,0 +1 @@ +from stormpy.info._info import * \ No newline at end of file