@@ -75,34 +75,34 @@ Build instructions for CppInterOp and its dependencies are as follows. CppInterO
7575
7676First clone the CppInterOp repository, as this contains patches that need to be applied to the subsequently cloned llvm-project repo (these patches are only applied if building CppInterOp with Clang-REPL)
7777
78- ```
78+ ``` bash
7979git clone --depth=1 https://github.com/compiler-research/CppInterOp.git
8080```
8181
8282and clone cppyy-backend repository where we will be installing the CppInterOp library
8383
84- ```
84+ ``` bash
8585git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git
8686```
8787
8888#### Setup Clang-REPL
8989
9090Clone the 19.x release of the LLVM project repository.
9191
92- ```
92+ ``` bash
9393git clone --depth=1 --branch release/19.x https://github.com/llvm/llvm-project.git
9494cd llvm-project
9595```
9696
9797For Clang 16 & 17, the following patches required for development work. To apply these patches on Linux and MacOS execute the following command(substitute ` {version} ` with your clang version):
9898
99- ```
99+ ``` bash
100100git apply -v ../CppInterOp/patches/llvm/clang{version}-* .patch
101101```
102102
103103and
104104
105- ```
105+ ``` powershell
106106cp -r ..\CppInterOp\patches\llvm\clang17* .
107107git apply -v clang{version}-*.patch
108108```
@@ -115,7 +115,7 @@ Clang-REPL is an interpreter that CppInterOp works alongside. Build Clang (and
115115Clang-REPL along with it). On Linux and MacOS you do this by executing the following
116116command
117117
118- ```
118+ ``` bash
119119mkdir build
120120cd build
121121cmake -DLLVM_ENABLE_PROJECTS=" clang;lld" \
@@ -135,7 +135,7 @@ cmake --build . --target clang clang-repl lld --parallel $(nproc --all)
135135
136136On Windows you would do this by executing the following
137137
138- ```
138+ ``` powershell
139139$env:ncpus = $([Environment]::ProcessorCount)
140140mkdir build
141141cd build
@@ -153,15 +153,15 @@ cmake -DLLVM_ENABLE_PROJECTS=clang `
153153
154154Note the 'llvm-project' directory location. On linux and MacOS you execute the following
155155
156- ```
156+ ``` bash
157157cd ../
158158export LLVM_DIR=$PWD
159159cd ../
160160```
161161
162162On Windows you execute the following
163163
164- ```
164+ ``` powershell
165165cd ..\
166166$env:LLVM_DIR= $PWD.Path
167167cd ..\
@@ -174,7 +174,7 @@ interpreter. Cling depends on its own customised version of `llvm-project`,
174174hosted under the ` root-project ` (see the git path below).
175175Use the following build instructions to build on Linux and MacOS
176176
177- ```
177+ ``` bash
178178git clone https://github.com/root-project/cling.git
179179cd ./cling/
180180git checkout tags/v1.0
@@ -204,7 +204,7 @@ cmake --build . --target gtest_main --parallel $(nproc --all)
204204
205205Use the following build instructions to build on Windows
206206
207- ```
207+ ``` powershell
208208git clone https://github.com/root-project/cling.git
209209cd .\cling\
210210git checkout tags/v1.0
@@ -233,15 +233,15 @@ cmake --build . --target gtest_main --parallel $env:ncpus
233233
234234Note the 'llvm-project' directory location. On linux and MacOS you execute the following
235235
236- ```
236+ ``` bash
237237cd ../
238238export LLVM_DIR=$PWD
239239cd ../
240240```
241241
242242On Windows you execute the following
243243
244- ```
244+ ``` powershell
245245cd ..\
246246$env:LLVM_DIR= $PWD.Path
247247cd ..\
@@ -251,21 +251,21 @@ cd ..\
251251
252252Regardless of whether you are building CppInterOP with Cling or Clang-REPL you will need to define the following environment variables (as they clear for a new session, it is recommended that you also add these to your .bashrc in linux, .bash_profile if on MacOS, or profile.ps1 on Windows). On Linux and MacOS you define as follows
253253
254- ```
254+ ``` bash
255255export CB_PYTHON_DIR=" $PWD /cppyy-backend/python"
256256export CPPINTEROP_DIR=" $CB_PYTHON_DIR /cppyy_backend"
257257export CPLUS_INCLUDE_PATH=" ${CPLUS_INCLUDE_PATH} :${LLVM_DIR} /llvm/include:${LLVM_DIR} /clang/include:${LLVM_DIR} /build/include:${LLVM_DIR} /build/tools/clang/include"
258258```
259259
260260If on MacOS you will also need the following environment variable defined
261261
262- ```
262+ ``` bash
263263export SDKROOT=` xcrun --show-sdk-path`
264264```
265265
266266On Windows you define as follows (assumes you have defined $env: PWD_DIR = $PWD.Path )
267267
268- ```
268+ ``` powershell
269269$env:CB_PYTHON_DIR="$env:PWD_DIR\cppyy-backend\python"
270270$env:CPPINTEROP_DIR="$env:CB_PYTHON_DIR\cppyy_backend"
271271$env:CPLUS_INCLUDE_PATH="$env:CPLUS_INCLUDE_PATH;$env:LLVM_DIR\llvm\include;$env:LLVM_DIR\clang\include;$env:LLVM_DIR\build\include;$env:LLVM_DIR\build\tools\clang\include"
@@ -275,69 +275,71 @@ $env:CPLUS_INCLUDE_PATH="$env:CPLUS_INCLUDE_PATH;$env:LLVM_DIR\llvm\include;$env
275275
276276Now CppInterOp can be installed. On Linux and MacOS execute
277277
278- ```
278+ ``` bash
279279mkdir CppInterOp/build/
280280cd CppInterOp/build/
281281```
282282
283283On Windows execute
284284
285- ```
285+ ``` powershell
286286mkdir CppInterOp\build\
287287cd CppInterOp\build\
288288```
289289
290290Now if you want to build CppInterOp with Clang-REPL then execute the following commands on Linux and MacOS
291291
292- ```
292+ ``` bash
293293cmake -DBUILD_SHARED_LIBS=ON -DUSE_CLING=Off -DUSE_REPL=ON -DLLVM_DIR=$LLVM_DIR /build/lib/cmake/llvm -DClang_DIR=$LLVM_DIR /build/lib/cmake/clang -DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR ..
294294cmake --build . --target install --parallel $( nproc --all)
295295```
296296
297297and
298298
299- ```
299+ ``` powershell
300300cmake -DUSE_CLING=Off -DUSE_REPL=ON -DLLVM_DIR=$env:LLVM_DIR\build\lib\cmake\llvm -DClang_DIR=$env:LLVM_DIR\build\lib\cmake\clang -DCMAKE_INSTALL_PREFIX=$env:CPPINTEROP_DIR ..
301301cmake --build . --target install --parallel $env:ncpus
302302```
303303
304304on Windows. If alternatively you would like to install CppInterOp with Cling then execute the following commands on Linux and MacOS
305305
306- ```
306+ ``` bash
307307cmake -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 ..
308308cmake --build . --target install --parallel $( nproc --all)
309309```
310310
311311and
312312
313- ```
313+ ``` powershell
314314cmake -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 ..
315315cmake --build . --target install --parallel $env:ncpus
316316```
317317
318+ on Windows.
319+
318320#### Testing CppInterOp
319321
320322To test the built CppInterOp execute the following command in the CppInterOP build folder on Linux and MacOS
321323
322- ```
324+ ``` bash
323325cmake --build . --target check-cppinterop --parallel $( nproc --all)
324326```
325327
326328and
327329
328- ```
330+ ``` powershell
329331cmake --build . --target check-cppinterop --parallel $env:ncpus
330332```
331333
332334on Windows. Now go back to the top level directory in which your building CppInterOP. On Linux and MacOS you do this by executing
333335
334- ```
336+ ``` bash
335337cd ../..
336338```
337339
338340and
339341
340- ```
342+ ``` powershell
341343cd ..\..
342344```
343345
@@ -347,7 +349,7 @@ on Windows. Now you are in a position to install cppyy following the instruction
347349
348350Cd into the cppyy-backend directory, build it and copy library files into ` python/cppyy-backend ` directory:
349351
350- ```
352+ ``` bash
351353cd cppyy-backend
352354mkdir -p python/cppyy_backend/lib build
353355cd build
@@ -357,32 +359,32 @@ cmake --build .
357359
358360If on a linux system now execute the following command
359361
360- ```
362+ ``` bash
361363cp libcppyy-backend.so ../python/cppyy_backend/lib/
362364```
363365
364366and if on MacOS execute the following command
365367
366- ```
368+ ``` bash
367369cp libcppyy-backend.dylib ../python/cppyy_backend/lib/
368370```
369371
370372Note go back to the top level build directory
371373
372- ```
374+ ``` bash
373375cd ../..
374376```
375377
376378#### Install CPyCppyy
377379
378380Create virtual environment and activate it:
379381
380- ```
382+ ``` bash
381383python3 -m venv .venv
382384source .venv/bin/activate
383385```
384386
385- ```
387+ ``` bash
386388git clone --depth=1 https://github.com/compiler-research/CPyCppyy.git
387389mkdir CPyCppyy/build
388390cd CPyCppyy/build
@@ -392,26 +394,26 @@ cmake --build .
392394
393395Note down the path to the ` build ` directory as ` CPYCPPYY_DIR ` :
394396
395- ```
397+ ``` bash
396398export CPYCPPYY_DIR=$PWD
397399cd ../..
398400```
399401
400402Export the ` libcppyy ` path to python:
401403
402- ```
404+ ``` bash
403405export PYTHONPATH=$PYTHONPATH :$CPYCPPYY_DIR :$CB_PYTHON_DIR
404406```
405407
406408and on Windows:
407409
408- ```
410+ ``` powershell
409411$env:PYTHONPATH="$env:PYTHONPATH;$env:CPYCPPYY_DIR;$env:CB_PYTHON_DIR"
410412```
411413
412414#### Install cppyy
413415
414- ```
416+ ``` bash
415417git clone --depth=1 https://github.com/compiler-research/cppyy.git
416418cd cppyy
417419python -m pip install --upgrade . --no-deps --no-build-isolation
@@ -423,21 +425,21 @@ cd ..
423425Each time you want to run cppyy you need to:
424426Activate the virtual environment
425427
426- ```
428+ ``` bash
427429source .venv/bin/activate
428430```
429431
430432Now you can ` import cppyy ` in ` python `
431433
432- ```
434+ ``` bash
433435python -c " import cppyy"
434436```
435437
436438#### Run cppyy tests
437439
438440** Follow the steps in Run cppyy.** Change to the test directory, make the library files and run pytest:
439441
440- ```
442+ ``` bash
441443cd cppyy/test
442444make all
443445python -m pip install pytest
0 commit comments