The hxcpp
build.xml
build system is designed to make compiling, cross-compiling and linking easy on a large variety of operating systems and devices. It was originally designed to build the Haxe-generated C++ code but has evolved to replace the need for configuration tools in many open source libraries.
The source code for the tool lives in tools/hxcpp
in the hxcpp
repo. When compiled, it can be run with the Haxelib tool. This is usually done automatically by the Haxe compiler after the C++ code has been generated. It can be done manually like:
haxelib run hxcpp build.xml key=value ... [target]
See the hxcpp
build environment.
The compiler specification and target lists all use the same format.
echo
).if
and unless
node attributes.${VAR}
syntax.default
target must be defined.Most of the XML nodes support if
and unless
attributes. These will enable or disable the whole node according the existence or non-existence of a define. These can be combined with a space for "and" or two pipes for "or".
Substitution is supported via the dollars-brace syntax, and does basoc text substitution. In addition, there is some special syntax that can be used:
${VAR}
- normal replacement.${removeQuotes:VAR}
- strips surrounding quotes from VAR
, if any.${dospath:VAR}
- converts VAR
to path with backward slashes (as used on Windows).${dir:PathWithFilename}
- just the directory part of a filename.${this_dir}
- location of the directory containing the build.xml
file.The following code is saved as example.xml
:
<xml> <echo value="Hello ${WHO}" if="WHO" unless="SILENT" /> <echo value="You are in ${haxelib:hxcpp}" unless="WHO||SILENT"/> <error value="Silent and who both specified" if="WHO SILENT"/> <target id="default" /> </xml>
Some example usage:
unset SILENT
haxelib run hxcpp example.xml
haxelib run hxcpp example.xml WHO=world default
export SILENT=1
haxelib run hxcpp example.xml
haxelib run hxcpp example.xml WHO=world
Or, on Windows:
unsetenv SILENT
haxelib run hxcpp example.xml
haxelib run hxcpp example.xml WHO=world default
setenv SILENT 1
haxelib run hxcpp example.xml
haxelib run hxcpp example.xml WHO=world
The build.xml
file contains configuration, targets, compilers, linkers, and files. The details can be found in the subsections:
12.6.3.1: Structure of the top-level
12.6.3.2: Files
12.6.3.3: Tags
12.6.3.4: Targets
12.6.3.5: Compiler
12.6.3.6: Linker
12.6.3.7: Stripper
12.6.3.8: The Haxe Target
12.6.3.9: Xml Injection