Hi,
I am playing with onGenerate for my experimental Nim target. Some things are not completely clear for me:
I can’t see any difference if I use --no-output or not. Does it make any change when I use it ?
Can I give a platform_name for that target - or what platform_name is used when no platform is specified ?
In order to build a standard library I want to create a _std directory in the platform directory to put the shadowed modules there. Is this possible from onGenerate/onAfterGenerate. Currently I have the modules in the root path, but this is a bit painful, because I need a lot of #if in order to distinguish between macro and target
Is -D analyzer-optimize applied for onGenerate/onAfterGenerate. I see that the inliner is applied, but sometimes I get a chain of unnecessary assignments. For what I thought is, that it is applied before onAfterGenerate. But maybe I do something wrong to get the final types there.
I am thinking of some optimizations. Can I analyze the code in onGenerate and for example mark a function to be inlined and then get it inlined in onAfterGenerate ?
I don’t have all the answers but I hope this can help:
The only difference is there is no output on your file system.
I am not sure, I think I would target js and use Compiler.setCustomJSGenerator. If your Nim target comes as a Haxelib, you can try to add -js output.js to your extraParams.hxml to “hide” the underlying js target. Also maybe it is possible to bypass the js package with Compiler.define if you set js to 0.
I have some doubt just creating an _std directory in the platform directory will make it work, but if it does I would not do it in onGenerate. Maybe you can use Compiler.patchTypes instead.
It is applied before both. Try using -dce full alongside because -D analyzer-optimize does not replace the DCE.
Inlining happens before onGenerate, but you can probably inline and make any additional optimizations yourself before writing Nim files.
Hi Dimitri,
thanks for the directions. I will give them a try. Since Nim is a static target I will try to shadow hl instead of js
is there any documentation about how a patchFile must look for Compiler.patchTypes. I can only guess from looking at the source and found some patch files in use - so I will try…
Cheers, Adrian.