Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@
"description": "full path to executable.",
"default": "${workspaceFolder}/bin/yourExecutable.exe"
},
"cwd": {
"type": "string",
"description": "working directory for the executable",
"default": "${workspaceFolder}"
},
"args": {
"type": "array",
"description": "arguments for the executable",
"default": []
},
"receiveAdapterOutput": {
"type": "boolean",
"description": "redirect adapter log to debug console",
Expand Down
8 changes: 6 additions & 2 deletions src/Adapter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import hxcpp.debug.jsonrpc.Protocol;

typedef HxppLaunchRequestArguments = LaunchRequestArguments & {
var program:String;
var ?cwd:String;
var ?args:Array<String>;
}

@:keep
Expand Down Expand Up @@ -52,6 +54,8 @@ class Adapter extends DebugSession {
override function launchRequest(response:LaunchResponse, args:LaunchRequestArguments) {
var args:HxppLaunchRequestArguments = cast args;
var executable = args.program;
var arguments = args.args;
var cwd = args.cwd;

function onConnected(socket) {
trace("Debug server connected!");
Expand All @@ -72,8 +76,8 @@ class Adapter extends DebugSession {

var server = Net.createServer(onConnected);
server.listen(6972, function() {
var args = [];
var haxeProcess = ChildProcess.spawn(executable, args, {stdio: Pipe, cwd: haxe.io.Path.directory(executable)});
var haxeProcess = ChildProcess.spawn(executable, arguments != null ? arguments : [],
{stdio: Pipe, cwd: cwd != null ? cwd : haxe.io.Path.directory(executable)});
haxeProcess.stdout.on(ReadableEvent.Data, onStdout);
haxeProcess.stderr.on(ReadableEvent.Data, onStderr);
haxeProcess.on(ChildProcessEvent.Exit, onExit);
Expand Down