This Template is designed to ease programming with HaxeLang in Visual Studio Code.
It uses the VSCode Extension Legacy Haxe by Haxe Devs.
For this to work, this Template assumes you to install all recommended extensions, so everything 'just runs'.
Also you can extend it by upcomming haxelib language extensions, by adding a line to the Build.hxml
file.
You can use npm to install our setup tool for the most convenient way.
- Predefined Tasks for a set of Targets. [Tasks]
- Per-Target Includes [Includes]
- easy to extend [Adding a Target]
- installable via npm [npm usage]
First of all (for the obvious) you need a working installation of Visual Studio Code. Also you will need:
If you are running Linux or Mac OS, Mono will be required for execution of some targets.
By default all Build Targets are enabled, so if you want to successfully compile, you might want to disable build targets.
If you want to run and debug PHP code, you will also need:
Please Note, that all referenced requirements might also require thirdparty software.
By default there are predifened Launch Configurations. Available Tasks are:
- Launch Compiled HAXE (AS)
- Launch Compiled HAXE (C++)
- Launch Compiled HAXE (C#)
- Launch Compiled HAXE (JAVA)
- Launch Compiled HAXE (JS)
- Launch Compiled HAXE (LUA)
- Launch Compiled HAXE (NEKO)
- Launch Compiled HAXE (PHP)
- Launch Compiled HAXE (PYTHON)
- Launch Compiled HAXE (SWF)
These Configurations will be run by NodeJS. Exceptions:
Also JS Task will be run in NodeJS since if you wanted to debug it, you should open it manually in a browser of your choice.
Every Target by default has a directory for target specific includes.
So if you need something included only for e.g. Java
you can put it in targets/java/
folder in your workspace root.
These files will be automatically included by Haxe compiler.
To successfully use this Template you will need to some easy steps. Before we get into the "console stuff", we need to install Haxe and Visual Studio Code. After that we get into the console and install our haxe libraries we need for our desired targets.
E.g. for C# and java we need to type:
$ haxelib install hxcs
[...]
Done
$ haxelib install hxjava
[...]
Done
Yeah! That was easy, wasn't it?
Now you can close the console, we won't need it for the next steps.
We provide a npm package for you to install this template even more convenient.
To install the package run
npm install -g haxe-vsc-template
after that you can simply create a new project by typing
init_Haxe
<directory>
You can even omit <directory>
.
init_Haxe
then installs to your current working directory (cwd).
After installation of all requirements for your needs, we will now configure your workspace.
There isn't much to do, except for those who don't want to compile every target.
If you want to add a target, jump to section Adding a Target.
If you dont need or dont want a specific target simply disable it in targets.json
.
If you want to add a library to your target, jump to section Adding a Library to a Target.
Compilation takes place in ${WorkspaceRoot}/buld/<platform>/
So for example Compilation of JS
will be stored in ${WorkspaceRoot}/buld/js/
To add a build target, basically there is only to add it in a file named as your target + ".hxml" in directory hxml. If you want to add it like this Template does, do the following:
First open up hxml/<mytarget>.hxml
and add your target as following
# My Target
-cp targets/<mytarget>
-<target> build/<target>
save it and activate it by adding its name into targets.json
.
As you might have noticed, there isn't a targets/<mytarget>
directory in your workspace, so create it.
(Optional)
Now open up .vscode/launch.json
and add a new launch configuration.
{
"name": "Launch compiled HAXE (<mytarget>)",
"type": "node",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/.vscode/runner.js",
"args": ["${workspaceRoot}/build/<mytarget>/<myexecutable>"],
"cwd": "${workspaceRoot}/build/<mytarget>/<basepath of executable>"
}
please change <myexecutable>
and <mytarget>
to your target.
If you want to use a library for your target, simply append it by editing your target file
(hxml/<mytarget>
)
# My Target
-cp targets/<mytarget>
-<target> build/<target>
-lib <mylib>
To disable a buld target, simply open your tagets.json
file on the root of your workspace
and comment out that target or remove that line completely.
[...]
"java",
[...]
[...]
//"java",
[...]
This Template is licensed under MIT Licens, a copy of it is contained in this Repository.
If you want to contribute to this repository, feel free to grab a fork and submit a pull request.
Also see Projects and Issues section for details about current bugs, todos, etc.
[1]: Since the compiled script will be executed in the CLI, you will need a proper installation of PHP in your PATH. Also you will need the PHP extension for VSCode.
[2]: the Taget is not supported to be run without thirdparty software, so it won't open.