Commit graph

33 commits

Author SHA1 Message Date
Amaan Qureshi
95ab17e444 build: define _DARWIN_C_SOURCE 2025-09-22 19:50:43 +03:00
Amaan Qureshi
22553b3372 feat: support compiling to wasm32-unknown-unknown 2025-09-17 04:57:49 -04:00
Will Lillis
be8b3e282a fix(rust): remove unused Command import 2025-06-26 00:54:44 -04:00
James McCoy
889015f03b
build(rust): use $CARGO_PKG_RUST_VERSION when generating bindings (#4512)
Since cargo 1.63, $CARGO_PKG_RUST_VERSION is set in the build
environment to the value of the rust-version Cargo.toml field.

This removes the need to manually invoke cargo from build.rs during a
build of the tree-sitter crate with the bindgen feature enabled.

Removing the cargo invocation also ensures the build doesn't write to
the current directory when the target directory has been redirected
elsewhere. "cargo metadata" will attempt to update Cargo.lock, which
will fail if the source tree is read-only.
2025-06-13 11:11:22 -07:00
WillLillis
11071ed682 fix(rust): adapt to new nightly lint 2025-03-06 09:32:21 +01:00
Amaan Qureshi
7d3dbc062d build: bump deps 2024-12-16 01:22:58 -05:00
Amaan Qureshi
8943983df6 feat!: properly handle UTF-16 endianness encoding 2024-10-05 21:12:48 -04:00
DragonBillow
d13d7235d2 feat(lib): support no_std 2024-07-28 11:34:26 +03:00
Amaan Qureshi
7f4a57817d build(deps): bump wasmtime to v21 2024-05-29 18:57:26 -04:00
Paolo Tranquilli
d35e40185a
fix(rust): fetch CARGO_MANIFEST_DIR at runtime in build script
The `CARGO_MANIFEST_DIR` environment variable should be accessed by
`build.rs` at run time rather than compile time. This was for example
causing issues when importing `tree-sitter` via
[`rules_rust`](https://github.com/bazelbuild/rules_rust) in bazel,
where compilation and running happen in separate environments.
2024-05-13 10:09:58 -04:00
Amaan Qureshi
b35efa8f33 style: format imports 2024-04-11 22:35:43 -04:00
Max Brunsfeld
b19d85aca7 Remove logic for building with clang static analyzer in core rust binding 2024-03-17 09:59:51 -07:00
ObserverOfTime
799833f9cf build: use c11 everywhere
And improve the makefiles
2024-02-27 15:54:38 -05:00
Max Brunsfeld
b40a42ac0f Remove vendored wasmtime headers
When building rust binding, use wasmtime headers provided via cargo
by the wasmtime-c-api crate.

Co-authored-by: Marshall <marshall@zed.dev>
2024-02-26 10:48:58 -08:00
dundargoc
c8bd6705cf
chore: clippy 2024-02-06 23:34:14 -05:00
Douglas Creager
44aa80d678
feat: include build script links in Rust bindings
This patch updates the Rust binding's build script to output [build
metadata][links].  This makes it easier for downstream crates to
determine the include path, in case they need to compile their own C
code that requires the tree-sitter headers.

[links]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#the-links-manifest-key
2024-02-05 20:05:05 -05:00
Max Brunsfeld
f4788b49c0 Merge branch 'master' into wasm-stdlib 2024-02-05 11:55:58 -08:00
Amaan Qureshi
28bb2a8c1c
chore(lib): apply clippy fixes 2024-02-04 04:18:59 -05:00
Max Brunsfeld
e054de4191 Return an error from build-wasm if scanner uses unavailable functions 2024-02-02 12:04:49 -08:00
Max Brunsfeld
81a1a1733d Fix C compile warnings in wasm.c 2023-10-27 12:16:05 +01:00
Max Brunsfeld
f4e2f68f14 Merge branch 'master' into wasm-language 2023-10-27 12:11:43 +01:00
Andrew Hlynskyi
9cc1daafca chore(ffi): remove enum name prefixes from all C enum values 2023-09-03 07:38:27 +03:00
Andrew Hlynskyi
4278e03b11 feat: generate Rust bindings during build process
It can be used as:
  > cargo build -p tree-sitter -F bindgen
2023-08-21 02:56:14 +03:00
James McCoy
545ef842de
Remove -Werror from default CFLAGS
Production builds shouldn't include -Werror by default since that could
cause spurious build failures when there are toolchain updates.

CI uses -Werror to prevent warnings, so that should be sufficient.
2023-08-18 14:23:19 -04:00
Andrew Hlynskyi
f9e8802234 Use the same flags in lib's build.rs as in Makefile 2023-08-17 16:27:52 +03:00
Max Brunsfeld
042e6f9d57 Restucture wasm module, return a normal TSLanguage from load_language 2022-11-15 17:14:33 -08:00
Max Brunsfeld
3f1a7f9cd4 Start work on ability to load wasm languages from native lib, via wasmtime 2022-11-15 17:14:33 -08:00
Max Brunsfeld
622359b400 Simplify allocation-recording in test suite using new ts_set_allocator API 2021-12-30 16:09:07 -08:00
Max Brunsfeld
b661050a61 Simplify setup for enabling/disabling allocation recording in the C lib 2020-12-02 15:35:13 -08:00
Max Brunsfeld
87fd2f5ca3 rust: Detect debug builds using PROFILE env var in build script
Fixes #757
2020-10-12 11:53:16 -07:00
Max Brunsfeld
967da88371 Avoid unnecessary recompiles between debug & test builds
This makes development much quicker when switching back and forth
between compiling with RLS while editing and running tests with
`cargo test`.
2019-11-14 13:34:25 -08:00
Matthew Krupcale
ee9a3c0ebb lib: remove utf8proc dependency (#436)
* Remove dependency on utf8proc

This removes the only external dependency on utf8proc for UTF-8 decoding. It does so by implementing its own UTF-8 decoder. This decoder is both faster and has a simpler API.

 * .gitmodules: remove utf8proc submodule
 * docs/section-2-using-parsers.md: remove requirement for utf8proc submodule
 * docs/section-6-contributing.md: likewise
 * lib/Cargo.toml: remove utf8proc subdirectory package include
 * lib/README.md: remove utf8proc subdirectory description
 * lib/binding_rust/build.rs: remove utf8proc compiler include directory
 * lib/src/lexer.c: remove utf8proc dependencies and types
 * lib/src/lib.c: remove utf8proc dependency
 * lib/src/unicode.h: define types for Unicode decoders
 * lib/src/utf16.{c,h}: implement more readable UTF-16 decoder
 * lib/src/utf8.{c,h}: implement fast UTF-8 decoder
 * lib/utf8proc: remove utf8proc submodule directory
 * script/build-lib: remove utf8proc compiler include directory
 * script/build-wasm: likewise

* Optimize ts_lexer__get_lookahead.

Try to favor non-failure code path and assign lookahead values directly to lexer

 * lib/src/lexer.c: optimize for non-failure code path

* Fix some compiler errors

 * lib/src/lexer.c: cast from signed to unsigned for decode_next result
 * lib/src/utf16.c: fix non-constant initializers for older compilers

* Remove some missed remnants of utf8proc

 * docs/section-2-using-parsers.md: only two include paths necessary now
 * lib/src/lib.c: no need to define UTF8PROC_STATIC

* Use ICU's utf8 and utf16 decoding routines

* Remove unnecessary casts when calling icu macros

* Check buffer length before attempting to decode a unicode character

* Use new unicode function when parsing Queries

Co-Authored-By: Matthew Krupcale <mkrupcale@matthewkrupcale.com>

* Mark libicu files as vendored for GitHub's stats
2019-10-14 11:18:39 -07:00
Max Brunsfeld
3fc459a84b Reorganize language bindings
* Move rust binding: lib/binding -> lib/binding_rust
* Move wasm bindinig: lib/web -> lib/binding_web
* Add wasm readme
2019-05-07 10:41:49 -07:00
Renamed from lib/build.rs (Browse further)