简体   繁体   中英

How do I compile a Haxe program with Eclipse?

I installed the Eclihx plugin and I am now trying to test it. The contents of Main.hx is

class Main {
    static function main() {
        trace("This is a test.");
    }
}

and the contents of Build.hxml is

-cp Source

# Uncomment the desirable target
# JavaScript target
-js Output/haxe Test.js

# SWF 9 target
-swf9 Output/haxe Test.swf

# ActionScript3 target
-as3 Output

# Neko target
-neko Output/haxe Test.n

# PHP target
-php Output

# C++ target
-cpp Output

# Uncomment and place your main class with package
-main Main

The build option in the Project menu is grayed out. What do I do?

First of all, you can't compile all targets at once, you need to comment all the targets and uncomment for example javascript target.

Then, open Haxe Package Explorer and select (left mouse click) your project (root), then right mouse click, Run As, Run Configurations...

Left double click Haxe application and you will get New_configuration. Select project, set Build File and click Run. Your project is compiled. Further on you can use CTRL+11 to compile your project.

Now, you will need test html document for javascript target. Create test.html in output directory (where .js file is generated) and use content like this:

<html>
<head><title>Haxe JS</title></head>
<body>
<div id="haxe:trace"></div>
<script type="text/javascript" src="hxTest.js"></script>
</body>
</html>

For Neko, I usually associate .n extension to Neko program, etc. (then you only need to doublick .n to execute your progam)

TIP: Project Properties, Haxe Content Assist, Build File (select build.hxml from your project) to enable code completition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM