Skip to content

Commit 4c367cf

Browse files
authored
Add code block languages readme.md
1 parent 490b3d3 commit 4c367cf

File tree

1 file changed

+41
-39
lines changed

1 file changed

+41
-39
lines changed

README.md

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -75,34 +75,34 @@ Build instructions for CppInterOp and its dependencies are as follows. CppInterO
7575

7676
First 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
7979
git clone --depth=1 https://github.com/compiler-research/CppInterOp.git
8080
```
8181

8282
and clone cppyy-backend repository where we will be installing the CppInterOp library
8383

84-
```
84+
```bash
8585
git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git
8686
```
8787

8888
#### Setup Clang-REPL
8989

9090
Clone the 19.x release of the LLVM project repository.
9191

92-
```
92+
```bash
9393
git clone --depth=1 --branch release/19.x https://github.com/llvm/llvm-project.git
9494
cd llvm-project
9595
```
9696

9797
For 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
100100
git apply -v ../CppInterOp/patches/llvm/clang{version}-*.patch
101101
```
102102

103103
and
104104

105-
```
105+
```powershell
106106
cp -r ..\CppInterOp\patches\llvm\clang17* .
107107
git apply -v clang{version}-*.patch
108108
```
@@ -115,7 +115,7 @@ Clang-REPL is an interpreter that CppInterOp works alongside. Build Clang (and
115115
Clang-REPL along with it). On Linux and MacOS you do this by executing the following
116116
command
117117

118-
```
118+
```bash
119119
mkdir build
120120
cd build
121121
cmake -DLLVM_ENABLE_PROJECTS="clang;lld" \
@@ -135,7 +135,7 @@ cmake --build . --target clang clang-repl lld --parallel $(nproc --all)
135135

136136
On Windows you would do this by executing the following
137137

138-
```
138+
```powershell
139139
$env:ncpus = $([Environment]::ProcessorCount)
140140
mkdir build
141141
cd build
@@ -153,15 +153,15 @@ cmake -DLLVM_ENABLE_PROJECTS=clang `
153153

154154
Note the 'llvm-project' directory location. On linux and MacOS you execute the following
155155

156-
```
156+
```bash
157157
cd ../
158158
export LLVM_DIR=$PWD
159159
cd ../
160160
```
161161

162162
On Windows you execute the following
163163

164-
```
164+
```powershell
165165
cd ..\
166166
$env:LLVM_DIR= $PWD.Path
167167
cd ..\
@@ -174,7 +174,7 @@ interpreter. Cling depends on its own customised version of `llvm-project`,
174174
hosted under the `root-project` (see the git path below).
175175
Use the following build instructions to build on Linux and MacOS
176176

177-
```
177+
```bash
178178
git clone https://github.com/root-project/cling.git
179179
cd ./cling/
180180
git checkout tags/v1.0
@@ -204,7 +204,7 @@ cmake --build . --target gtest_main --parallel $(nproc --all)
204204

205205
Use the following build instructions to build on Windows
206206

207-
```
207+
```powershell
208208
git clone https://github.com/root-project/cling.git
209209
cd .\cling\
210210
git checkout tags/v1.0
@@ -233,15 +233,15 @@ cmake --build . --target gtest_main --parallel $env:ncpus
233233

234234
Note the 'llvm-project' directory location. On linux and MacOS you execute the following
235235

236-
```
236+
```bash
237237
cd ../
238238
export LLVM_DIR=$PWD
239239
cd ../
240240
```
241241

242242
On Windows you execute the following
243243

244-
```
244+
```powershell
245245
cd ..\
246246
$env:LLVM_DIR= $PWD.Path
247247
cd ..\
@@ -251,21 +251,21 @@ cd ..\
251251

252252
Regardless 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
255255
export CB_PYTHON_DIR="$PWD/cppyy-backend/python"
256256
export CPPINTEROP_DIR="$CB_PYTHON_DIR/cppyy_backend"
257257
export 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

260260
If on MacOS you will also need the following environment variable defined
261261

262-
```
262+
```bash
263263
export SDKROOT=`xcrun --show-sdk-path`
264264
```
265265

266266
On 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

276276
Now CppInterOp can be installed. On Linux and MacOS execute
277277

278-
```
278+
```bash
279279
mkdir CppInterOp/build/
280280
cd CppInterOp/build/
281281
```
282282

283283
On Windows execute
284284

285-
```
285+
```powershell
286286
mkdir CppInterOp\build\
287287
cd CppInterOp\build\
288288
```
289289

290290
Now if you want to build CppInterOp with Clang-REPL then execute the following commands on Linux and MacOS
291291

292-
```
292+
```bash
293293
cmake -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 ..
294294
cmake --build . --target install --parallel $(nproc --all)
295295
```
296296

297297
and
298298

299-
```
299+
```powershell
300300
cmake -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 ..
301301
cmake --build . --target install --parallel $env:ncpus
302302
```
303303

304304
on Windows. If alternatively you would like to install CppInterOp with Cling then execute the following commands on Linux and MacOS
305305

306-
```
306+
```bash
307307
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 ..
308308
cmake --build . --target install --parallel $(nproc --all)
309309
```
310310

311311
and
312312

313-
```
313+
```powershell
314314
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 ..
315315
cmake --build . --target install --parallel $env:ncpus
316316
```
317317

318+
on Windows.
319+
318320
#### Testing CppInterOp
319321

320322
To test the built CppInterOp execute the following command in the CppInterOP build folder on Linux and MacOS
321323

322-
```
324+
```bash
323325
cmake --build . --target check-cppinterop --parallel $(nproc --all)
324326
```
325327

326328
and
327329

328-
```
330+
```powershell
329331
cmake --build . --target check-cppinterop --parallel $env:ncpus
330332
```
331333

332334
on 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
335337
cd ../..
336338
```
337339

338340
and
339341

340-
```
342+
```powershell
341343
cd ..\..
342344
```
343345

@@ -347,7 +349,7 @@ on Windows. Now you are in a position to install cppyy following the instruction
347349

348350
Cd into the cppyy-backend directory, build it and copy library files into `python/cppyy-backend` directory:
349351

350-
```
352+
```bash
351353
cd cppyy-backend
352354
mkdir -p python/cppyy_backend/lib build
353355
cd build
@@ -357,32 +359,32 @@ cmake --build .
357359

358360
If on a linux system now execute the following command
359361

360-
```
362+
```bash
361363
cp libcppyy-backend.so ../python/cppyy_backend/lib/
362364
```
363365

364366
and if on MacOS execute the following command
365367

366-
```
368+
```bash
367369
cp libcppyy-backend.dylib ../python/cppyy_backend/lib/
368370
```
369371

370372
Note go back to the top level build directory
371373

372-
```
374+
```bash
373375
cd ../..
374376
```
375377

376378
#### Install CPyCppyy
377379

378380
Create virtual environment and activate it:
379381

380-
```
382+
```bash
381383
python3 -m venv .venv
382384
source .venv/bin/activate
383385
```
384386

385-
```
387+
```bash
386388
git clone --depth=1 https://github.com/compiler-research/CPyCppyy.git
387389
mkdir CPyCppyy/build
388390
cd CPyCppyy/build
@@ -392,26 +394,26 @@ cmake --build .
392394

393395
Note down the path to the `build` directory as `CPYCPPYY_DIR`:
394396

395-
```
397+
```bash
396398
export CPYCPPYY_DIR=$PWD
397399
cd ../..
398400
```
399401

400402
Export the `libcppyy` path to python:
401403

402-
```
404+
```bash
403405
export PYTHONPATH=$PYTHONPATH:$CPYCPPYY_DIR:$CB_PYTHON_DIR
404406
```
405407

406408
and 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
415417
git clone --depth=1 https://github.com/compiler-research/cppyy.git
416418
cd cppyy
417419
python -m pip install --upgrade . --no-deps --no-build-isolation
@@ -423,21 +425,21 @@ cd ..
423425
Each time you want to run cppyy you need to:
424426
Activate the virtual environment
425427

426-
```
428+
```bash
427429
source .venv/bin/activate
428430
```
429431

430432
Now you can `import cppyy` in `python`
431433

432-
```
434+
```bash
433435
python -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
441443
cd cppyy/test
442444
make all
443445
python -m pip install pytest

0 commit comments

Comments
 (0)