Difference between revisions of "Compiler options file"
m (→See also:  Make links to forum absolute)  | 
				m (Minor corrections)  | 
				||
| Line 80: | Line 80: | ||
* version_less  | * version_less  | ||
| − | + | If the output is not so easy to parse, as it happens p.e. with "sdcc --version", there is an extended version of the regex test (since r12739) allowing version extraction followed by numeric comparison:<source lang="xml" enclose="div">  | |
| − | If the output is not so easy to parse, as it happens   | ||
<if exec="C --version"  | <if exec="C --version"  | ||
     regex="([0-9]+\.[0-9]+\.[0-9]+);op;a.b.c"  |      regex="([0-9]+\.[0-9]+\.[0-9]+);op;a.b.c"  | ||
| Line 95: | Line 94: | ||
* ne: not equal  | * ne: not equal  | ||
* le: less or equal  | * le: less or equal  | ||
| − | * lt less than  | + | * lt: less than  | 
| − | |||
All these tests can be cascaded, and the result will be the logical AND of the individual results (with short circuit, so a ''false'' will skip the remaining tests).:<source lang="xml" enclose="div">  | All these tests can be cascaded, and the result will be the logical AND of the individual results (with short circuit, so a ''false'' will skip the remaining tests).:<source lang="xml" enclose="div">  | ||
| Line 106: | Line 104: | ||
</if>  | </if>  | ||
</source>  | </source>  | ||
| − | |||
<source lang="xml" enclose="div">  | <source lang="xml" enclose="div">  | ||
<Program name="C" value="mingw32-gcc.exe"/>  | <Program name="C" value="mingw32-gcc.exe"/>  | ||
Revision as of 13:24, 7 March 2022
Format for storing compiler options in editable XML.
<CodeBlocks_compiler_options extends="gcc">
[...]
</CodeBlocks_compiler_options>I am a Code::Blocks compiler options file.
extends="<id>" (optional)
- Load the corresponding options_<id>.xml file first (use if this compiler is almost the same, with only a few altered programs or added switches, for example).
 
<if platform="windows">
[...]
</if>
<else>
[...]
</else>Standard if statement; contents of if block is evaluated if the if statement is true, otherwise the else block is evaluated (the else block is optional). Nesting is allowed.
platform="<os>". <os> is one of:
- windows
 - macosx
 - linux
 - freebsd
 - netbsd
 - openbsd
 - darwin
 - solaris
 - unix
 
<if exec="bison -h">
[...]
</if>True if the the command exec can be run.
<if exec="C -dumpversion"
    regex="^4\.[3-9]|^[5-9]\.[0-9]"
    default="true">
[...]
</if>If the text before the first space in exec is one of:
- C
 - CPP
 - LD
 - LIB
 - WINDRES
 - MAKE
 
it will be replaced with the name of the corresponding executable.
True if regex matches the command's output (in this case, version number >= 4.3.0).
default is used if the command fails to execute (optional).
If the output of "C -dumpversion" is easily parseable (p.e. GCC-9.1.0 will output 9.1.0) there are handy tests for numeric comparison:
<if exec="C -dumpversion"
    test="9.1.3"
    default="true">
[...]
</if>where test can be one of:
- version_greater
 - version_greater_equal
 - version_equal
 - version_not_equal
 - version_less_equal
 - version_less
 
If the output is not so easy to parse, as it happens p.e. with "sdcc --version", there is an extended version of the regex test (since r12739) allowing version extraction followed by numeric comparison:
<if exec="C --version"
    regex="([0-9]+\.[0-9]+\.[0-9]+);op;a.b.c"
    default="true">
[...]
</if>The capturing regex is followed by an operator and a version number in a.b.c format (not limited to three parts). The separator is a semicolon, if the regex includes one it can be escaped with a backslash. The operator (op) can be one of:
- gt: greater than
 - ge: greater or equal
 - eq: equal
 - ne: not equal
 - le: less or equal
 - lt: less than
 
All these tests can be cascaded, and the result will be the logical AND of the individual results (with short circuit, so a false will skip the remaining tests).:
<if exec="C -dumpversion"
    version_greater_equal="9.1.3"
    version_less="11.0"
    default="true">
[...]
</if><Program name="C" value="mingw32-gcc.exe"/>Give the name of an executable
name="<prog>". <prog> is one of:
- C
 - CPP
 - LD
 - DBGconfig
 - LIB
 - WINDRES
 - MAKE
 
value="<exec>" (actual name of the executable).
<Switch name="includeDirs" value="-I"/>Switches controlling compiler constants.
name="<opt>". <opt> is one of:
- includeDirs
 - libDirs
 - linkLibs
 - defines
 - genericSwitch
 - objectExtension
 - forceFwdSlashes. value is one of true or false
 - forceLinkerUseQuotes. value is one of true or false
 - forceCompilerUseQuotes. value is one of true or false
 - needDependencies. value is one of true or false
 - logging.  value is one of:
- default (same as full)
 - full
 - simple
 - none
 
 - libPrefix
 - libExtension
 - linkerNeedsLibPrefix. value is one of true or false
 - linkerNeedsLibExtension. value is one of true or false
 - supportsPCH. value is one of true or false
 - PCHExtension
 - UseFlatObjects. value is one of true or false
 - UseFullSourcePaths. value is one of true or false
 - Use83Paths. value is one of true or false
 
<Option name="Profile code when executed"
        option="-pg"
        additionalLibs="-pg -lgmon"
        category="Profiling"
        checkAgainst="-O -O1 -O2 -O3 -Os"
        checkMessage="You have optimizations enabled. This is Not A Good Thing(tm) when producing debugging symbols..."
        supersedes="-s"
        exclusive="true"/>Definition of a compiler flag.
- name. Human readable description of the flag.
 - option. Flags to be sent to the compiler (optional).
 - additionalLibs. Flags to be sent to the linker (optional).
 - category. The category this flag is in (optional; defaults to "General").
 - checkAgainst. Show a warning message if any of these flags are enabled (optional).
 - checkMessage. Warning message to show upon conflict (optional).
 - superseds. Automatically disable the list of superseded flags if this flag is enabled (optional).
 - exclusive. Disable all other flags in this category if this flag is enabled. Is one of true or false (optional).
 
<Category name="CPU architecture tuning"
          exclusive="true">
[...]
</Category>name="<cat>". Any flags (<Option [...] />) contained in here that lack the category attribute will be treated as category <cat>.
exclusive. Is one of true or false. Any flags (<Option [...] />) contained in here that lack the exclusive attribute will be treated as this. (Optional.)
<Common name="optimization"/>Load options from a common file.
name="<file>"
- Loads options_common_<file>.xml (file syntax is exactly the same as this file).
 
<Command name="CompileObject"
         value="$compiler $options $includes -c $file -o $object"/>Definitions for forming compiler commands.
name="<cmd>". <cmd> is one of:
- CompileObject
 - GenDependencies
 - CompileResource
 - LinkExe
 - LinkConsoleExe
 - LinkDynamic
 - LinkStatic
 - LinkNative
 
<Command name="CompileObject"
         value="bison -v -d $file -o $file_dir/$file_name.parser.cc"
         ext="y"
         gen="$file_dir/$file_name.parser.cc;$file_dir/$file_name.parser.hh"/>Additional commands can be added to each category with a file extension filter.
ext="<exts>". <exts> is a semicolon separated list of file extensions (without the leading "." period).
gen="<files>". <files> is a semicolon separated list of generated files to be further processed (optional).
<RegEx name="Info line"
       type="info"
       msg="1;2;4"
       file="2"
       line="3">
    <![CDATA[(In file) ([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+)(\.[0-9]+.*:)*]]>
</RegEx>Definitions for regular expressions to parse compiler output.
name="<label>". <label> is the name this regex will be listed as.
type="<tp>". <tp> is one of
- normal
 - warning
 - error
 - info
 
msg="<nums>". <nums> is a semicolon separated list of indices (minimum one, maximum three) for the locations of messages within the regex.
file="<num>". <num> is the index of the regex which gives the relevant file (optional).
line="<num>". <num> is the index of the regex which gives the relevant line number (optional).
The contents is the regex (use of a CDATA section is not required).
Proposed Updates
See: Use wxPropGrid for compiler flags
<Option name="Intel Pentium (MMX)"
        option="-march=pentium-mmx"
        type="string"
        default="pentium-mmx"
        compose="-march=$(ENTRY)"/>For type="string", a free text editor is presented.
default="<str>". <str> is the default text for the editor textbox.
compose="<str>". <str> is the template for generating the compile command. All occurrences of $(ENTRY) are replaced with the content of the textbox. (Extensions: all occurrences of $(ENTRY_QUOTE) are replaced with the content of the textbox, and quoted/escaped as needed; $(ENTRY_STRIP) is replaced with the textbox content, all whitespace removed.)
<Option name="Link time optimization"
        option="-flto"
        additionalLibs="-flto -O2"
        type="integer"
        default="1"
        min="1"
        max="16"
        label="Parallel link jobs"
        compose="-flto"
        composeLib="-flto=$(ENTRY) -02"/>For type="integer", a spin dial is presented.
default="<int>". <int> is the starting value.
min="<int>". <int> the minimum allowed value.
max="<int>". <int> the maximum allowed value.
label="<str>". <str> descriptive information (displayed as a tooltip? or maybe a label next to it?).
compose="<str>". <str> is the template for generating the compile command. All occurrences of $(ENTRY) are replaced with the value of the spin control.
composeLib="<str>". <str> is the template for generating the link command. All occurrences of $(ENTRY) are replaced with the value of the spin control.
<Option name="Intel i386"
        option="-march=i386"
        type="boolean"/>For type="boolean", a standard checkbox is supplied (this is default behavior if no type is specified).
<Combo comboId="architecture"
       label="Generate code for:"/>
<Option name="Generate code for Intel i386"
        option="-march=i386"
        type="combo"
        comboId="architecture"
        label="Intel i386"/><Combo [...]/> defines a combo select box with label="<str>".
For type="combo", an entry is added to a combo select box.
comboId="<str>". <str> is the id of the combo box to add this command to.
label="<str>". <str> is the text to name this entry in the combo box's list. (If not supplied, name="<str>" is used instead.)
All of these proposed changes maintain both forwards and backwards compatibility. The new attributes will be ignored by older versions of Code::Blocks. Any entry which does not contain the required fields for this updated format can be rendered as type="boolean" to read older files, with no loss of information. Alpha 01:59, 25 June 2014 (CEST)