🏡 index : ~doyle/rgit.git

author Jordan Doyle <jordan@doyle.la> 2024-11-13 2:44:43.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2024-11-13 2:44:43.0 +00:00:00
commit
c474c3aeb4d2400d4cc53c363dfd8b8029d077d6 [patch]
tree
4ba6bed86a42c6323a2c8941e30fc8f65b63daf1
parent
6595e8c4a50c9b8bab72aed3ad355538a5e92a63
download
c474c3aeb4d2400d4cc53c363dfd8b8029d077d6.tar.gz

Fix build when passing TREE_SITTER_GRAMMAR_LIB_DIR



Diff

 tree-sitter-grammar-repository/build.rs | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/tree-sitter-grammar-repository/build.rs b/tree-sitter-grammar-repository/build.rs
index af06146..5f6591b 100644
--- a/tree-sitter-grammar-repository/build.rs
+++ a/tree-sitter-grammar-repository/build.rs
@@ -44,11 +44,19 @@
    };

    let (config, query_path) = if dylib {
        let config: HelixLanguages = basic_toml::from_str(
            &fs::read_to_string(root.join("languages.toml"))
                .context("failed to read languages.toml")?,
        )
        .context("failed to parse helix languages.toml")?;
        let config = fs::read_to_string(root.join("languages.toml"))
            .context("failed to read helix languages.toml")?;

        // find the start of the language arrays & skip parsing everything before them (primarily because
        // `basic_toml` can't handle some of the new syntax used in this file, and `toml` pulls in a lot
        // of dependencies)
        let language_defs_start = memchr::memmem::find(config.as_bytes(), b"[[language]]")
            .context("languages.toml is missing languages")?;

        let config = &config[language_defs_start..];

        let config: HelixLanguages =
            basic_toml::from_str(config).context("failed to parse helix languages.toml")?;

        println!("cargo::rustc-link-search=native={}", root.display());