-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build the project with Bazel. #3312
Conversation
Several CMake PRs were rejected for being too much. Now this, this is way too much. |
Hi @ObserverOfTime, thanks for your reply. |
16 files for a build system that very few people use. |
I'm not going to debate Bazel's popularity, because it's pretty hard to get numbers. I understand your feeling about having 16 files exclusively for a build system. However, since the project is quite ""simple"" (it doesn't have tons of external dependencies), I think it would be easy to maintain it. I was inspired by what was done for LLVM's monorepo. I made a directory to self-contain everything related to Bazel (
I've added new GitHub jobs, I'll make them non-blocking to ensure that non-Bazel-aware contributors won't be blocked. What do you think? |
In my opinion, if we were to add another (optional) build system it should be CMake (just one or two files). |
It seems that we cannot flag a job as non-blocking, we can only use However, an admin can flag these jobs as non-required. |
I can also add an optional CMake-based build system for tree-sitter if you want. |
Downstream projects can use whatever build system they want. It doesn't need to be added here. |
I agree. I've decided to make this PR in case other people want to use tree-sitter without them writing the build system themselves. As I wrote in my commit's description, the idea is to be able to easily integrate tree-sitter using |
This commit introduces a Bazel-based build system for the core library of `tree-sitter`. In order not to "pollute" the existing source directories, an overlay directory has been created at `bazel/`. People can build the `tree-sitter` C API by doing: ``` $ cd bazel/ $ bazel build @tree-sitter ``` The following two flags are available to enable or disable specific features: - `--@tree-sitter//build_config:wasm=<true|false>`: enable WASM. **not yet supported.** - `--@tree-sitter//build_config:hide_symbols=<true|false>`: if enabled, do not expose tree-sitter symbols. Bazel users can import `tree-sitter` into their existing Bazel workspace by adding the following to their `WORKSPACE` file: ```starlark load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # The git commit. _COMMIT = "" # SHA-256 digest of the archive. _SHA256SUM = "" http_archive( name = "tree-sitter-raw", sha256 = _SHA256SUM, urls = [ "https://github.com/tree-sitter/tree-sitter/archive/{commit}.tar.gz".format( commit = _COMMIT, ), ], strip_prefix = "tree-sitter-{commit}".format( commit = _COMMIT, ), ) load("@tree-sitter-raw//bazel:configure.bzl", "tree_sitter_configure") # Configures the repository `tree-sitter`. tree_sitter_configure(name = "tree-sitter") # Fetches `tree-sitter` Bazel dependencies. load("@tree-sitter//:repositories.bzl", "tree_sitter_repositories") tree_sitter_repositories() # Loads `tree-sitter` Bazel dependencies. load("@tree-sitter//:deps.bzl", "tree_sitter_dependencies") tree_sitter_dependencies() ``` Then, users can link their libraries/binaries against tree-sitter: ```starlark cc_library( name = "my-parser", srcs = ["my-parser.cc"], deps = ["@tree-sitter"], ) ```
Hi, this is great work but I don’t want to maintain this in this repository. |
I understand. Thanks anyway for your reply. |
See [`tree-sitter-bazel`] and [`tree-sitter-bazel` v0.22.5]. I attempted to integrate Bazel into the original repo (see tree-sitter/tree-sitter#3312), but tree-sitter maintainers are not willing to do so, so I decided to create my own repo for this purpose. [`tree-sitter-bazel`]: https://github.com/zadlg/tree-sitter-bazel [`tree-sitter-bazel` v0.22.5]: https://github.com/zadlg/tree-sitter-bazel/releases/tag/v0.22.5
See [`tree-sitter-bazel`] and [`tree-sitter-bazel` v0.22.5]. I attempted to integrate Bazel into the original repo (see tree-sitter/tree-sitter#3312), but tree-sitter maintainers are not willing to do so, so I decided to create my own repo for this purpose. [`tree-sitter-bazel`]: https://github.com/zadlg/tree-sitter-bazel [`tree-sitter-bazel` v0.22.5]: https://github.com/zadlg/tree-sitter-bazel/releases/tag/v0.22.5
See [`tree-sitter-bazel`] and [`tree-sitter-bazel` v0.22.5]. I attempted to integrate Bazel into the original repo (see tree-sitter/tree-sitter#3312), but tree-sitter maintainers are not willing to do so, so I decided to create my own repo for this purpose. [`tree-sitter-bazel`]: https://github.com/zadlg/tree-sitter-bazel [`tree-sitter-bazel` v0.22.5]: https://github.com/zadlg/tree-sitter-bazel/releases/tag/v0.22.5
See [`tree-sitter-bazel`] and [`tree-sitter-bazel` v0.22.5]. I attempted to integrate Bazel into the original repo (see tree-sitter/tree-sitter#3312), but tree-sitter maintainers are not willing to do so, so I decided to create my own repo for this purpose. [`tree-sitter-bazel`]: https://github.com/zadlg/tree-sitter-bazel [`tree-sitter-bazel` v0.22.5]: https://github.com/zadlg/tree-sitter-bazel/releases/tag/v0.22.5
See [`tree-sitter-bazel`] and [`tree-sitter-bazel` v0.22.5]. I attempted to integrate Bazel into the original repo (see tree-sitter/tree-sitter#3312), but tree-sitter maintainers are not willing to do so, so I decided to create my own repo for this purpose. [`tree-sitter-bazel`]: https://github.com/zadlg/tree-sitter-bazel [`tree-sitter-bazel` v0.22.5]: https://github.com/zadlg/tree-sitter-bazel/releases/tag/v0.22.5
Add tree-sitter-bazel 0.22.5. See [`tree-sitter-bazel`] and [`tree-sitter-bazel` v0.22.5]. I attempted to integrate Bazel into the original repo (see tree-sitter/tree-sitter#3312), but tree-sitter maintainers are not willing to do so, so I decided to create my own repo for this purpose. [`tree-sitter-bazel`]: https://github.com/zadlg/tree-sitter-bazel [`tree-sitter-bazel` v0.22.5]: https://github.com/zadlg/tree-sitter-bazel/releases/tag/v0.22.5
Quick note: I've put the overlay in a repository: https://github.com/zadlg/tree-sitter-bazel/ |
Awesome, thank you @zadlg ! |
Add tree-sitter-bazel 0.22.5. See [`tree-sitter-bazel`] and [`tree-sitter-bazel` v0.22.5]. I attempted to integrate Bazel into the original repo (see tree-sitter/tree-sitter#3312), but tree-sitter maintainers are not willing to do so, so I decided to create my own repo for this purpose. [`tree-sitter-bazel`]: https://github.com/zadlg/tree-sitter-bazel [`tree-sitter-bazel` v0.22.5]: https://github.com/zadlg/tree-sitter-bazel/releases/tag/v0.22.5
Build the project with Bazel.
This commit introduces a Bazel-based build system for the core library
of
tree-sitter
.In order not to "pollute" the existing source directories, an overlay directory
has been created at
bazel/
.People can build the
tree-sitter
C API by doing:The following two flags are available to enable or disable specific features:
--@tree-sitter//build_config:wasm=<true|false>
: enable WASM. not yet supported.--@tree-sitter//build_config:hide_symbols=<true|false>
: if enabled, do not expose tree-sitter symbols.Bazel users can import
tree-sitter
into their existing Bazel workspace byadding the following to their
WORKSPACE
file:Then, users can link their libraries/binaries against tree-sitter: