Haxe compilation without a main entry point

I am trying to compile a Haxe class without defining an entry point using an assembly file hxml.

My folder structure is as follows:

root
|
 ___src
     |___Test.hx
|
 ___build.hxml

Test.hx has the following contents:

package foo;

class BarLib 
{
      public function new()  {}

      public function test() {
            return "Hello from BarLib!";
      }
}

build.hxml looks like that:

-cp src 
--macro "include('foo')"
-js test.js

Then I run haxe build.hxmlfrom the root folder that creates the file test.js, but its contents are almost empty:

// Generated by Haxe 3.3.0
(function () { "use strict";
})();

Seems unable to find package foo.

What am I doing wrong?

+4
source share
2 answers

You declare as Test.hxpart of the package foo, however it is placed in a folder with the name src. If you move it to src/foo, Haxe will produce the following output:

// Generated by Haxe 3.3.0
(function () { "use strict";
var foo_BarLib = function() {
};
foo_BarLib.prototype = {
    test: function() {
        return "Hello from BarLib!";
    }
};
})();

Test.hx, Test. BarLib.hx .

+7

haxe -cp src foo.Test ( )

+1

All Articles