Get final full expanded source?
Get final full expanded source?
Hi guys, is there a way I can get the final full expanded source of my app after all included files and macros have been expanded, and save it as a new single big PureBasic source code to disk? I'm talking about what would be considered the "finished" source just before the compiler starts compiling it. Thank you.
Re: Get final full expanded source?
Here is an example with RunProgram().https://www.purebasic.com/documentation/reference/cli_compiler.html wrote:-pp, --preprocess, /PREPROCESS "filename": preprocess the source code and write the output in the specified "Filename". The processed file is a single file with all macro expanded, compiler directive handled and multiline resolved. This allows an easier parsing of a PureBasic source file, as all is expanded and is available in a flat file format. No comments are included by default, but the flag '--commented' can be used to have all untouched original source as comments and allow comments processing. The preprocessed file can be recompiled as any other PureBasic source file to create the final executable.
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Re: Get final full expanded source?
Thank you both. I'm amazed that it even splits multiple commands onto separate lines.
Is there a way to specify the output file, so it doesn't go to c:\commented?
Is there a way to specify the output file, so it doesn't go to c:\commented?
Re: Get final full expanded source?
As you can see from the PB help, the output file name is specified after the preprocess command. Instead of specifying only the output file name, you can also specify the full path to the output file. You can see that in my example code, too.BarryG wrote:Is there a way to specify the output file, so it doesn't go to c:\commented?
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Re: Get final full expanded source?
Hi Sicro, I already did look at your source but when I tried to adapt it to this simple batch file, it doesn't work:
The parameters match the order of what you did:
So I don't know why it's failing.
Code: Select all
C:\PureBasic\Compilers\pbcompiler.exe C:\Source\Orig.pb /preprocess C:\Source\Full.pb
Code: Select all
compilerFilePath$, ~"\"" + codeFilePath$ + ~"\" --preprocess \"" + tempCodeFilePath$
Re: Get final full expanded source?
Possibly a restriction of the Windows version of the PB compiler.
Please take my procedure linked above and execute it:What is the result?
Please take my procedure linked above and execute it:
Code: Select all
fullCode$ = GetContentOfPreProcessedFile("C:\Source\Orig.pb", "C:\PureBasic\Compilers\pbcompiler.exe")
If fullCode <> ""
Debug "ok"
Else
Debug "error"
EndIf
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
- Kwai chang caine
- Always Here
- Posts: 5353
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Get final full expanded source?
For me works perfectly with "fullCode$"
Thanks a lot SICRO for sharing
Thanks a lot SICRO for sharing
The happiness is a road...
Not a destination
Not a destination
Re: Get final full expanded source?
Hi Sicro, I tried your procedure and it worked, so I deleted my batch file and recreated it, and it works for me now. No idea why. All sorted, anyway. Thanks!Sicro wrote:Please take my procedure linked above and execute it