Merge pull request #231 from afh/dev/pylib

Create shared python module
This commit is contained in:
John Wiegley 2014-01-27 16:58:59 -08:00
commit 35c1bf03ec
3 changed files with 15 additions and 0 deletions

View file

@ -244,11 +244,20 @@ endif()
add_pch_rule(${PROJECT_BINARY_DIR}/system.hh LEDGER_SOURCES main.cc global.cc) add_pch_rule(${PROJECT_BINARY_DIR}/system.hh LEDGER_SOURCES main.cc global.cc)
if(BUILD_LIBRARY) if(BUILD_LIBRARY)
add_library(pyledger SHARED ${LEDGER_SOURCES})
add_ledger_library_dependencies(pyledger)
if(CMAKE_HOST_APPLE)
set_target_properties(pyledger PROPERTIES OUTPUT_NAME ledger)
set_target_properties(pyledger PROPERTIES SUFFIX .so)
set(CMAKE_SHARED_LIBRARY_PREFIX )
endif()
add_library(libledger ${LEDGER_SOURCES} ${PROJECT_SOURCE_DIR}/lib/sha1.cpp) add_library(libledger ${LEDGER_SOURCES} ${PROJECT_SOURCE_DIR}/lib/sha1.cpp)
set_target_properties(libledger PROPERTIES OUTPUT_NAME ledger) set_target_properties(libledger PROPERTIES OUTPUT_NAME ledger)
add_executable(ledger main.cc global.cc) add_executable(ledger main.cc global.cc)
install(TARGETS pyledger DESTINATION lib)
install(TARGETS libledger DESTINATION lib) install(TARGETS libledger DESTINATION lib)
install(FILES ${LEDGER_INCLUDES} DESTINATION include/ledger) install(FILES ${LEDGER_INCLUDES} DESTINATION include/ledger)
else() else()

View file

@ -315,6 +315,7 @@ void export_commodity()
scope().attr("COMMODITY_STYLE_SUFFIXED") = COMMODITY_STYLE_SUFFIXED; scope().attr("COMMODITY_STYLE_SUFFIXED") = COMMODITY_STYLE_SUFFIXED;
scope().attr("COMMODITY_STYLE_SEPARATED") = COMMODITY_STYLE_SEPARATED; scope().attr("COMMODITY_STYLE_SEPARATED") = COMMODITY_STYLE_SEPARATED;
scope().attr("COMMODITY_STYLE_DECIMAL_COMMA") = COMMODITY_STYLE_DECIMAL_COMMA; scope().attr("COMMODITY_STYLE_DECIMAL_COMMA") = COMMODITY_STYLE_DECIMAL_COMMA;
scope().attr("COMMODITY_STYLE_TIME_COLON") = COMMODITY_STYLE_TIME_COLON;
scope().attr("COMMODITY_STYLE_THOUSANDS") = COMMODITY_STYLE_THOUSANDS; scope().attr("COMMODITY_STYLE_THOUSANDS") = COMMODITY_STYLE_THOUSANDS;
scope().attr("COMMODITY_NOMARKET") = COMMODITY_NOMARKET; scope().attr("COMMODITY_NOMARKET") = COMMODITY_NOMARKET;
scope().attr("COMMODITY_BUILTIN") = COMMODITY_BUILTIN; scope().attr("COMMODITY_BUILTIN") = COMMODITY_BUILTIN;

View file

@ -34,6 +34,7 @@
#include "pyinterp.h" #include "pyinterp.h"
#include "pyutils.h" #include "pyutils.h"
#include "account.h" #include "account.h"
#include "report.h"
#include "xact.h" #include "xact.h"
#include "post.h" #include "post.h"
@ -76,6 +77,10 @@ void initialize_for_python()
export_xact(); export_xact();
export_session(); export_session();
export_journal(); export_journal();
python_session.reset(new ledger::python_interpreter_t);
shared_ptr<session_t> session_ptr = python_session;
scope_t::default_scope = new report_t(*session_ptr);
} }
struct python_run struct python_run