Haxe Compiler

Command Line Arguments

Updated to 2.09

Here is a list of the different arguments that you are able to pass to the Haxe compiler.

These arguments can also be placed into a text file of one per line with the extension hxml. This file can then be passed directly to the haxe compiler as a build script.

Usage

compile all input haxe files with a main class.

haxe [-main <class>] [-<target_platform> <output>] [option]+ [<input_file>]+ 

OR

haxe <hxml_file> [option]+
  • [] : can be omitted
  • + : repeatable

Example


build.hxml (builds Client.hx and Server.hx)
#some comment

-main Client
-swf client.swf

--next

-main Server
-neko server.n

Run from command line:
haxe build.hxml

The equivalent without using an hxml file. Run from command line:
haxe -main Client -swf index.swf
haxe -main Server -neko server.n

Target Platforms Option

Each target and its options may only be used once per call the compiler. --next can be used in hxml files to utilize multiple calls with one command.

C++

See: Getting started with Haxe/C++

  • -cpp <directory> : generate C++ code into target directory

Javascript

See: Getting started with Haxe/JS.

  • -js <file> : compile code to JavaScript file
  • --js-modern : wrap JS output in a closure, strict mode, and other upcoming features
    See: JS modern
    in 2.09, removed --js-namespace, added $hxClasses
  • -D noEmbedJS : Omits inclusion of JQuery classes and swfobject.

Neko

See: Getting started with Haxe/Neko.

  • -neko <file> : compile code to Neko Binary
  • -x <main_class>: shortcut for compiling and executing a neko file. (generate <main_class>.n file See: --interp option)
  • -D neko-source : keep generated neko source

Flash

See: Getting started with Haxe/Flash.

  • -swf <file> : compile code to Flash SWF file
  • -swf-version <version> : change the SWF version (6 to 11.2, not adobe swf version, but flash player version).
    Implies the `-D flashN` switch, where `N` is the SWF version specified.
  • -swf-header <header> : define SWF header (width:height:fps[:color])
  • -swf-lib <file> : add the SWF library to the compiled SWF
    (Note: all classes of lib swf mixed with haxe classes. so you can use symbol class directly.
    but class name must starts with UpperCase, also must not be conflicted with haxe classes.)
    See: Getting started with Haxe/Flash check Using the Library section
    See: Using/Exporting SWC Files
  • -swf-lib-extern <file> : add the SWF library for type checking but don't include it in the compiled SWF
  • -as3 <directory> : generate AS3 code into target directory
    can not be used with -swf
  • --flash-strict : more type strict flash API
  • --flash-use-stage : place objects found on the stage of the SWF lib. In Haxe3 this has been changed to: -D flash-use-stage.
    (Not to be used together with -swf-header)
  • -swf9 <file>: (Deprecated: Use -swf-version instead) compile code to Flash9 SWF file

PHP

See: Getting started with Haxe/PHP.

  • -php <directory> : generate PHP code into target directory
  • --php-front <file>: select the name for the PHP front file
  • --php-lib <directory> : It's the path generated library, stored by defaut in the 'lib' sub directory.
  • --php-prefix <name> : prefix all classes with given name

Compilation Options

  • -main <class> : select startup class
  • -cp <directory> : class path. add a directory to find source files
  • -lib <lib_name[:version]> : use an haxelib library
    Implies `-D <lib_name>`
    See: Using haxelib
  • -D <var> : define a conditional compilation flag, or set one of the compiler flags.
    See: Conditional Compilation
    See: Tips and Tricks check Compiler Flags section for another intrinsics
    ie) -D haxe3 : Force compiler to only use future haxe3 when using 2.09 ( sys packages ).
  • -resource <file>[@name] : add a named resource file
    See: External File Resources
    (if you want to embed flash-specific-media, you can also use @:bitmap, @:file, @:sound )
    See: Tips and Tricks check Compiler Metadata->flash specfic section
  • -debug : add debug information to the compiled code. (NB: Flash users may additionally need `-D fdb` for debugging)
  • -xml <file>: generate XML types description of all input classes. (normaly used for documentation)
    See: Using haxedoc, chxdoc
  • --no-opt : disable code optimizations
  • --no-traces : don’t compile trace calls in the program
  • --no-inline : disable inlining
  • --no-output : compiles but does not generate any file
  • --remap <package:target> : remap a package to another one.
    (ie: --remap neko:cpp, --remap flash:nme)
  • dead code elimination : remove unused code
    • "-dce no" : do not remove unused code
    • "-dce std" : remove unused code in the std lib (default)
    • "-dce full" : remove all unused code
  • --gen-hx-classes : generate hx headers(extern classes) for all input classes (also classes from -swf-lib) to `hxclasses` folder
    See: Using/Exporting SWC Files check hx Classes Generation section
    See: Using AS3 classes in Haxe

Macro Options

  • --macro <macro_function_call>: call the given macro before typing anything else.
    ie) --macro MyMacroClass.myMacroFunction()
    Implies `-D macro`
    See: Compiler Configuration with Macros
  • --interp : interpret the program using internal macro system. (neko)
    (for just quick code testing, you can use `haxe -main Main --interp`, not generate output file.)
    Implies `-D macro`
    See: mailing list thread

Compiler Interaction Options

  • --display <file>@<byte_position> : display code tips
    See: the introductory blog post here)
    See: Completion and IDE Support check Compiler-based Completion section
  • -v : turn on verbose mode
  • -prompt : prompt on error
  • --times : measure compilation times
  • -help : Display basic list of options
  • --help : Display all list of options

Compilation Cache Server Options

  • --wait <[host:]port> : wait on the given port for commands to run
  • --connect <[host:]port> : connect on the given port and run commands there
  • --cwd <directory> : set current working directory
    See: Completion and IDE Support check Compilation cache server section

Batch Processing Commands

  • -cmd <comand> : run the specified command after successful compilation.
    (Note: Version 2.04 and earlier will only run after a successful compile. Will not run without a target)
    You can enclose environment variables in "%" to use their value (e.g. -cmd "echo %PATH%").
    (if you use windows cmd.exe, use double-quote like -cmd "..." )
    You can combine multiple commands in a single line using brackets and double ampersands (e.g. -cmd (cd core && haxe build.hxml && cd ../)
  • --next : separate several haxe compilations
version #19608, modified 2013-07-25 11:40:41 by AndyLi