Skip to content
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

Support dynamically linking grammars #177

Merged
merged 25 commits into from
Sep 26, 2021
Merged

Conversation

afnanenayet
Copy link
Owner

@afnanenayet afnanenayet commented Aug 12, 2021

Add a build flag that allows toggling support for dynamic and static
linking of grammars and add tests for dynamic grammar loading.

Fixes #167.

Add a build flag that allows toggling support for dynamic and static
linking of grammars and add tests for dynamic grammar loading.
Update the github actions so we specify each feature for debug builds,
tests, and release builds. We can't enable dynamic libraries when
testing release builds because the libraries won't be found on the
system, but we still want to make sure the code for the libraries
builds.
`libloading` doesn't supply the extension for you so we need to add the
extension based on the platform.
Add a compilation flag for static grammars so the binary doesn't attempt
to compile any of the grammars unless the compilation flag is selected.
* Add a proper config for grammars
    * Add configs to set the dynamic library paths for different
      languages
    * Refactor extension overrides into this config (breaking change for
      the configs)
    * Update sample config to reflect this change
* Disable dynamic grammar test by default
* Derive the `default` trait for configs instead of using a manual
  implementation
Don't include the codegen file if the static grammar flag hasn't been
set, because the file won't exist.
Ignore a clippy lint about unused arguments since it's valid with
certain build flags.
@bbigras
Copy link

bbigras commented Aug 28, 2021

I had to add to src/parse.rs:

use tree_sitter::Language;
use phf::phf_map;

and I still have:

error[E0425]: cannot find value `LANGUAGES` in this scope
   --> src/parse.rs:301:39
    |
301 |     let mut keys: Vec<&'static str> = LANGUAGES.keys().copied().collect();
    |                                       ^^^^^^^^^ not found in this scope

Move everything behind the proper feature gates so each combination of
build flags compiles correctly and address clippy warnings.
@afnanenayet
Copy link
Owner Author

Hey sorry about that, I realized I tested without enabling --no-default-features so i didn't catch a lot of the build issues with various build flag combinations. I made some updates which should hopefully fix them.

@afnanenayet afnanenayet merged commit 8f54add into main Sep 26, 2021
@afnanenayet afnanenayet deleted the afnan/dynamic-loading branch September 26, 2021 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide an option to skip building grammars or provide paths to prebuilt ones
2 participants