Initial release of HXP


#1

We have released an initial version of HXP, a script library spun from the core of the Lime and OpenFL command-line tools.

You might have seen the presentation at Haxe Summit talking about the “project.hxp” functionality available in the tools. We’ve taken this and built it into a whole library, and will continue to make changes to the Lime/OpenFL tools to rely more on it.

What can it do? At its simplest, you can turn ordinary Haxe files into scripts, without a compilation step.

Here’s a quick example:

// script.hx
class Script {
    public function new () {
        trace ("Hello from my script");
        System.mkdir ("bin");
        new HXML ({ cp: ["src"], main: "Main.hx", js: "bin/index.js" }).build ();
        PlatformTools.startWebServer ("bin");
    }
}
hxp script.hx

You can also pass arguments to your script:

class Script extends hxp.Script {
    public function new () {
        super ();
        trace (command);
        trace (commandArgs);
        trace (flags.keys ());
        trace (defines.keys ());
    }
}
hxp commandName arg1 -Ddefine arg2 -Ddefine2=value -flag -anotherflag
class Script extends hxp.Script {
    public function new () {
        hxp.Log ("Building multiple projects!);
        hxp.System.runCommand ("Project1", "lime", args);
        hxp.System.runCommand ("Project2", "lime", args);
    }
}

It works on Haxe 4 (using eval) or Haxe 3 (using Neko)

It has no CFFI requirement either, so it doesn’t have to be rebuilt.

We’re working on a 2.x API, and would love your feedback and help to continue to make this a more robust tool