Skip to content

Commit

Permalink
feat: improve language bindings
Browse files Browse the repository at this point in the history
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
  • Loading branch information
amaanq and ObserverOfTime committed Feb 26, 2024
1 parent d0d349c commit 9e5bf65
Show file tree
Hide file tree
Showing 32 changed files with 1,129 additions and 192 deletions.
175 changes: 98 additions & 77 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ ctor = "0.2.6"
ctrlc = { version = "3.4.2", features = ["termination"] }
difference = "2.0.0"
dirs = "5.0.1"
filetime = "0.2.23"
fs4 = "0.7.0"
git2 = "0.18.2"
glob = "0.3.1"
heck = "0.4.1"
html-escape = "0.2.13"
indexmap = "2.2.2"
indoc = "2.0.4"
Expand Down
2 changes: 2 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ clap.workspace = true
ctrlc.workspace = true
difference.workspace = true
dirs.workspace = true
filetime.workspace = true
glob.workspace = true
heck.workspace = true
html-escape.workspace = true
indexmap.workspace = true
indoc.workspace = true
Expand Down
21 changes: 16 additions & 5 deletions cli/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::{env, fs};
use std::{
env,
ffi::OsStr,
fs,
path::{Path, PathBuf},
time::SystemTime,
};

fn main() {
if let Some(git_sha) = read_git_sha() {
Expand All @@ -10,6 +14,12 @@ fn main() {
if web_playground_files_present() {
println!("cargo:rustc-cfg=TREE_SITTER_EMBED_WASM_BINDING");
}

let build_time = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs_f64();
println!("cargo:rustc-env=BUILD_TIME={build_time}");
}

fn web_playground_files_present() -> bool {
Expand All @@ -30,7 +40,8 @@ fn read_git_sha() -> Option<String> {
git_path = repo_path.join(".git");
if git_path.exists() {
break;
} else if !repo_path.pop() {
}
if !repo_path.pop() {
return None;
}
}
Expand Down Expand Up @@ -93,7 +104,7 @@ fn read_git_sha() -> Option<String> {
return fs::read_to_string(&ref_filename).ok();
}
// If we're on a detached commit, then the `HEAD` file itself contains the sha.
else if head_content.len() == 40 {
if head_content.len() == 40 {
return Some(head_content);
}
}
Expand Down

0 comments on commit 9e5bf65

Please sign in to comment.