nim-lang / RFCs

A repository for your Nim proposals.
135 stars 26 forks source link

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

Open codehz opened 2 years ago

codehz commented 2 years ago

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 commented 2 years ago

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

Araq commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

codehz commented 2 years ago

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 commented 2 years ago

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

saemideluxe commented 1 year ago

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 commented 1 year ago

You can use when defined(nimcheck)

saemideluxe commented 1 year ago

Great, thanks!