7.1 HXML

Compiler arguments can be stored in a .hxml file and can be executed with haxe <file.hxml>. In hxml it is possible to use newlines and comments which makes it easier to maintain Haxe build configurations. It is possible to supply more arguments after the hxml file, e.g. haxe build.hxml --debug.

Example:

This example has a configuration which compiles the class file website.HomePage.hx to JavaScript into a file called bin/homepage.js, which is located in the src class path. And uses full dead code elimination.

--class-path src
--dce full
--js bin/homepage.js
--main website.HomePage
Multiple build compilations

Hxml configurations allow multiple compilation using these arguments:

  • --next Separate several Haxe compilations.
  • --each Append preceding parameters to all haxe compilations separated by --next. This reduces the repeating params.

Example:

This example has a configuration which compiles three different classes into their own JavaScript files. Each build uses src as class path and uses full dead code elimination.

--class-path src
--dce full

--each

--js bin/homepage.js
--main website.HomePage

--next

--js bin/gallery.js
--main website.GalleryPage

--next

--js bin/contact.js
--main website.ContactPage

Calling build configurations inside HXML:

It is possible to create a configuration that looks like this:

build-server.hxml
--next
build-website.hxml
--next
build-game.hxml
Comments inside hxml

Inside .hxml files lines starting with a hash (i.e. #) are comments.

Example:

# This hxml run the program
--run cli.Main