[英]Compiling Haxe without a main entry point
I am trying to compile a Haxe class without defining an entry point by using a build hxml
file. 我试图编译一个Haxe类,而不使用构建
hxml
文件定义入口点。
My folder structure looks like the following: 我的文件夹结构如下所示:
root
|
___src
|___Test.hx
|
___build.hxml
Test.hx
has the following contents: Test.hx
具有以下内容:
package foo;
class BarLib
{
public function new() {}
public function test() {
return "Hello from BarLib!";
}
}
build.hxml
looks like this: build.hxml
看起来像这样:
-cp src
--macro "include('foo')"
-js test.js
I then run haxe build.hxml
from the root folder which creates the file test.js
, but its contents is pretty much empty: 然后我从根文件夹运行
haxe build.hxml
,它创建文件test.js
,但其内容非常空:
// Generated by Haxe 3.3.0
(function () { "use strict";
})();
It seems not to be able to locate the package foo
. 似乎无法找到包
foo
。
What am I doing wrong? 我究竟做错了什么?
You declare Test.hx
to be part of the foo
package, however, it's placed in a folder named src
. 您将
Test.hx
声明为foo
包的一部分,但是,它放在名为src
的文件夹中。 If you move it to src/foo
, Haxe produces the following output: 如果将其移动到
src/foo
,Haxe会产生以下输出:
// Generated by Haxe 3.3.0
(function () { "use strict";
var foo_BarLib = function() {
};
foo_BarLib.prototype = {
test: function() {
return "Hello from BarLib!";
}
};
})();
It's also a bit unusual to have a file named Test.hx
that doesn't actually define a type named Test
. 有一个名为
Test.hx
的文件实际上并没有定义名为Test
的类型,这也有点不寻常。 BarLib.hx
might be a better name. BarLib.hx
可能是一个更好的名称。
你也可以使用haxe -cp src foo.Test
来编译一个没有入口点的类(和它的引用)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.