Jupyter kernel support dylib.
This commit is contained in:
parent
6eac3e3159
commit
2f2c2151c0
55
tools/Jupyter/CMakeLists.txt
Normal file
55
tools/Jupyter/CMakeLists.txt
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# CLING - the C++ LLVM-based InterpreterG :)
|
||||||
|
#
|
||||||
|
# This file is dual-licensed: you can choose to license it under the University
|
||||||
|
# of Illinois Open Source License or the GNU Lesser General Public License. See
|
||||||
|
# LICENSE.TXT for details.
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set(SOURCES
|
||||||
|
Kernel.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(LIBS
|
||||||
|
clangBasic
|
||||||
|
clangAST
|
||||||
|
clangFrontend
|
||||||
|
clingInterpreter
|
||||||
|
clingUtils
|
||||||
|
)
|
||||||
|
|
||||||
|
if( LLVM_ENABLE_PIC )
|
||||||
|
set(ENABLE_SHARED SHARED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(output_name "libclingJupyter")
|
||||||
|
else()
|
||||||
|
set(output_name "clingJupyter")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_clang_library(libclingJupyter ${ENABLE_SHARED} ${ENABLE_STATIC}
|
||||||
|
OUTPUT_NAME ${output_name}
|
||||||
|
${SOURCES}
|
||||||
|
# DEPENDS clang-headers
|
||||||
|
|
||||||
|
LINK_LIBS
|
||||||
|
${LIBS}
|
||||||
|
|
||||||
|
LINK_COMPONENTS
|
||||||
|
Core
|
||||||
|
Support
|
||||||
|
)
|
||||||
|
|
||||||
|
if(ENABLE_SHARED)
|
||||||
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
set(LIBCLINGJUPYTER_LINK_FLAGS " -Wl,-compatibility_version -Wl,1")
|
||||||
|
if (DEFINED ${LLVM_SUBMIT_VERSION})
|
||||||
|
set(LIBCLINGJUPYTER_LINK_FLAGS
|
||||||
|
"${LIBCLINGJUPYTER_LINK_FLAGS} -Wl,-current_version -Wl,${LLVM_SUBMIT_VERSION}.${LLVM_SUBMIT_SUBVERSION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_property(TARGET libclingJupyter APPEND_STRING PROPERTY
|
||||||
|
LINK_FLAGS ${LIBCLINGJUPYTER_LINK_FLAGS})
|
||||||
|
endif()
|
||||||
|
endif()
|
33
tools/Jupyter/Kernel.cpp
Normal file
33
tools/Jupyter/Kernel.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// Created by Axel Naumann on 09/12/15.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "cling/Interpreter/Interpreter.h"
|
||||||
|
#include "cling/Interpreter/Value.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
///\{
|
||||||
|
///\name Cling4CTypes
|
||||||
|
/// The Python compatible view of cling
|
||||||
|
|
||||||
|
/// The Interpreter object cast to void*
|
||||||
|
using TheInterpreter = void ;
|
||||||
|
|
||||||
|
/// Create an interpreter object.
|
||||||
|
TheInterpreter *cling_create(int argc, const char *argv[], const char* llvmdir) {
|
||||||
|
return new cling::Interpreter(argc, argv, llvmdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Evaluate a string of code. Returns 0 on success.
|
||||||
|
int cling_eval(TheInterpreter *interpVP, const char *code) {
|
||||||
|
cling::Interpreter *interp = (cling::Interpreter *) interpVP;
|
||||||
|
printf("Interpreter %s about to run \"%s\"\n", interp->getVersion(), code);
|
||||||
|
cling::Value V;
|
||||||
|
cling::Interpreter::CompilationResult Res = interp->evaluate(code, V);
|
||||||
|
if (Res != cling::Interpreter::kSuccess)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
///\}
|
||||||
|
|
||||||
|
} // extern "C"
|
Loading…
Reference in New Issue
Block a user