Tasks.json compiler arguments

Hi all,

I am trying to pass compiler flags (like -debug) in Visual Studio Code by using the default tasks file, but nothing seems to work. Any advice?

Thanks!

You can’t modify the arguments of tasks auto-generated by the Haxe extension in tasks.json. But you can define a new “configuration” in settings.json:

"haxe.configurations": [
	["build.hxml", "-debug"]
]

This can then be run as a task with the haxe: active configuration task (once the config is selected).

1 Like

Thanks for replying! I got this:

"settings": 
{
	"haxe.configurations":
	[
		["build.hxml", "-debug"]
	]
}

And we have this tasks.json

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "hxml",
			"file": "build.hxml",
			"group": {
				"kind": "build",
				"isDefault": true
			}
		}
	]
}

Doing this add a configuration option in the bottom of VSC, but it does not actually add the debug compiler flag.

As I said, you would want to use the active configuration task:

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "haxe",
			"args": "active configuration",
			"group": {
				"kind": "build",
				"isDefault": true
			}
		}
	]
}

(putting it in tasks.json doesn’t really do anything beyond allowing you to run it directly with your “Run Build Task” shortcut, you can always open the full list of auto-generated tasks via Terminal → Run Task, even when you don’t have a tasks.json)

1 Like

Wow I completely missed that… Somehow it still feels a bit mysterious how these tasks work in VSC.

Thanks a million :smiley:

Something that confuses a lot of people is that you can’t create tasks of type "haxe" / "hxml" in a tasks.json (or any type that is created by an extension). These tasks already exist.

The only thing you can do with those in tasks.json is configuring / customizing them, for instance in this example, marking one as the default build task with the group property.