Skip to content

Commit e272cf7

Browse files
aborgna-qdoug-q
andauthored
chore: Add script to recompile the ECC sets (#514)
- Moves the loose ECC files into `test_files/eccs` - Adds a `just recompile-eccs` command / script to regenerate the `.rwr` files. Note that the compilation is not deterministic, so we should avoid running it unless needed to avoid bloating the git history. --------- Co-authored-by: Douglas Wilson <douglas.wilson@quantinuum.com>
1 parent 54564fc commit e272cf7

File tree

13 files changed

+32426
-7
lines changed

13 files changed

+32426
-7
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
# Compiled ECC files
3+
*.rwr binary

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ missing_docs = "warn"
2525

2626
[workspace.dependencies]
2727

28+
# Make sure to run `just recompile-eccs` if the hugr serialisation format changes.
2829
hugr = "0.9.1"
2930
hugr-cli = "0.2.1"
3031
hugr-core = "0.6.1"

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ coverage language="[rust|python]": (_run_lang language \
4444
shell:
4545
poetry shell
4646

47+
# Runs `compile-rewriter` on the ECCs in `test_files/eccs`
48+
recompile-eccs:
49+
scripts/compile-test-eccs.sh
50+
4751

4852
# Runs a rust and a python command, depending on the `language` variable.
4953
#

scripts/compile-test-eccs.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
# This script calls `compile-rewriter` to recompile all ECC sets in the
4+
# `test_files/eccs/` directory.
5+
#
6+
# Note that the output is not deterministic, so the resulting `.rwr` will always
7+
# be different even if the input and the compiler are the same.
8+
set -euo pipefail
9+
10+
# Get the directory of this script
11+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
12+
ECCS_DIR="$DIR/../test_files/eccs"
13+
14+
# Command to call compile-rewriter with cargo
15+
COMPILE_REWRITER="cargo run --release -p compile-rewriter --"
16+
17+
# Compile all json files into `.rwr`
18+
for ecc in $ECCS_DIR/*.json; do
19+
echo "-------- Compiling $ecc"
20+
$COMPILE_REWRITER -i "$ecc" -o "${ecc%.json}.rwr"
21+
done
22+
23+
# Additional hard-coded step:
24+
# The python package contains a copy of the nam_6_3 ecc,
25+
# which must be manually copied.
26+
PY_ECCS_DIR="$DIR/../tket2-py/tket2/data"
27+
nam_6_3="$ECCS_DIR/nam_6_3.rwr"
28+
PY_NAM_6_3="$PY_ECCS_DIR/nam_6_3.rwr"
29+
30+
echo "Copying $nam_6_3 to $PY_NAM_6_3"
31+
cp -f "$nam_6_3" "$PY_NAM_6_3"
32+
33+
echo "Done!"
File renamed without changes.

test_files/eccs/nam_6_3.json

Lines changed: 32378 additions & 0 deletions
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)