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

tree-sitter test does not respect CFLAGS / CXXFLAGS #2849

Open
tgross35 opened this issue Jan 7, 2024 · 4 comments
Open

tree-sitter test does not respect CFLAGS / CXXFLAGS #2849

tgross35 opened this issue Jan 7, 2024 · 4 comments
Labels
cli enhancement Feature request
Milestone

Comments

@tgross35
Copy link

tgross35 commented Jan 7, 2024

I would like to be able to test my scanner configuration with more warnings, but am unable to do so:

$ CC=banana CFLAGS=fake tree-sitter test
(output works)

Tree-sitter should respect CC/CXX on all files, and respect CFLAGS on files that aren't autogenerated.

This isn't meant as a way to provide flags for downstream compilation, just an easier way to get the benefit of extra Wall output or similar.

As a workaround, I am using this crude command to check everything in src/ with special flags:

$ find src/ -name '*.c' ! -name "parser.c" |
    xargs -IFNAME sh -c \
    'echo "\nCHECKING FILE FNAME" &&
    clang FNAME -c -Wall -Werror --pedantic -o/dev/null'
@amaanq
Copy link
Member

amaanq commented Jan 29, 2024

I think this makes sense, though one thing to note is that the CLI relies on the mtime (modified time) of the parser OR scanner to trigger recompilation. Would you think it be better to recompile always when CC/CFLAGS/CXX/CXXFLAGS are provided? this might be annoying for someone who has them always set as an env var for whatever reason though.

@clason
Copy link
Contributor

clason commented Jan 29, 2024

Or at least provide a flag to force rebuild? That might be the easiest (and useful in other situations, e.g., where mtime check fails).

@tgross35
Copy link
Author

Just for prior art - I believe that Make doesn’t detect env changed for rebuilds but Cargo always rebuilds if specific variables are set. A flag to force rebuild sounds reasonable, or maybe a flag to clean generated files.

Storing the hash of relevant env variables to a file could also work, but that might not be worth it if there isn’t already a cache/object location.

@ObserverOfTime ObserverOfTime linked a pull request Apr 11, 2024 that will close this issue
@ObserverOfTime ObserverOfTime added enhancement Feature request cli labels Apr 12, 2024
@ObserverOfTime
Copy link
Member

#3188 adds support for environment variables but no rebuild flag yet.

@ObserverOfTime ObserverOfTime modified the milestones: 0.24, 0.23 Apr 12, 2024
@ObserverOfTime ObserverOfTime modified the milestones: 0.23, 0.24 Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli enhancement Feature request
Projects
None yet
Development

No branches or pull requests

4 participants