Description
--genscript
messes up nimcache because it copies over Nim/lib/nimbase.h
(which could be stale, or from an old commit, or with local modifications etc) to nimcache/nimbase.h
and then future invocations of nim (that don't even involve --genscript
) will be forced to pickup up that old nimcache/nimbase.h
instead of the current Nim/lib/nimbase.h
; even nim c --forceBuild main.nim
won't help with that
Example
git checkout commit_with_older_nimbase # or simply do a local temporary modification to nimbase
nim c --genscript main.nim
git checkout -
nim c main.nim # `--forceBuild` doesn't help
uses old nimbase/nimbase.h
Possible Solution
-
generate
#include <nimbase.h>
instead of#include "nimbase.h"
in generateHeaders
by using angle bracket include, it'll honor the-I
flags and pickup the correct nimbase. However this may break the script generated by--genscript
, which should be updated to add an appropriate-I
flag -
nimbase.h
should be tracked as a depdendency in themain.json
file generated by--genscript
and maybe also the generatedmain.deps
file
Additional Information
- code where nimbase is copied for
--genscript
:
copyFile(conf.libpath / RelativeFile"nimbase.h",
getNimcacheDir(conf) / RelativeFile"nimbase.h")
- recent devel a33b72a
- root cause of one of the nimterop build errors I was having here build errors nimterop/nimterop#168 (comment)