I think users will get some mileage out of this addition (and I need a break from thiscall and c++ stuff).
Code: Select all
'' always compile for multi thread, extra errors checks, and debugging...
#cmdline "-mt -exx -g" '' ... etc
- #cmdline directives are processed when they appear in the first source module (.bas) file given on the real command line.
- All command line options are allowable except for '-print' and '-help'.
- #cmdline directives are processed on the first pass of the source file only. They are ignored on the second pass (even if a conditional #if would add something different on the second pass).
- if an invalid command line option is given in #cmdline - compilation immediately aborts
- #cmdline directives in any source module except the first are ignored. I wrote it this way because command line options are global and fbc has no concept of per module command line options - what would be better added as #pragma's ... some other time ;P
The way this feature works is:
- fbc intializes as usual and starts parsing of fb source code using whatever real command line options are given
- at least one of the real command line options needs to be a fb source file
- after #cmdline directives are processed they are merged in to the current compiler state
- depending on what command line options were encountered, fbc might continue parsing, reset the parser, or reset the build
- example: no restart after #cmdline "-mt"
- example: parser restart after #cmdline "-gen gcc"
- example: build restart after #cmdline "-target win64"
- #cmdline is only allowed at module scope, but can be conditional with #if statements
I have no clever way to detect when all the #cmdline directives have been processed, so there are 2 pseudo command line options to instruct fbc what to next.
#cmdline "-end" '' restart parser or build if needed
#cmdline "-reset" '' always restart bulid
The general form of the source should be:
Code: Select all
'' comments .... etc
#lang "fb" '' or fblite or qb
#if __FB_VERSION__ >= "1.09.0"
'' conditionals
#if defined( something )
#cmdline "args..."
#endif
#cmdline "args..."
#cmdline "-end" '' or "-reset"
... etc
#endif
'' The actual program follows...
#include ...
... etc
$ fbc source.bas -z nocmdline
To get warnings about ignored #cmdline directives:
$ fbc source.bas -w all
I'll post some examples soon-ish in additional posts.