Get file dir from build script

Hi, everyone.

In my .hxml build script, I am defining a “–cmd” to run after building, and I need to pass the dir to the .hxml build script to the command. Is there any kind of variable or something that I can use in the script to get the value?

Thank you!

Could you do something like this?

HAXE_CMD=$(pwd) haxe build.hxml

Then in the cmd reference that variable like so:

--main Main
...other stuff
--cmd echo $HAXE_CMD

The above will print the directory. This will only work on bash-family shells.

If there is no way to obtain the directory from within the hxml script itself, I would have to do something like that, but it needs to work on Windows and Linux.

Maybe create a .sh script for Linux and a .bat for Windows where haxe is called, but then I can just run the command afterwards from the shell script itself instead of the hxml. It would just be handy to be able to do this in the hxml and avoid the shell script altogether.

Hxml isn’t a script it’s a markup file.

Hxp would probably be better suited for your needs, I would encourage you to take a look: GitHub - openfl/hxp: Write scripts in Haxe, and execute them on Windows, macOS or Linux