summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-03-22 13:17:44 -0300
committerTomás Touceda <chiiph@leap.se>2013-03-22 13:17:44 -0300
commitc890a5590d0e5ac9eaf2b7a173c827f2ca10e3be (patch)
tree10999f05975c8be90466e98850954bf4e7f1e24e /src
parent2732de4495fd7dc9232b2ea21fc2ad019802ae71 (diff)
First draft of the launcher
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt14
-rw-r--r--src/launcher.rc1
-rw-r--r--src/main.cpp38
3 files changed, 53 insertions, 0 deletions
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 <iostream>
+#include <vector>
+#include <string>
+
+#include <boost/python.hpp>
+#include <frameobject.h>
+
+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;
+}