Skip to content

Commit

Permalink
Add a readme for the ABI scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
kouchy committed Jan 21, 2021
1 parent b34a4c6 commit 7669e3d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ code_coverage_report/
doc/build/
doc/source/api/
doc/output/
scripts/abi/aff3ct_ast.txt
scripts/abi/db.json
scripts/abi/db_summary.txt

__pycache__/
2 changes: 1 addition & 1 deletion scripts/abi/01_aff3ct_dump_clang_ast.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
rootdir='..'
rootdir='../..'
cmd=$(clang++ -### -c -I${rootdir}/include -I${rootdir}/src -I${rootdir}/lib/MIPP/src -I${rootdir}/lib/cli/src -I${rootdir}/lib/rang/include -I${rootdir}/lib/date/include/date -std=gnu++11 ${rootdir}/include/aff3ct.hpp 2>&1 |tail -1|sed 's/^ //;s/emit-pch/ast-print/;s/"-o" "[^"]*"/"-o" "aff3ct_ast.txt"/');
eval "$cmd"
47 changes: 47 additions & 0 deletions scripts/abi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Application Binary Interface (ABI)

This directory contains some scripts to generate a JSON interface that describes
the AFF3CT C++ headers. This JSON interface can facilitate the creation of
AFF3CT wrappers for high level languages (Python, MATLAB, Julia, ...) that need
the AFF3CT headers information to be generated.

## Dump the Abstract Syntax Tree (AST)

The first operation consists in dumping the AFF3CT AST. To do this, we rely on
the [Clang](https://clang.llvm.org/) compiler.

Install Clang on Ubuntu 20.04 LTS:

```bash
sudo apt install clang
```

Then you can generate the AST:

```bash
./01_aff3ct_dump_clang_ast.sh
```

This last command should generate an `aff3ct_ast.txt` file in the current
directory.

## Convert the AST in JSON

In order to facilitate the manipulation of the AFF3CT AST, we propose to
generate a more structured file from the previously generated `aff3ct_ast.txt`
file. We choose to use the JSON format as it is highly democratized.

The conversion script is written in [Python](https://www.python.org/) version 3,
so on Ubuntu 20.04 LTS you should install it as follow :

```bash
sudo apt install python3
```

Finally you can convert the `aff3ct_ast.txt` raw AST file into the JSON format:

```bash
./02_aff3ct_read_clang_ast.py
```

This last command should generate a `db.json` file in the current directory.

0 comments on commit 7669e3d

Please sign in to comment.