Need help with configuring HashLink Debugger for vscode

I was having a series of issues in getting the HashLink debugger set up, with errors similar to what @gpstudios_tom mentioned (not finding lime.hdll, not finding ApplicationMain.hl, inability to load “default” asset library, etc).

I look forward to when the debugger no longer needs an hxml file to run, but in the meantime, I managed to throw together a PowerShell script that seems to accomplish what @Gama11 suggested through automation.

I store the script Copy-Hxml.ps1 in the .vscode directory with the following contents:

# Run from the project root directory (not .vscode folder)

Get-Content ./Export/hl/haxe/debug.hxml |
ForEach-Object {
    If ($_ -match '\w:[\\/]') {
        $_
    }
    Else {
        $fullPath = Join-Path -Path (Get-Location) -ChildPath ($_ -replace '-\w{2}\s', '')
        $_ -replace '(-\w{2}\s).*', ('$1' + $fullPath)
    }
} |
Set-Content ./Export/hl/haxe/debugAbsolutePath.hxml

My tasks.json looks like this:

{
    "version": "2.0.0",
    "tasks": [
        // Other tasks
        {
            "label": "Copy HXML",
            "type": "shell",
            "command": "${workspaceFolder}/.vscode/Copy-Hxml.ps1"
        }
    ]
}

And finally my launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "HashLink",
            "type": "hl",
            "request": "launch",
            "hl": "C:/HaxeToolkit/hl-1.10.0-win/hl.exe",
            "cwd": "${workspaceFolder}/Export/hl/bin",
            "hxml": "${workspaceFolder}/Export/hl/haxe/debugAbsolutePath.hxml",
            "preLaunchTask": "Copy HXML"
        }
    ]
}

Now, regardless of how the debug.hxml file looks when OpenFL builds it, any argument of the form -\w{2} will be modified to use an absolute file path. (I needed the generic regex to find both -cp and -hl.)

I will definitely be refactoring this hack to be more extensible and generic (the regex bit is embarrassingly inelegant), but I wanted to document my progress online before I drifted away to other projects.

Hope this helps someone!

1 Like