Skip to content

Commit

Permalink
script to patch the cpp circuit file
Browse files Browse the repository at this point in the history
  • Loading branch information
olomix committed Apr 14, 2024
1 parent aa6c421 commit 5db96a9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ Requirements: Xcode.
} // namespace
```
4. Optional. Replace all accurances of `assert(` with `check(` in .cpp file to switch from asserts to exceptions (more secure).
4. Optional. Remove the `#include <assert.h>` line and replace all accurances of `assert(` with `check(` in .cpp file to switch from asserts to exceptions (more secure).
Alternatively you can patch the `.cpp` circuit file with a `patch_cpp.sh` script. Example how to run it:
```shell
./patch_cpp.sh ../circuits/build/linkedMultiQuery10/linkedMultiQuery10_cpp/linkedMultiQuery10.cpp > ./src/linkedMultiQuery10.cpp
```
## License
Expand Down
21 changes: 21 additions & 0 deletions patch_cpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

if [ $# -ne 1 ]; then
echo "Usage: $0 <path_to_cpp_file>"
exit 1
fi

file_path="$1"

if [ ! -f "$file_path" ]; then
echo "Error: File does not exist."
exit 1
fi

sed "$(grep -n "^#include" ${file_path} | cut -d ':' -f 1 | tail -n 1) a\\
\\
namespace CIRCUIT_NAME {\\
; /^#include <assert\\.h>\$/ d; s/^assert(/check(/; $ a\\
}\\
" ${file_path}

0 comments on commit 5db96a9

Please sign in to comment.