Commit graph

36 commits

Author SHA1 Message Date
Julian
3abb104738
build(wasm): support big endian machines (#3492) 2024-07-29 16:19:56 +03:00
Boris Verkhovskiy
cd3e561224
build(wasm): don't minify JS (#3380) 2024-07-29 10:00:02 +03:00
ObserverOfTime
f50123a3ec refactor(scripts): clean up bash scripts 2024-07-28 10:12:55 +03:00
ObserverOfTime
799833f9cf build: use c11 everywhere
And improve the makefiles
2024-02-27 15:54:38 -05:00
Max Brunsfeld
d2900510f6 Remove duplicate specification of stdlib symbols for web tree-sitter 2024-02-02 12:04:49 -08:00
Steven Kalt
d35efd4608
feat(cli): support building WASM via podman
Previously, `tree-sitter build-wasm` had the ability to build WASM
by using docker to pull in an image with a complete emscripten toolchain.
This commit adds the ability to use podman to do the same thing.

Using podman requires two notable changes:
1. Using the fully-qualified image name. Docker defaults to prepending
    `docker.io` to the image name, but podman does not.
2. Podman will mount the `/src/` volume as belonging to root unless
  `--userns=keep-id` is passed. I think podman's different
  volume-ownership is related to podman's daemonless execution and
  `--uidmap` functionality, but I'm not 100% sure.

To test, I ran
```sh
script/fetch-fixtures
script/generate-fixtures
script/generate-fixtures-wasm # <- the important one!
```

which worked as well as the docker version.
2024-01-29 00:50:32 -05:00
Max Brunsfeld
f4e2f68f14 Merge branch 'master' into wasm-language 2023-10-27 12:11:43 +01:00
Andrew Hlynskyi
a9dfcb9e47 script/build-wasm: update emcc options to use actual non-deprecated names 2023-05-16 04:46:46 +03:00
Andrew Hlynskyi
be179a3c80 script/build-wasm: add a --verbose option 2023-05-15 17:03:24 +03:00
Boris Verkhovskiy
61b85b2664 Make error message more specific 2023-01-08 08:10:14 -07:00
Max Brunsfeld
d47713ee4a Integrate WASM compilation into the CLI's Loader 2022-11-15 17:14:33 -08:00
Jonathan Arnett
a8988339c3 Add 'stringToUTF16' and 'AsciiToString' to exported method 2022-11-15 16:39:17 -08:00
Max Brunsfeld
15190a497d Build core wasm library with C++ exceptions disabled 2022-09-02 14:55:50 -07:00
Max Brunsfeld
4d64c2b939 Put emscripten-version file in cli directory
This lets the CLI crate build without relying on sibling directories.
2021-09-03 13:57:45 -07:00
Vladimir Panteleev
b14ea51e3d
Refactor emscripten/emsdk version to a single file 2021-06-29 21:39:12 +00:00
Vladimir Panteleev
725f3f7f2b
Pin emscripten/emsdk Docker version
Fixes issues caused by incompatible changes in Emscripten since the
time that tree-sitter was built.
2021-06-26 18:07:12 +00:00
Max Brunsfeld
18980b7b99 wasm: Avoid registering uncaught exception/rejection handlers 2020-12-01 11:04:06 -08:00
Max Brunsfeld
751ffd2ee1 Use new emscripten when building with docker 2020-12-01 11:04:06 -08:00
Max Brunsfeld
b118e7d750 Make binding.js syntactically valid
Put the end of the surrounding closure into a separate file, suffix.js.
2020-11-30 15:28:26 -08:00
Max Brunsfeld
7ccec8c0e2 Tweak wasm binding to work with new upstream LLVM backend 2019-10-21 16:10:29 -07: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
9323ba52c8 Minify function names in wasm build 2019-09-16 11:38:29 -07:00
Max Brunsfeld
7ad087ce27 Tweak compile flags in build-wasm script 2019-09-04 08:54:13 -07:00
Matthew Krupcale
71d96e813f Use Z option for docker-run volume mount
This is necessary on systems with SELinux to prevent file permission/access errors when building WASM output

 * cli/src/wasm.rs: Use Z volume mount option for docker-run
 * script/build-wasm: Likewise.
2019-06-29 15:49:25 -04:00
Paul Young
15bf75a2f9
Fix ALLOW_MEMORY_GROWTH setting
Fixes ERROR:root:ALLOW_MEMORY_GROWTH: No such file or directory ("ALLOW_MEMORY_GROWTH" was expected to be an input file, based on the commandline arguments provided) according to https://emscripten.org/docs/optimizing/Optimizing-Code.html#memory-growth
2019-06-04 17:17:25 -07:00
Max Brunsfeld
70038bd251 Build wasm lib with -O3
There doesn't seem to be much code size difference, but there's
a big performance difference.
2019-05-17 12:50:00 -07:00
Max Brunsfeld
ad43b211f4 Allow building the wasm libs with native emscripten instead of docker
And build them on the mac CI as well as the linux CI
2019-05-14 14:02:22 -07:00
Max Brunsfeld
9a82bd9d83 Set up code to publish web bindings to npm 2019-05-07 13:11:04 -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
Max Brunsfeld
a6a50a6320 Avoid some bloat in wasm build 2019-05-01 12:44:58 -07:00
Max Brunsfeld
3425b6e1c2 Add wasm binding for TreeCursor 2019-04-29 13:20:09 -07:00
Chris Wendt
cff9c16ccc Increase memory limit for language wasm files (continued) 2019-04-28 14:08:40 -07:00
Max Brunsfeld
f3ecafe13b Fix inclusion of libc++ in wasm build 2019-04-27 18:06:34 -07:00
Max Brunsfeld
b4c4dc48ff Minify JS build with terser 2019-04-26 19:52:01 -07:00
Max Brunsfeld
66e006105c Build and test wasm on CI 2019-04-26 14:38:13 -07:00
Max Brunsfeld
1fc0525940 Start work on a WASM binding 2019-04-25 17:27:39 -07:00