Compile to multiple languages with a single .hxml file in Haxe

345 views Asked by At

Here's the basic Haxe "Hello World!" program:

class Main 
{
    public static function main() 
    {
        trace("Hello world");
    }
}

Here's the build file for the above program:

-main Main
-java java

Now I want to compile this program to Java, Javascript, and C++ with a single .hxml file. How should the .hxml file be formatted, in this case?

2

There are 2 answers

0
mikeysee On BEST ANSWER

You should use the command "--next" to specify the next compile target. So:

-main Main
-java java

--next

-main Main
-cpp cpp

--next
-flash out.swf
0
Anderson Green On

I have written a compile.hxml file that compiles the class Test.hx to various target languages. All the necessary libraries will need to be installed first in order for it to work properly.

-js test.js
-main Test

--next
-php www
-main Test

--next
-cpp cpp
-debug
-main Test

--next
-main Test
-java java

--next
-cs test
-main Test
-D haxe3