From c890a5590d0e5ac9eaf2b7a173c827f2ca10e3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Fri, 22 Mar 2013 13:17:44 -0300 Subject: First draft of the launcher --- src/CMakeLists.txt | 14 ++++++++++++++ src/launcher.rc | 1 + src/main.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 src/CMakeLists.txt create mode 100644 src/launcher.rc create mode 100644 src/main.cpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..b783d6c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,14 @@ +SET(CMAKE_SKIP_BUILD_RPATH FALSE) +SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +SET(CMAKE_INSTALL_RPATH "lib") +SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +SET(launcher_SOURCES main.cpp) + +IF(WIN32) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows") + SET(launcher_SOURCES ${launcher_SOURCES} launcher.rc) +ENDIF(WIN32) + +ADD_EXECUTABLE(launcher ${launcher_SOURCES}) +TARGET_LINK_LIBRARIES(launcher ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) diff --git a/src/launcher.rc b/src/launcher.rc new file mode 100644 index 0000000..7655199 --- /dev/null +++ b/src/launcher.rc @@ -0,0 +1 @@ +id ICON "../res/leap.ico" diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..237b282 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,38 @@ +#include +#include +#include + +#include +#include + +using namespace boost::python; + +int +main(int argc, char** argv) +{ + try { + Py_Initialize(); + object main_module = import("__main__"); + object global = (main_module.attr("__dict__")); + + PySys_SetArgv(argc, argv); + + exec( + "import os\n" + "import sys\n" + "import encodings.idna\n" // we need to make sure this is imported + "sys.path = [os.path.join(os.getcwd(), 'deps'),\n" + " os.path.join(os.getcwd(), 'apps'),\n" + " os.path.join(os.getcwd(), 'apps', 'eip'),\n" + " os.getcwd()]\n" + "sys.argv.append('--standalone')\n", global, global); + + exec_file("apps/leap/app.py", + global, + global); + } catch (error_already_set&) { + PyErr_PrintEx(0); + return 1; + } + return 0; +} -- cgit v1.2.3