I've been using the --run command, and have been trying to include some packages when running it, using --macro include like this:
haxe -lib nape --macro include('nape.geom.Vec2') --run Main 'nape.geom.Vec2'
and then use Type.resolve so I can instantiate them with Type.createInstance like so:
class Main
{
static function main()
{
trace("hello", Sys.args());
var c = Type.resolveClass(StringTools.replace(Sys.args()[0], "'", ""));
trace(c);
Type.createInstance(c, []);
}
}
I've also tried to use --interp with this command:
haxe -lib nape --macro include('nape.geom.Vec2') -main Main --interp -D nape.geom.Vec2
They both run, trace, and receive the Sys.args as expected for --run (with a small code change to accommodate '-D nape.geom.Vec2' for interp), but resolveClass always returns null, so I cant pass it to creatInstance without an error.
I'm using haxe 3.4.2 stable
What am I doing wrong? Is this possible with the --run command or --interp commands?
Id really love some more complete documentation on some of these features
Ok, so I got it working by linking the individual classes I require, and disabling dead code elimination (as suggested above by Jonas Malaco)
Using the code from the original post, and this build command:
haxe -lib nape nape.geom.Vec2 -dce no --run Main 'nape.geom.Vec2'