Archive: Expand macros (flatten code)


Expand macros (flatten code)
Hi,

is there a way to get the result of the preprocessing of makensis? I want to get a single file with the final code (all includes inline and macros/defines resolved). Makensis does something similar on stdout but that is no real (compilable) code. Source Code that is included with NSIS (e.g. MUI2) should stay in it's original form (no expansion for includes like that). It would be ok to mark the things to expand (!insertmacro and !include statements with a special switch or something like that).

Any ideas?


search-and-replace? :)

( you could even write an 'installer' with NSIS that did this for you ;) )


It's definitely a lot more complicated than that. What about the conditional compilation instructions (among other compile time instructions)? Even replacing macro parameters with their corresponding values would require a bit of code (and in NSIS? no thanks!) I'm not sure how makensis processes scripts so I do not know if it will hold the expanded script in memory (I doubt it) or a compiled version. So as Animaether suggests (albeit a lot more work) would be to write your own parser. Another option of course would be to modify makensis but I cannot say if that is more work.

Edit: FYI Java has a Scanner class for tokenizing strings which will definitely cut the work load.

Stu


This tool called Universal Extractor has some rudimentary support for ripping an nsi file from an NSIS installer, if it was compressed with the default compressor and if it's not too complex. It's a lot of pops and pushes and not very understandable, and even then it's definitely not the same as the precompiler output. Either way, it may help in your case.