Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/MacOS-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ jobs:
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
if [[ "${cling_on}" == "ON" ]]; then
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DUSE_CLING=ON \
-DUSE_REPL=OFF \
-DCPPINTEROP_USE_CLING=ON \
-DCPPINTEROP_USE_REPL=OFF \
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ jobs:
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
if [[ "${cling_on}" == "ON" ]]; then
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DUSE_CLING=ON \
-DUSE_REPL=OFF \
-DCPPINTEROP_USE_CLING=ON \
-DCPPINTEROP_USE_REPL=OFF \
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Ubuntu-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ jobs:
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
if [[ "${cling_on}" == "ON" ]]; then
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DUSE_CLING=ON \
-DUSE_REPL=OFF \
-DCPPINTEROP_USE_CLING=ON \
-DCPPINTEROP_USE_REPL=OFF \
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ jobs:
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
if [[ "${cling_on}" == "ON" ]]; then
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DUSE_CLING=ON \
-DUSE_REPL=OFF \
-DCPPINTEROP_USE_CLING=ON \
-DCPPINTEROP_USE_REPL=OFF \
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ jobs:
if ( "${{ matrix.cling }}" -imatch "On" )
{
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} `
-DUSE_CLING=ON `
-DUSE_REPL=OFF `
-DCPPINTEROP_USE_CLING=ON `
-DCPPINTEROP_USE_REPL=OFF `
-DCling_DIR="$env:LLVM_BUILD_DIR\tools\cling" `
-DLLVM_DIR="$env:LLVM_BUILD_DIR" `
-DLLVM_ENABLE_WERROR=On `
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ jobs:

if [[ "${cling_on}" == "ON" ]]; then
emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DUSE_CLING=ON \
-DUSE_REPL=OFF \
-DCPPINTEROP_USE_CLING=ON \
-DCPPINTEROP_USE_REPL=OFF \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ jobs:
export CPPINTEROP_BUILD_DIR=$PWD
if [[ "${cling_on}" == "ON" ]]; then
emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DUSE_CLING=ON \
-DUSE_REPL=OFF \
-DCPPINTEROP_USE_CLING=ON \
-DCPPINTEROP_USE_REPL=OFF \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \
Expand Down
32 changes: 16 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
enable_language(CXX)
set(CMAKE_CXX_EXTENSIONS NO)
include(GNUInstallDirs)
option(USE_CLING "Use Cling as backend" OFF)
option(USE_REPL "Use clang-repl as backend" ON)
option(CPPINTEROP_USE_CLING "Use Cling as backend" OFF)
option(CPPINTEROP_USE_REPL "Use clang-repl as backend" ON)

if (USE_CLING AND USE_REPL)
message(FATAL_ERROR "We can only use Cling (USE_CLING=On) or Repl (USE_REPL=On), but not both of them.")
if (CPPINTEROP_USE_CLING AND CPPINTEROP_USE_REPL)
message(FATAL_ERROR "We can only use Cling (CPPINTEROP_USE_CLING=On) or Repl (CPPINTEROP_USE_REPL=On), but not both of them.")
endif()

## Define supported version of clang and llvm
Expand Down Expand Up @@ -102,12 +102,12 @@ include(GNUInstallDirs)

## Find supported LLVM

if (USE_CLING)
message(STATUS "Mode USE_CLING = ON")
if (CPPINTEROP_USE_CLING)
message(STATUS "Mode CPPINTEROP_USE_CLING = ON")
find_package(LLVM REQUIRED CONFIG ${llvm_search_hints} NO_DEFAULT_PATH)
find_package(Clang REQUIRED CONFIG ${clang_search_hints} NO_DEFAULT_PATH)
find_package(Cling REQUIRED CONFIG ${cling_search_hints} NO_DEFAULT_PATH)
endif(USE_CLING)
endif(CPPINTEROP_USE_CLING)

if (LLVM_FOUND)
if (LLVM_PACKAGE_VERSION VERSION_LESS LLVM_MIN_SUPPORTED OR LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL LLVM_VERSION_UPPER_BOUND)
Expand Down Expand Up @@ -248,7 +248,7 @@ endif()

## Find supported Cling

if (USE_CLING)
if (CPPINTEROP_USE_CLING)
if (NOT Cling_FOUND AND DEFINED Cling_DIR)
find_package(Cling REQUIRED CONFIG ${cling_extra_hints} NO_DEFAULT_PATH)
endif()
Expand Down Expand Up @@ -292,24 +292,24 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
# In rare cases we might want to have clang installed in a different place
# than llvm and the header files should be found first (even though the
# LLVM_INCLUDE_DIRS) contain clang headers, too.
if (USE_CLING)
add_definitions(-DUSE_CLING)
if (CPPINTEROP_USE_CLING)
add_definitions(-DCPPINTEROP_USE_CLING)
include_directories(SYSTEM ${CLING_INCLUDE_DIRS})
else()
if (NOT USE_REPL)
message(FATAL_ERROR "We need either USE_CLING or USE_REPL")
if (NOT CPPINTEROP_USE_REPL)
message(FATAL_ERROR "We need either CPPINTEROP_USE_CLING or CPPINTEROP_USE_REPL")
endif()
add_definitions(-DUSE_REPL)
add_definitions(-DCPPINTEROP_USE_REPL)

endif(USE_CLING)
endif(CPPINTEROP_USE_CLING)
include_directories(SYSTEM ${CLANG_INCLUDE_DIRS})
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
add_definitions(${LLVM_DEFINITIONS_LIST})

if (USE_CLING)
if (CPPINTEROP_USE_CLING)
message(STATUS "CLING_INCLUDE_DIRS: ${CLING_INCLUDE_DIRS}")
endif(USE_CLING)
endif(CPPINTEROP_USE_CLING)
message(STATUS "CLANG_INCLUDE_DIRS: ${CLANG_INCLUDE_DIRS}")
message(STATUS "LLVM_INCLUDE_DIRS: ${LLVM_INCLUDE_DIRS}")
message(STATUS "LLVM_DEFINITIONS_LIST: ${LLVM_DEFINITIONS_LIST}")
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,14 @@ cmake --build . --target install --parallel $env:ncpus
on Windows. If alternatively you would like to install CppInterOp with Cling then execute the following commands on Linux and MacOS

```bash
cmake -DBUILD_SHARED_LIBS=ON -DUSE_CLING=ON -DUSE_REPL=Off -DCling_DIR=$LLVM_DIR/build/tools/cling -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR/build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..
cmake -DBUILD_SHARED_LIBS=ON -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$LLVM_DIR/build/tools/cling -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR/build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..
cmake --build . --target install --parallel $(nproc --all)
```

and

```powershell
cmake -DUSE_CLING=ON -DUSE_REPL=Off -DCling_DIR=$env:LLVM_DIR\build\tools\cling -DLLVM_DIR=$env:LLVM_DIR\build\lib\cmake\llvm -DClang_DIR=$env:LLVM_DIR\build\lib\cmake\clang -DCMAKE_INSTALL_PREFIX=$env:CPPINTEROP_DIR ..
cmake -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$env:LLVM_DIR\build\tools\cling -DLLVM_DIR=$env:LLVM_DIR\build\lib\cmake\llvm -DClang_DIR=$env:LLVM_DIR\build\lib\cmake\clang -DCMAKE_INSTALL_PREFIX=$env:CPPINTEROP_DIR ..
cmake --build . --target install --parallel $env:ncpus
```

Expand Down
4 changes: 2 additions & 2 deletions docs/DevelopersDocumentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@ then execute the following commands on Linux and MacOS

.. code:: bash

cmake -DBUILD_SHARED_LIBS=ON -DUSE_CLING=ON -DUSE_REPL=Off -DCling_DIR=$LLVM_DIR/build/tools/cling -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR/build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..
cmake -DBUILD_SHARED_LIBS=ON -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$LLVM_DIR/build/tools/cling -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR/build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..
cmake --build . --target install --parallel $(nproc --all)

and

.. code:: powershell

cmake -DUSE_CLING=ON -DUSE_REPL=Off -DCling_DIR=$env:LLVM_DIR\build\tools\cling -DLLVM_DIR=$env:LLVM_DIR\build\lib\cmake\llvm -DClang_DIR=$env:LLVM_DIR\build\lib\cmake\clang -DCMAKE_INSTALL_PREFIX=$env:CPPINTEROP_DIR ..
cmake -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$env:LLVM_DIR\build\tools\cling -DLLVM_DIR=$env:LLVM_DIR\build\lib\cmake\llvm -DClang_DIR=$env:LLVM_DIR\build\lib\cmake\clang -DCMAKE_INSTALL_PREFIX=$env:CPPINTEROP_DIR ..
cmake --build . --target install --parallel $env:ncpus

********************
Expand Down
4 changes: 2 additions & 2 deletions docs/InstallationAndUsage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@ then execute the following commands on Linux and MacOS

.. code:: bash

cmake -DBUILD_SHARED_LIBS=ON -DUSE_CLING=ON -DUSE_REPL=Off -DCling_DIR=$LLVM_DIR/build/tools/cling -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR/build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..
cmake -DBUILD_SHARED_LIBS=ON -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$LLVM_DIR/build/tools/cling -DLLVM_DIR=$LLVM_DIR/build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR/build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..
cmake --build . --target install --parallel $(nproc --all)

and

.. code:: powershell

cmake -DUSE_CLING=ON -DUSE_REPL=Off -DCling_DIR=$env:LLVM_DIR\build\tools\cling -DLLVM_DIR=$env:LLVM_DIR\build\lib\cmake\llvm -DClang_DIR=$env:LLVM_DIR\build\lib\cmake\clang -DCMAKE_INSTALL_PREFIX=$env:CPPINTEROP_DIR ..
cmake -DCPPINTEROP_USE_CLING=ON -DCPPINTEROP_USE_REPL=Off -DCling_DIR=$env:LLVM_DIR\build\tools\cling -DLLVM_DIR=$env:LLVM_DIR\build\lib\cmake\llvm -DClang_DIR=$env:LLVM_DIR\build\lib\cmake\clang -DCMAKE_INSTALL_PREFIX=$env:CPPINTEROP_DIR ..
cmake --build . --target install --parallel $env:ncpus

********************
Expand Down
12 changes: 6 additions & 6 deletions lib/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ else()
DynamicLibraryManagerSymbol.cpp
Paths.cpp
)
if (USE_CLING)
if (CPPINTEROP_USE_CLING)
set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${DLM})
set(DLM)
endif(USE_CLING)
if (USE_REPL)
endif(CPPINTEROP_USE_CLING)
if (CPPINTEROP_USE_REPL)
#Use DML optional sources
endif(USE_REPL)
endif(CPPINTEROP_USE_REPL)

if (USE_CLING)
if (CPPINTEROP_USE_CLING)
set(cling_clang_interp clingInterpreter)
endif()
if (USE_REPL)
if (CPPINTEROP_USE_REPL)
set(cling_clang_interp clangInterpreter)
endif()

Expand Down
20 changes: 10 additions & 10 deletions lib/Interpreter/CXCppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,25 +291,25 @@ CXInterpreter clang_createInterpreterFromRawPtr(TInterp_t I) {
}

void* clang_Interpreter_getClangInterpreter(CXInterpreter I) {
#ifdef USE_CLING
#ifdef CPPINTEROP_USE_CLING
return nullptr;
#else
auto* interp = getInterpreter(I);
auto* clInterp = &static_cast<clang::Interpreter&>(*interp);
return clInterp;
#endif // USE_CLING
#endif // CPPINTEROP_USE_CLING
}

TInterp_t clang_Interpreter_takeInterpreterAsPtr(CXInterpreter I) {
return static_cast<CXInterpreterImpl*>(I)->Interp.release();
}

enum CXErrorCode clang_Interpreter_undo(CXInterpreter I, unsigned int N) {
#ifdef USE_CLING
#ifdef CPPINTEROP_USE_CLING
return CXError_Failure;
#else
return getInterpreter(I)->Undo(N) ? CXError_Failure : CXError_Success;
#endif // USE_CLING
#endif // CPPINTEROP_USE_CLING
}

void clang_Interpreter_dispose(CXInterpreter I) {
Expand Down Expand Up @@ -351,30 +351,30 @@ enum CXErrorCode clang_Interpreter_process(CXInterpreter I, const char* code) {
}

CXValue clang_createValue(void) {
#ifdef USE_CLING
#ifdef CPPINTEROP_USE_CLING
auto val = std::make_unique<cling::Value>();
#else
auto val = std::make_unique<clang::Value>();
#endif // USE_CLING
#endif // CPPINTEROP_USE_CLING

return val.release();
}

void clang_Value_dispose(CXValue V) {
#ifdef USE_CLING
#ifdef CPPINTEROP_USE_CLING
delete static_cast<cling::Value*>(V); // NOLINT(*-owning-memory)
#else
delete static_cast<clang::Value*>(V); // NOLINT(*-owning-memory)
#endif // USE_CLING
#endif // CPPINTEROP_USE_CLING
}

enum CXErrorCode clang_Interpreter_evaluate(CXInterpreter I, const char* code,
CXValue V) {
#ifdef USE_CLING
#ifdef CPPINTEROP_USE_CLING
auto* val = static_cast<cling::Value*>(V);
#else
auto* val = static_cast<clang::Value*>(V);
#endif // USE_CLING
#endif // CPPINTEROP_USE_CLING

if (getInterpreter(I)->evaluate(code, *val))
return CXError_Failure;
Expand Down
12 changes: 6 additions & 6 deletions lib/Interpreter/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static inline char* GetEnv(const char* Var_Name) {
// std::regex breaks pytorch's jit: pytorch/pytorch#49460
#include "llvm/Support/Regex.h"

#ifdef USE_CLING
#ifdef CPPINTEROP_USE_CLING

#include "cling/Interpreter/DynamicLibraryManager.h"
#include "cling/Interpreter/Interpreter.h"
Expand Down Expand Up @@ -222,9 +222,9 @@ inline void codeComplete(std::vector<std::string>& Results,

} // namespace compat

#endif // USE_CLING
#endif // CPPINTEROP_USE_CLING

#ifndef USE_CLING
#ifndef CPPINTEROP_USE_CLING

#include "DynamicLibraryManager.h"
#include "clang/AST/Mangle.h"
Expand Down Expand Up @@ -444,7 +444,7 @@ namespace compat {
using Interpreter = Cpp::Interpreter;
}

#endif // USE_REPL
#endif // CPPINTEROP_USE_REPL

namespace compat {

Expand Down Expand Up @@ -482,15 +482,15 @@ inline std::string MakeResourceDir(llvm::StringRef Dir) {
}

// Clang >= 16 (=16 with Value patch) change castAs to converTo
#ifdef USE_CLING
#ifdef CPPINTEROP_USE_CLING
template <typename T> inline T convertTo(cling::Value V) {
return V.castAs<T>();
}
#else // CLANG_REPL
template <typename T> inline T convertTo(clang::Value V) {
return V.convertTo<T>();
}
#endif // USE_CLING
#endif // CPPINTEROP_USE_CLING

} // namespace compat

Expand Down
Loading
Loading