I need some help to get a clearer picture of how PureBasic compiler toolchain works in detail.
Recently, I’ve started working on a customized version of Horst Schaeffer’s PBasmUI — a PureBASIC IDE tool to create, view, edit and re-assemble the intermediate assembly code from PureBASIC source files:
Since this tool interfaces with PB’s command line compiler, I’m getting a chance to look closer at how the PBcompiler CLI options work; but I’m also facing problems in trying to implement all the compiler options found in PB’s IDE; and didn’t manage to find answers in PB Documentation or the SDK.
I’ve been documenting my findings (so far) in the project’s Wiki:
- PBasmUI Wiki: CLI Compiler
- PBasmUI Wiki: Compiler Toolchain
- PBasmUI Wiki: Compiler Options Mapping
- PBasmUI Wiki: Version nformation
Binary Tools
On Windows, the “Compilers” directory inside PureBASIC installation dir contains the following tools:
- pbcompiler.exe — The PureBASIC compiler
- PBDebugger.exe — The PureBASIC Debuger
- FAsm.exe — flat assembler v1.71.39
- polib.exe — Pelles Library Manager v6.00.1
- polink.exe — Pelles Linker v5.00.1
- porc.exe — Pelles Resource Compiler v7.00.0
If I’ve understood correctly, pbcompiler.exe always translates the pb source to Assembly, and then passes it to FAsm.exe to produce a binary file. But I’m not quite sure how the other tools fit in the toolchain (ie: in relation to pureLibs, IDE options, custom resources, etc.).
I’ve also downloaded the Pelles C suite, which contains the documentation of some of the above binary tools. Hopefully it might help, but right now I still don’t know how they fit in the picture.
Asm and ReAsm
While testing with the CLI compiler, I realized that when producing the “PureBasic.asm” file via the /COMMENTED switch, the presence of other switches (eg: /USER, /CONSOLE, and others) will create different asm sources. From this, I’m assuming that these switches are therefore not required when using the /REASM option (as they’ve already done their job in the productin of the asm file). But while this might be true for some switches, it’s unlikely to apply to others (eg: the /ICON switch shouldn’t affect the “PureBasic.asm” file, and should be passed with /REASM option).
What I’m missing out here is how /COMMENTED and /REASM actually work behind the scene — which tools they invoke, in which order, and (most important) which of the IDE’s options are being passed to which tool, and which options should be passed or left-out when invoking the compiler with /COMMENTED and /REASM.
Version Information
On Windows, PBCompiler supports version information, but I haven’t worked out how to handle this via command line. I’ve seen some Visual Studio projects that use a “*.RC” resource file to store version information.
The Version Info of a pb source file can be easily recovered from its settings (either at the end of file, or from a “*.cfg” file); but how can I include this info in the final executable via command line?
How does the PB IDE handle Version Info? Does it create a temporary resource file, or does it pass the info via CLI options?
…
I’m confident that advanced users will be able to grasp from my questions what I’m missing out of the global picture, and that they could provide some answers or direct me toward some external resources that can help me fill the knowldege gaps.