I am trying to port the Nape physics engine (written in Haxe) to a language not supported by Haxe (Xojo). Now I don't understand Haxe but I am comfortable in Python. I'm trying to convert the mass of .hx files to python source files so I can then translate them to Xojo.
I have the Nape .hx source files (from haxelib) and have installed the haxe command line tool.
I have tried multiple permutations to try to convert the .hx files to Python files but am having no success. I have tried the following:
haxe -cp <directory containing some .hx files> -python <output directory>
That just outputs help from the haxe tool.
haxe <directory containing .hx files> -python <output directory>
That throws:
Error: Could not process argument [directory] Class name must start with uppercase character
I've tried just processing one .hx file:
haxe <.hx file> -python <output directory>
Error: Could not process argument [myfile.hx] empty part
Any ideas what I'm doing wrong? I thought the whole point of Haxe was to be able to easily convert to different languages?
Hugh is right in that you normally need to specify a
-main
argument. However, you can omit that and compile a single module as well if you don't need to have an entry point (for example when compiling a library like in your case):It think doesn't really matter much which module you choose here. I went with
nape.Config
. The important part is using--macro include
to make sure every file in the nape lib is compiled (otherwise only the ones referenced are included).This command produces a
nape.py
file with around 121000 lines, which might be a bit prohibitive depending on how much work is needed to convert Python code to this Xojo language. Even if that's a simple process, generated code is typically not the most readable.In fact, Nape's Haxe version is already not very readable, since it is generated by a preprocessor called caxe (
.cx
). The caxe source of Nape can be found here.There's some compiler options you could try here to reduce the code size a bit and make it more readable:
--no-inline
: prevents code form being inlined, reducing the output to ~60000 lines-D NAPE_RELEASE_BUILD
: Nape define that removes error handling - probably not worth it, only removes ~2000 more lines.