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

Allow use gorge in nim check and nimsuggest (but only use cached value) #430

Open
codehz opened this issue Oct 18, 2021 · 9 comments
Open
Assignees

Comments

@codehz
Copy link

codehz commented Oct 18, 2021

Currently, gorge and gorgeEx are "disabled" for nimsuggest and nim check
https://github.com/nim-lang/Nim/blob/8ccde68f132be4dba330eb6ec50f4679e564efac/compiler/vm.nim#L1721
I can understand why they are disabled (partial command may break something), but I also think there are other options

Changes

Allow use gorge in check context, but only when the result is cached (or use some command line options to temporarily enable).
If the result is not cached, emit a warning and return an empty string.

It will be really useful if user's code depends on some metaprograming magic that require gorge (like external codegen)

@codehz codehz changed the title Allow use gorge in nim check or nim suggest (but only use cached value) Allow use gorge in nim check and nim suggest (but only use cached value) Oct 18, 2021
@codehz
Copy link
Author

codehz commented Oct 18, 2021

I have created a patched version for nim 1.4 branch for testing (not use devel is because I want to test in my actual project that does't work for 1.5 yet)
https://github.com/codehz/Nim/tree/fix-gorge (not for merge)
Update:
Now I've migrate this patch to 1-6 branch see tree fix-gorge-1-6

@codehz codehz changed the title Allow use gorge in nim check and nim suggest (but only use cached value) Allow use gorge in nim check and nimsuggest (but only use cached value) Oct 18, 2021
@Araq
Copy link
Member

Araq commented Oct 28, 2021

The idea is smart but why do you need it? So you use nim c proj once, the invokations are cached and then nim check succeeds? Would work I guess.

@codehz
Copy link
Author

codehz commented Oct 28, 2021

The idea is smart but why do you need it? So you use nim c proj once, the invokations are cached and then nim check succeeds? Would work I guess.

Get better IDE support, or it will keep mark many symbol as error(nimsuggest won't work neither) if those symbols are depends on staticExec's result.

for example external code generator for GLSL based on glslang, extract metadata(attribute location, uniform structure) from shader source, which hard to implemented in pure nim

@Araq
Copy link
Member

Araq commented Oct 29, 2021

The question is: Is the outlined workflow good enough for you?

@codehz
Copy link
Author

codehz commented Oct 29, 2021

The question is: Is the outlined workflow good enough for you?

Yes, it is definity enough, I just create a user level task in vscode, so I can easily rebuild the cache when needed (when edit nim code, the shader codes are keep unchanged, so no need to rebuild frequently, I think it is also true for most of projects that require those feature like niminterop), maybe it could be integrated into the extension, but I think it is already good enough to me..

btw, in 1-6 branch , since check use different cache folder, I added a --gorgecheck option for that (not a good name)

@Araq
Copy link
Member

Araq commented Oct 31, 2021

Cannot see a flaw in this proposal, hence "accepted". Hopefully we didn't overlook something.

@ringabout ringabout self-assigned this Aug 4, 2022
@saemideluxe
Copy link

Hi there
Any advancment on this issue? This would be nice for compile-time shader-compilation. Currently I am just comparing the output of gorgeEx to the empty string, to see whether it has run or not. Or is there another way to check if we are in "check" mode?

@Araq
Copy link
Member

Araq commented Jan 17, 2023

You can use when defined(nimcheck)

@saemideluxe
Copy link

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants