Reputation: 28138
I have installed Haxe for OS X, and I have installed the Haxe code completion package for Sublime Text. So far this is working - I can type Haxe code and Sublime Text will recognize it.
I have read the Haxe tutorials and documentation, but I can't seem to find anything about compiling the Haxe code to javascript from Sublime Text.
I'm sure it has something to do with the 'build system' in Sublime Text, but I don't see how to get Haxe's tutorial commands into Sublime Text?
From the Haxe website:
Input:
-cp path:
Adds a class path where .hx source files or packages (sub-directories) can be found.
-lib library_name:
Adds a Haxelib library.
-main dot_path:
Sets the main class.
Output:
-js file_name:
Generates Javascript source code in specified file
-as3 directory:
Generates Actionscript 3 source code in specified directory.
An example of a build system from the unofficial SublimeText documentation:
{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
Does anybody have any idea how to use this? The Haxe website seems short on working examples.
Upvotes: 0
Views: 584
Reputation: 466
This question is old, but i'll answer - here is build system i'm using with ctrl+b shortcut (you can use "haxelib run openfl run ... " for your project.xml, or "haxe build.hxml")
{
"file_regex": "(\\/.+\\.hx)\\:(\\d+)\\:",
"name": "Jive",
"shell_cmd": "haxelib run jive test -debug",
"working_dir": "${project_path:${folder}}/jive/tests"
}
Upvotes: 0
Reputation: 739
Apart from the accepted answer you can also define project specific build systems within your .sublime-project file
"build_systems":
[
{
"name": "my-build",
"cmd": ["haxe", "${project_path}/path/to/build.hxml"],
"working_dir": "${project_path}/path/to/main/class"
}
]
This has the advantage that if you add the working_dir like above you don't need to open your main class file to build the project. And you can easily move the build.hxml to another folder.
Upvotes: 0
Reputation: 4430
Just create a build.hxml
file at the root of your project. Put all the compilation settings in there as you described above and use CTRL+ENTER
to compile. You can have multiple hxml
files if you need to compile to multiple targets or chain several compilation procedures in the same build file. Also the file will be used for autocompletion.
Upvotes: 1