12.6.3.5 Compiler

Compilers are run over each of the changed files in each of the file groups in a target to create object files, which are then linked into the target. Modification dates or hashes are used to tell if files need recompiling, or if the object file can be reused.

  • flag - Adds a single argument to the compiler command line.

    • value - flag added to the command line.
    • tag - optional filter to restrict flag to files with a matching tag. See Tags.
<flagvalue="value"tag="tag"/>
  • cflag/cppflag/objcflag/mmflag - Adds a flag when compiling specific file types.

    • cflag - only added to .c (C) files.
    • cppflag - only added to .cpp (C++) files.
    • objcflag - only added to .objc (Objective-C) files.
    • mmflag - only added to .mm (Objective-C++) files.
<cflagvalue="value"/><cppflagvalue="value"/><objcflagvalue="value"/><mmflagvalue="value"/>
  • pchflag - Adds a flag when compiling precompiled header .h files.

    • pchflag - usually ["-x", "c++-header"] for apple to specify the "identity" of the header.
<pchflagvalue="value"/>
  • pch - Sets the precompiled header style - gcc or msvc.
<pchvalue="gcc|msvc"/>
  • objdir - Sets the name of the directory used to store object files. Should be unique for a given set of compiler flags to avoid linking against the wrong architecture.

    • value - usually built programmatically, e.g. obj/msvc${MSVC_VER}-rt${OBJEXT}${OBJCACHE}${XPOBJ}.
<objdirvalue="obj/somewhere"/>
  • output - Sets the flag used to specify the compiler's output.

    • value - flag value. Note that it should contain a space character if the actual name should be a separate argument, like -o<space>, or -o/-out: if the name should be appended directly.
<outflagvalue="-flag"/>
  • exe - Overrides the executable command specified in the compiler attribute.

    • name - command. Usually you would use path to add the directory containing the executable, then specify the filename part only in this attribute.
<exename="command"/>
  • ext - Sets the object file extension.

    • name - extension, including ".". .o on Linux and Mac, .obj on Windows.
<extname=".obj"/>
  • getversion - Sets the command used to obtain the version of the compiler. This is used for checking if the compiler has changed, and therefore whether the objects need recompiling.

    • value - command to run. It defaults to (compiler) --version which works for gcc-based compilers. Setting it to an empty value will disable caching.
<getversionvalue="command"/>
  • section - Groups blocks of elements - usually ones that all respect the same if/unless condition.
<section>...</section>
  • include - Includes compiler options from another file. Most compilers should include <include name="toolchain/common-defines.xml" /> to add the defines used by hxcpp.
<includename="filename"/>

close