7 Compiler Usage
Basic Usage
The Haxe Compiler is typically invoked from command line with several arguments which have to answer two questions:
- What should be compiled?
- What should the output be?
To answer the first question, it is usually sufficient to provide a class path via the -cp path argument, along with the main class to be compiled via the -main dot_path argument. The Haxe Compiler then resolves the main class file and begins compilation.
The second question usually comes down to providing an argument specifying the desired target. Each Haxe target has a dedicated command line switch, such as -js file_name for JavaScript and -php directory for PHP. Depending on the nature of the target, the argument value is either a file name (for -js, -swf and neko) or a directory path.
Common arguments
Input:
- -cp pathAdds a class path where- .hxsource files or packages (sub-directories) can be found.
- -lib library_nameAdds a Haxelib library. By default the most recent version in the local Haxelib repository is used. To use specific version,- -lib library_name:versioncan be used.
- -main dot_pathSets the main class.
Output:
- -js file_nameGenerates JavaScript source code in specified file.
- -as3 directoryGenerates ActionScript 3 source code in specified directory.
- -swf file_nameGenerates the specified file as Flash .swf.
- -neko file_nameGenerates Neko binary as specified file.
- -php directoryGenerates PHP source code in specified directory.
- -cpp directoryGenerates C++ source code in specified directory and compiles it using native C++ compiler.
- -cs directoryGenerates C# source code in specified directory.
- -java directoryGenerates Java source code in specified directory and compiles it using the Java Compiler.
- -python file_nameGenerates Python source code in the specified file.