How to determine which compiler is currently being used from within a build file
Right now, specific compilation flags can't be enabled/disabled depending on the compiler:
<compilerflag value="-Wno-psabi" unless="???" /> <!-- this works on gcc, but not clang -->
(If this isn't actually true, this issue can be ignored. Documentation just needs to be added.)
It seems like the isMsvc variable is available to check when using MSVC. Perhaps standard variables in the same vein may be helpful: isGcc, isClang, etc.
<compilerflag value="-Wno-psabi" unless="isClang" />
Or perhaps a more general solution:
<compilerflag value="-Wno-psabi" unless="compiler == clang" />
Otherwise, it may be useful to set a define in each toolchain that specifies which compiler has been chosen.
<compiler>
<set name="HXCPP_CLANG" value="1" />
<exe name="clang++" />
</compiler>
<compilerflag value="-Wno-psabi" unless="HXCPP_CLANG" />
I'd love to see this, but it'll be tricky at best. At the moment, BuildTool.hx parses your input file before setting up a compiler:
var xml_slow = Xml.parse(make_contents);
var xml = new XmlAccess(xml_slow.firstElement());
parseXML(xml,"",false); // <-- Your file
popFile();
include("toolchain/" + mDefines.get("toolchain") + "-toolchain.xml", false); // <-- Compiler setup
I'm sure sometimes you wouldn't need to wait for the toolchain.xml file, but sometimes you will. (Looking at you, android-toolchain.xml.)
I wonder if it's safe to reverse the execution order. I doubt it, but I haven't yet looked into it.