Skip to content

Commit

Permalink
More documentation and automation for adding a language
Browse files Browse the repository at this point in the history
  • Loading branch information
langston-barrett committed Oct 29, 2022
1 parent 8bde0cb commit d3cd3b1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,18 @@ To add a new language:
- Add the language to `.github/workflows/release.yml` by copying and modifying
existing lines for other languages.

See [PR #9][#9] for a complete example.

The script [`./scripts/add-language.sh`](`./scripts/add-language.sh`) automates
a few of these steps - but it is not necessarily a turn-key solution. Usage
example:

```bash
bash scripts/add-language.sh python Python
```

[#3]: https://github.com/langston-barrett/treeedb/issues/3
[#9]: https://github.com/langston-barrett/treeedb/pull/9
[cargo]: https://doc.rust-lang.org/cargo/
[cclyzerpp-fact-generator]: https://galoisinc.github.io/cclyzerpp/architecture.html#the-fact-generator
[cclyzerpp-schema]: https://github.com/GaloisInc/cclyzerpp/tree/746e30ac4579da68e06d49faac27f1f88d8edc72/datalog/schema
Expand Down
22 changes: 22 additions & 0 deletions scripts/add-language.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -eu

old=rust
new="${1}"
Old=Rust
New="${2}"

sed_recurse() { ag -g '.*' -0 | xargs -0 sed -E -i "$@"; }

cp -r treeedb-${old} treeedb-${new}
pushd treeedb-${new}
sed_recurse "s/${Old}/${New}/g"
sed_recurse "s/${old}/${new}/g"
popd

cp -r treeedbgen-souffle-${old} treeedbgen-souffle-${new}
pushd treeedbgen-souffle-${new}
sed_recurse "s/${Old}/${New}/g"
sed_recurse "s/${old}/${new}/g"
popd

0 comments on commit d3cd3b1

Please sign in to comment.