diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-03-22 13:17:44 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-03-22 13:17:44 -0300 |
commit | c890a5590d0e5ac9eaf2b7a173c827f2ca10e3be (patch) | |
tree | 10999f05975c8be90466e98850954bf4e7f1e24e | |
parent | 2732de4495fd7dc9232b2ea21fc2ad019802ae71 (diff) |
First draft of the launcher
-rw-r--r-- | .gitignore | 31 | ||||
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | res/leap.ico | bin | 0 -> 215486 bytes | |||
-rw-r--r-- | src/CMakeLists.txt | 14 | ||||
-rw-r--r-- | src/launcher.rc | 1 | ||||
-rw-r--r-- | src/main.cpp | 38 |
6 files changed, 92 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e448beb --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +*.swp +*.swo +*.pyc +*.log +*.*~ +.* +*_rc.py +ui_*.py +!.coveragerc +!.tx +bin/ +build/ +core +debian/python-leap-client/ +dist/ +docs/_build +docs/covhtml +include/ +lib/ +local/ +share/ +src/leap.egg-info/ +src/leap_client.egg-info +src/leap/_branding.py +src/leap/certs/*.pem +src/*.egg-info +src/pysqlcipher +pkg/osx/dist +pkg/osx/build +MANIFEST +_trial_temp* diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..87185c7 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8.3) +FIND_PACKAGE(PythonInterp) +FIND_PACKAGE(PythonLibs) +FIND_PACKAGE(Boost COMPONENTS python) + +INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}) + +ADD_SUBDIRECTORY(src) diff --git a/res/leap.ico b/res/leap.ico Binary files differnew file mode 100644 index 0000000..829126a --- /dev/null +++ b/res/leap.ico 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; +} |