compiler /REASM and /COMMENTED enhancements

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

compiler /REASM and /COMMENTED enhancements

Post by Tristano »

PureBasic 5.61

Currently, the pbcompiler behaviour for the /REASM option is a bit puzzling.

It seems that the /REASM option requires a source filename, but at the same time ignores it because it only takes "PureBasic.asm" as source file.

What make it even more puzzling, is that it first checks if the filename passed actually exists, and then looks for the "PureBasic.asm" as source file; if either of them is missing it will raise an error.

But if you invoke the compiler with /REASM without passing a filename it will raise a "source file not found" error, even if the "PureBasic.asm" file exists.

Effectively, with /REASM option, the filename parameter is just a dummy placeholder (except that it must refer to an existing source file). Currently, passing the filename of another source file is perfectly OK, except that the actual file being reasmed is another one (ie: "PureBasic.asm"). This might confuse the user to believe that he actually suceeded into compiling the passed asm filename, which is not the case.

I suggest that

1) the /REASM option should dispense the need to pass a source filename, and default to "PureBasic.asm" when no filename is passed:
pbcompiler.exe /REASM
... should implicitly look for "PureBasic.asm", and produce "PureBasic.exe"

2) If a "*.asm" source filename is passed, it should reasm that source file instead of "PureBasic.asm".
This would simplify working with multiple assembly sources in the same folder, without having to rename them back and forth to "PureBasic.asm"

Currently, the compiler checks that the passed filename exists, but then the /REASM option ignores it in favour of "PureBasic.asm" (which must exist).

3) If a "*.pb" source filename is passed, it should reasm the "PureBasic.asm" (and not look for a corresponding "<filename>.asm") — this would preserve backward compatiblity with automation scripts.

4) Also, it would be nice to improve the /COMMENTED option, allowing to specify a custom filename for the output asm file.
Again, preserving the current defaults to prevent breaking backward compatibility.

5) Currently there is no way to produce the asm file (via /COMMENTED) without also producing an exe file. If the /CHECK option is passed together with /COMMENTED,
no asm file is produced. The only workaround I've managed so far is to redirect the executable to some temporay folder, via /EXE.

These changes shouldn't break backward compatibility, and would make life easier when working with multiple asm source files in a same folder, especially
when resorting to scripted automation, or custom IDE tools. The current restriction imposed by the "PureBasic.asm" default forces multiple file rename operations.

For example, a user might wish to convert to asm the same pb source file, for both x86 and x86_64, so allowing the pbcompiler to handle custom filenames for /COMMENTED and /REASM would simplify working with some custom naming conventions like "<filename>_x32.asm" and "<filename>_x64.asm", or even "<filename>_x32_pb561.asm", and so on.
The PureBASIC Archives: FOSS Resources: