Skip to content

Commit

Permalink
Resolve #18
Browse files Browse the repository at this point in the history
Add Makefile
  • Loading branch information
Colonial-Dev committed May 6, 2024
1 parent f7f812d commit d6a178d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: redownload regenerate features

BUILD=cargo build --all-features -vv

must_specify:
@echo "Must specify redownload [languages], regenerate [languages], or [regenerate] features"

redownload:
INKJET_REDOWNLOAD_LANGS=true $(BUILD)

regenerate:
INKJET_REBUILD_LANGS_MODULE=true $(BUILD)

features:
INKJET_REBUILD_FEATURES=true $(BUILD)
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Inkjet comes bundled with support for over seventy languages, and it's easy to a
| Assembly (generic) | `asm` |
| Astro | `astro` |
| Awk | `awk` |
| Bash | `bash` |
| Bash | `bash`, `sh`, `shell` |
| BibTeX | `bibtex`, `bib` |
| Bicep | `bicep` |
| Blueprint | `blueprint`, `blp` |
Expand Down Expand Up @@ -151,17 +151,17 @@ Other notes:
## Building
For normal use, Inkjet will compile automatically just like any other crate.

However, if you have forked the repository and want to update the bundled languages, you'll need to set some environment variables:
- `INKJET_REDOWNLOAD_LANGS` will wipe the `languages/` directory and redownload everything from scratch.
However, if you have forked the repository and want to update the bundled languages, you'll need to use GNU Make with the included `Makefile`:
- `make redownload` will wipe the `languages/` directory and redownload everything from scratch.
- Currently, this only works on *nix. You will need `git`, `sed` and `wget` installed. (Git clones the grammar repositories, while `sed` and `wget` are used in miniature setup scripts for some languages.)
- `INKJET_REBUILD_LANGS_MODULE` will wipe `src/languages.rs` and regenerate it from scratch.
- `INKJET_REBUILD_FEATURES` will generate a file called `features` in the crate root, containing all the individual language features (ready to be pasted into `Cargo.toml`.)

The value of these variables doesn't matter - they just have to be set.

Additionally:
- You will need to pass the `--all-features` flag to `cargo` for these to work - by default, the development parts of the build script are not compiled.
- I recommend running `cargo build -vv` when redownloading languages, so the script's progress is visible.
- `make regenerate` will wipe `src/languages.rs` and regenerate it from scratch.
- `make features` will generate a file called `features` in the crate root, containing all the individual language features (ready to be pasted into `Cargo.toml`.)

If, for whatever reason, you don't have GNU Make available: you can also perform these actions manually by setting the appropriate environment variables and Cargo flags:
- `INKJET_REDOWNLOAD_LANGS=true` for `make redownload`.
- `INKJET_REBUILD_LANGS_MODULE=true` for `make regenerate`.
- `INKJET_REBUILD_FEATURES=true` for `make features`.
Run `cargo build --all-features` with these set. (The development portions of the build script are feature gated by default.)

## Acknowledgements
- Inkjet would not be possible without `tree-sitter` and the ecosystem of grammars surrounding it.
Expand Down
2 changes: 1 addition & 1 deletion build/languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ hash = "374da90"
name = "bash"
repo = "https://github.com/tree-sitter/tree-sitter-bash"
hash = "1479a40"
aliases = ["sh"]
aliases = ["sh", "shell"]
helix_override = true

[[languages]]
Expand Down
2 changes: 2 additions & 0 deletions src/languages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4117,6 +4117,8 @@ impl Language {
"bash" => Some(Self::Bash),
#[cfg(feature = "language-bash")]
"sh" => Some(Self::Bash),
#[cfg(feature = "language-bash")]
"shell" => Some(Self::Bash),
#[cfg(feature = "language-bibtex")]
"bibtex" => Some(Self::Bibtex),
#[cfg(feature = "language-bibtex")]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! | Assembly (generic) | `asm` |
//! | Astro | `astro` |
//! | Awk | `awk` |
//! | Bash | `bash` |
//! | Bash | `bash`, `sh`, `shell` |
//! | BibTeX | `bibtex`, `bib` |
//! | Bicep | `bicep` |
//! | Blueprint | `blueprint`, `blp` |
Expand Down

0 comments on commit d6a178d

Please sign in to comment.