Skip to content

Commit

Permalink
Update API check (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe committed May 8, 2023
1 parent 81aa405 commit 4a2a450
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![GitHub Action](https://img.shields.io/github/actions/workflow/status/raviqqe/melior/test.yaml?branch=main&style=flat-square)](https://github.com/raviqqe/melior/actions?query=workflow%3Atest)
[![Crate](https://img.shields.io/crates/v/melior.svg?style=flat-square)](https://crates.io/crates/melior)
![API coverage](https://img.shields.io/badge/api%20coverage-36%25-blue.svg?style=flat-square)
[![License](https://img.shields.io/github/license/raviqqe/melior.svg?style=flat-square)](LICENSE)

The rustic MLIR bindings for Rust
Expand Down
18 changes: 2 additions & 16 deletions tools/api_completeness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@

set -e

cd $(dirname $0)/..
cd melior
. $(dirname $0)/utility.sh

count() {
grep -o '\(m\|M\)lir[A-Z][a-zA-Z0-9]*' | sort -u | wc -l
}

implemented_count() {
cargo install cargo-expand
cargo expand | count
}

upstream_count() {
cat $(find $(brew --prefix llvm)/include/mlir-c -type f) | count
}

echo $(implemented_count) / $(upstream_count) | bc -l
echo $(implemented_api | count) / $(all_api | count) | bc -l
12 changes: 12 additions & 0 deletions tools/api_difference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

set -e

. $(dirname $0)/utility.sh

mkdir -p /tmp/melior

implemented_api >/tmp/melior/implemented.txt
all_api >/tmp/all.txt

diff -u /tmp/implemented.txt /tmp/all.txt | grep '^+[mM]' | sed s/^.//
22 changes: 22 additions & 0 deletions tools/utility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
directory=$(dirname $0)

count() {
wc -l
}

filter_api() {
grep -o '[mM]lir[A-Z][a-zA-Z0-9]*' | grep -iv -e python -e isnull | sort -u
}

implemented_api() {
(
cd $directory/../melior

cargo install cargo-expand
cargo expand | filter_api
)
}

all_api() {
cat $(find $(brew --prefix llvm)/include/mlir-c -type f) | filter_api
}

0 comments on commit 4a2a450

Please sign in to comment.