Skip to content

Commit 6c6f94a

Browse files
committed
Prefix the interpreter cmake option
1 parent be5141c commit 6c6f94a

18 files changed

+86
-86
lines changed

Diff for: .github/workflows/MacOS-arm.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ jobs:
396396
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
397397
if [[ "${cling_on}" == "ON" ]]; then
398398
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
399-
-DUSE_CLING=ON \
400-
-DUSE_REPL=OFF \
399+
-DCPPINTEROP_USE_CLING=ON \
400+
-DCPPINTEROP_USE_REPL=OFF \
401401
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
402402
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
403403
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \

Diff for: .github/workflows/MacOS.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ jobs:
367367
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
368368
if [[ "${cling_on}" == "ON" ]]; then
369369
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
370-
-DUSE_CLING=ON \
371-
-DUSE_REPL=OFF \
370+
-DCPPINTEROP_USE_CLING=ON \
371+
-DCPPINTEROP_USE_REPL=OFF \
372372
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
373373
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
374374
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \

Diff for: .github/workflows/Ubuntu-arm.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ jobs:
449449
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
450450
if [[ "${cling_on}" == "ON" ]]; then
451451
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
452-
-DUSE_CLING=ON \
453-
-DUSE_REPL=OFF \
452+
-DCPPINTEROP_USE_CLING=ON \
453+
-DCPPINTEROP_USE_REPL=OFF \
454454
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
455455
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
456456
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \

Diff for: .github/workflows/Ubuntu.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ jobs:
457457
cling_on=$(echo "${{ matrix.cling }}" | tr '[:lower:]' '[:upper:]')
458458
if [[ "${cling_on}" == "ON" ]]; then
459459
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
460-
-DUSE_CLING=ON \
461-
-DUSE_REPL=OFF \
460+
-DCPPINTEROP_USE_CLING=ON \
461+
-DCPPINTEROP_USE_REPL=OFF \
462462
-DCPPINTEROP_INCLUDE_DOCS=${{ matrix.documentation }} \
463463
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
464464
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \

Diff for: .github/workflows/Windows.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ jobs:
357357
if ( "${{ matrix.cling }}" -imatch "On" )
358358
{
359359
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} `
360-
-DUSE_CLING=ON `
361-
-DUSE_REPL=OFF `
360+
-DCPPINTEROP_USE_CLING=ON `
361+
-DCPPINTEROP_USE_REPL=OFF `
362362
-DCling_DIR="$env:LLVM_BUILD_DIR\tools\cling" `
363363
-DLLVM_DIR="$env:LLVM_BUILD_DIR" `
364364
-DLLVM_ENABLE_WERROR=On `

Diff for: .github/workflows/deploy-pages.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ jobs:
119119
120120
if [[ "${cling_on}" == "ON" ]]; then
121121
emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
122-
-DUSE_CLING=ON \
123-
-DUSE_REPL=OFF \
122+
-DCPPINTEROP_USE_CLING=ON \
123+
-DCPPINTEROP_USE_REPL=OFF \
124124
-DCMAKE_PREFIX_PATH=$PREFIX \
125125
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
126126
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \

Diff for: .github/workflows/emscripten.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ jobs:
575575
export CPPINTEROP_BUILD_DIR=$PWD
576576
if [[ "${cling_on}" == "ON" ]]; then
577577
emcmake cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
578-
-DUSE_CLING=ON \
579-
-DUSE_REPL=OFF \
578+
-DCPPINTEROP_USE_CLING=ON \
579+
-DCPPINTEROP_USE_REPL=OFF \
580580
-DCMAKE_PREFIX_PATH=$PREFIX \
581581
-DCling_DIR=$LLVM_BUILD_DIR/tools/cling \
582582
-DLLVM_DIR=$LLVM_BUILD_DIR/lib/cmake/llvm \

Diff for: CMakeLists.txt

+16-16
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
5757
enable_language(CXX)
5858
set(CMAKE_CXX_EXTENSIONS NO)
5959
include(GNUInstallDirs)
60-
option(USE_CLING "Use Cling as backend" OFF)
61-
option(USE_REPL "Use clang-repl as backend" ON)
60+
option(CPPINTEROP_USE_CLING "Use Cling as backend" OFF)
61+
option(CPPINTEROP_USE_REPL "Use clang-repl as backend" ON)
6262

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

6767
## Define supported version of clang and llvm
@@ -102,12 +102,12 @@ include(GNUInstallDirs)
102102

103103
## Find supported LLVM
104104

105-
if (USE_CLING)
106-
message(STATUS "Mode USE_CLING = ON")
105+
if (CPPINTEROP_USE_CLING)
106+
message(STATUS "Mode CPPINTEROP_USE_CLING = ON")
107107
find_package(LLVM REQUIRED CONFIG ${llvm_search_hints} NO_DEFAULT_PATH)
108108
find_package(Clang REQUIRED CONFIG ${clang_search_hints} NO_DEFAULT_PATH)
109109
find_package(Cling REQUIRED CONFIG ${cling_search_hints} NO_DEFAULT_PATH)
110-
endif(USE_CLING)
110+
endif(CPPINTEROP_USE_CLING)
111111

112112
if (LLVM_FOUND)
113113
if (LLVM_PACKAGE_VERSION VERSION_LESS LLVM_MIN_SUPPORTED OR LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL LLVM_VERSION_UPPER_BOUND)
@@ -248,7 +248,7 @@ endif()
248248

249249
## Find supported Cling
250250

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

304-
endif(USE_CLING)
304+
endif(CPPINTEROP_USE_CLING)
305305
include_directories(SYSTEM ${CLANG_INCLUDE_DIRS})
306306
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
307307
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
308308
add_definitions(${LLVM_DEFINITIONS_LIST})
309309

310-
if (USE_CLING)
310+
if (CPPINTEROP_USE_CLING)
311311
message(STATUS "CLING_INCLUDE_DIRS: ${CLING_INCLUDE_DIRS}")
312-
endif(USE_CLING)
312+
endif(CPPINTEROP_USE_CLING)
313313
message(STATUS "CLANG_INCLUDE_DIRS: ${CLANG_INCLUDE_DIRS}")
314314
message(STATUS "LLVM_INCLUDE_DIRS: ${LLVM_INCLUDE_DIRS}")
315315
message(STATUS "LLVM_DEFINITIONS_LIST: ${LLVM_DEFINITIONS_LIST}")

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,14 @@ cmake --build . --target install --parallel $env:ncpus
329329
on Windows. If alternatively you would like to install CppInterOp with Cling then execute the following commands on Linux and MacOS
330330

331331
```bash
332-
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 ..
332+
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 ..
333333
cmake --build . --target install --parallel $(nproc --all)
334334
```
335335

336336
and
337337

338338
```powershell
339-
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 ..
339+
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 ..
340340
cmake --build . --target install --parallel $env:ncpus
341341
```
342342

Diff for: docs/DevelopersDocumentation.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@ then execute the following commands on Linux and MacOS
270270

271271
.. code:: bash
272272
273-
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 ..
273+
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 ..
274274
cmake --build . --target install --parallel $(nproc --all)
275275
276276
and
277277

278278
.. code:: powershell
279279
280-
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 ..
280+
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 ..
281281
cmake --build . --target install --parallel $env:ncpus
282282
283283
********************

Diff for: docs/InstallationAndUsage.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@ then execute the following commands on Linux and MacOS
270270

271271
.. code:: bash
272272
273-
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 ..
273+
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 ..
274274
cmake --build . --target install --parallel $(nproc --all)
275275
276276
and
277277

278278
.. code:: powershell
279279
280-
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 ..
280+
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 ..
281281
cmake --build . --target install --parallel $env:ncpus
282282
283283
********************

Diff for: lib/Interpreter/CMakeLists.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ else()
5050
DynamicLibraryManagerSymbol.cpp
5151
Paths.cpp
5252
)
53-
if (USE_CLING)
53+
if (CPPINTEROP_USE_CLING)
5454
set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${DLM})
5555
set(DLM)
56-
endif(USE_CLING)
57-
if (USE_REPL)
56+
endif(CPPINTEROP_USE_CLING)
57+
if (CPPINTEROP_USE_REPL)
5858
#Use DML optional sources
59-
endif(USE_REPL)
59+
endif(CPPINTEROP_USE_REPL)
6060

61-
if (USE_CLING)
61+
if (CPPINTEROP_USE_CLING)
6262
set(cling_clang_interp clingInterpreter)
6363
endif()
64-
if (USE_REPL)
64+
if (CPPINTEROP_USE_REPL)
6565
set(cling_clang_interp clangInterpreter)
6666
endif()
6767

Diff for: lib/Interpreter/CXCppInterOp.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -291,25 +291,25 @@ CXInterpreter clang_createInterpreterFromRawPtr(TInterp_t I) {
291291
}
292292

293293
void* clang_Interpreter_getClangInterpreter(CXInterpreter I) {
294-
#ifdef USE_CLING
294+
#ifdef CPPINTEROP_USE_CLING
295295
return nullptr;
296296
#else
297297
auto* interp = getInterpreter(I);
298298
auto* clInterp = &static_cast<clang::Interpreter&>(*interp);
299299
return clInterp;
300-
#endif // USE_CLING
300+
#endif // CPPINTEROP_USE_CLING
301301
}
302302

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

307307
enum CXErrorCode clang_Interpreter_undo(CXInterpreter I, unsigned int N) {
308-
#ifdef USE_CLING
308+
#ifdef CPPINTEROP_USE_CLING
309309
return CXError_Failure;
310310
#else
311311
return getInterpreter(I)->Undo(N) ? CXError_Failure : CXError_Success;
312-
#endif // USE_CLING
312+
#endif // CPPINTEROP_USE_CLING
313313
}
314314

315315
void clang_Interpreter_dispose(CXInterpreter I) {
@@ -351,30 +351,30 @@ enum CXErrorCode clang_Interpreter_process(CXInterpreter I, const char* code) {
351351
}
352352

353353
CXValue clang_createValue(void) {
354-
#ifdef USE_CLING
354+
#ifdef CPPINTEROP_USE_CLING
355355
auto val = std::make_unique<cling::Value>();
356356
#else
357357
auto val = std::make_unique<clang::Value>();
358-
#endif // USE_CLING
358+
#endif // CPPINTEROP_USE_CLING
359359

360360
return val.release();
361361
}
362362

363363
void clang_Value_dispose(CXValue V) {
364-
#ifdef USE_CLING
364+
#ifdef CPPINTEROP_USE_CLING
365365
delete static_cast<cling::Value*>(V); // NOLINT(*-owning-memory)
366366
#else
367367
delete static_cast<clang::Value*>(V); // NOLINT(*-owning-memory)
368-
#endif // USE_CLING
368+
#endif // CPPINTEROP_USE_CLING
369369
}
370370

371371
enum CXErrorCode clang_Interpreter_evaluate(CXInterpreter I, const char* code,
372372
CXValue V) {
373-
#ifdef USE_CLING
373+
#ifdef CPPINTEROP_USE_CLING
374374
auto* val = static_cast<cling::Value*>(V);
375375
#else
376376
auto* val = static_cast<clang::Value*>(V);
377-
#endif // USE_CLING
377+
#endif // CPPINTEROP_USE_CLING
378378

379379
if (getInterpreter(I)->evaluate(code, *val))
380380
return CXError_Failure;

Diff for: lib/Interpreter/Compatibility.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static inline char* GetEnv(const char* Var_Name) {
8080
// std::regex breaks pytorch's jit: pytorch/pytorch#49460
8181
#include "llvm/Support/Regex.h"
8282

83-
#ifdef USE_CLING
83+
#ifdef CPPINTEROP_USE_CLING
8484

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

223223
} // namespace compat
224224

225-
#endif // USE_CLING
225+
#endif // CPPINTEROP_USE_CLING
226226

227-
#ifndef USE_CLING
227+
#ifndef CPPINTEROP_USE_CLING
228228

229229
#include "DynamicLibraryManager.h"
230230
#include "clang/AST/Mangle.h"
@@ -444,7 +444,7 @@ namespace compat {
444444
using Interpreter = Cpp::Interpreter;
445445
}
446446

447-
#endif // USE_REPL
447+
#endif // CPPINTEROP_USE_REPL
448448

449449
namespace compat {
450450

@@ -482,15 +482,15 @@ inline std::string MakeResourceDir(llvm::StringRef Dir) {
482482
}
483483

484484
// Clang >= 16 (=16 with Value patch) change castAs to converTo
485-
#ifdef USE_CLING
485+
#ifdef CPPINTEROP_USE_CLING
486486
template <typename T> inline T convertTo(cling::Value V) {
487487
return V.castAs<T>();
488488
}
489489
#else // CLANG_REPL
490490
template <typename T> inline T convertTo(clang::Value V) {
491491
return V.convertTo<T>();
492492
}
493-
#endif // USE_CLING
493+
#endif // CPPINTEROP_USE_CLING
494494

495495
} // namespace compat
496496

0 commit comments

Comments
 (0)