diff --git a/vscode-wpilib/src/cpp/deploydebug.ts b/vscode-wpilib/src/cpp/deploydebug.ts index e3976d19..ed4e51f7 100644 --- a/vscode-wpilib/src/cpp/deploydebug.ts +++ b/vscode-wpilib/src/cpp/deploydebug.ts @@ -10,8 +10,8 @@ import { IUnixSimulateCommands, startUnixSimulation } from './simulateunix'; import { IWindowsSimulateCommands, startWindowsSimulation } from './simulatewindows'; interface ICppDebugInfo { - debugfile: string; - artifact: string; + name: string; + path: string; } interface ICppSimExtensions { @@ -26,7 +26,7 @@ interface ICppSimulateInfo { extensions: ICppSimExtensions[]; launchfile: string; clang: boolean; - env?: Map; + environment?: Map; srcpaths: string[]; headerpaths: string[]; libpaths: string[]; @@ -34,18 +34,16 @@ interface ICppSimulateInfo { } interface ICppDebugCommand { - name?: string; - extensions: string; - clang?: boolean; - launchfile: string; + type: string; + name: string; + port: number; target: string; + launchfile: string; gdb: string; - env?: Map; - sysroot: string | null; + sysroot: string | undefined; srcpaths: string[]; headerpaths: string[]; libpaths: string[]; - debugpaths: string[]; libsrcpaths: string[]; } @@ -91,10 +89,10 @@ class DebugCodeDeployer implements ICodeDeployer { return false; } - const debugInfo = await readFileAsync(path.join(workspace.uri.fsPath, 'build', 'debug', 'debuginfo.json'), 'utf8'); + const debugInfo = await readFileAsync(path.join(workspace.uri.fsPath, 'build', 'debug', 'debug_info.json'), 'utf8'); const parsedDebugInfo: ICppDebugInfo[] = jsonc.parse(debugInfo) as ICppDebugInfo[]; if (parsedDebugInfo.length === 0) { - await vscode.window.showInformationMessage('No debug configurations found. Is this a robot project?', { + await vscode.window.showInformationMessage('No target configurations found. Is this a robot project?', { modal: true, }); return false; @@ -103,22 +101,46 @@ class DebugCodeDeployer implements ICodeDeployer { if (parsedDebugInfo.length > 1) { const arr: CppQuickPick[] = []; for (const i of parsedDebugInfo) { - arr.push(new CppQuickPick(i, i.artifact)); + arr.push(new CppQuickPick(i, i.name)); } const picked = await vscode.window.showQuickPick(arr, { - placeHolder: 'Select an artifact', + placeHolder: 'Select a target', }); if (picked === undefined) { - vscode.window.showInformationMessage('Artifact cancelled'); + vscode.window.showInformationMessage('Target cancelled'); return false; } targetDebugInfo = picked.debugInfo; } - const debugPath = path.join(workspace.uri.fsPath, 'build', 'debug', targetDebugInfo.debugfile); + const debugPath = targetDebugInfo.path; const targetReadInfo = await readFileAsync(debugPath, 'utf8'); - const targetInfoParsed: ICppDebugCommand = jsonc.parse(targetReadInfo) as ICppDebugCommand; + const targetInfoArray: ICppDebugCommand[] = jsonc.parse(targetReadInfo) as ICppDebugCommand[]; + + if (targetInfoArray.length === 0) { + await vscode.window.showInformationMessage('No debug configurations found. Is this a robot project?', { + modal: true, + }); + return false; + } + + // TODO Filter this off of type + let targetInfoParsed = targetInfoArray[0]; + if (targetInfoArray.length > 1) { + const arr: CppQuickPick[] = []; + for (const i of targetInfoArray) { + arr.push(new CppQuickPick(i, i.name)); + } + const picked = await vscode.window.showQuickPick(arr, { + placeHolder: 'Select an artifact', + }); + if (picked === undefined) { + vscode.window.showInformationMessage('Artifact cancelled'); + return false; + } + targetInfoParsed = picked.debugInfo; + } const set = new Set(targetInfoParsed.libpaths); @@ -132,7 +154,7 @@ class DebugCodeDeployer implements ICodeDeployer { let sysroot = ''; - if (targetInfoParsed.sysroot !== null) { + if (targetInfoParsed.sysroot !== undefined) { sysroot = targetInfoParsed.sysroot; } @@ -147,7 +169,7 @@ class DebugCodeDeployer implements ICodeDeployer { soLibPath: soPath, srcPaths: new Set(srcArrs), sysroot, - target: targetInfoParsed.target, + target: targetInfoParsed.target + ':' + targetInfoParsed.port.toString(10), workspace, }; @@ -291,7 +313,7 @@ class SimulateCodeDeployer implements ICodeDeployer { const config: IUnixSimulateCommands = { clang: targetSimulateInfo.clang, - environment: targetSimulateInfo.env, + environment: targetSimulateInfo.environment, executablePath: targetSimulateInfo.launchfile, extensions, ldPath: path.dirname(targetSimulateInfo.launchfile), // gradle puts all the libs in the same dir as the executable @@ -305,7 +327,7 @@ class SimulateCodeDeployer implements ICodeDeployer { } else { const config: IWindowsSimulateCommands = { debugPaths: targetSimulateInfo.libpaths, - environment: targetSimulateInfo.env, + environment: targetSimulateInfo.environment, extensions, launchfile: targetSimulateInfo.launchfile, srcPaths: targetSimulateInfo.srcpaths, diff --git a/vscode-wpilib/src/java/deploydebug.ts b/vscode-wpilib/src/java/deploydebug.ts index f790e718..7b094a27 100644 --- a/vscode-wpilib/src/java/deploydebug.ts +++ b/vscode-wpilib/src/java/deploydebug.ts @@ -9,14 +9,16 @@ import { IDebugCommands, startDebugging } from './debug'; import { ISimulateCommands, startSimulation } from './simulate'; interface IJavaDebugInfo { - debugfile: string; - project: string; - artifact: string; + name: string; + path: string; } interface ITargetInfo { - ipAddress: string; - port: string; + type: string; + name: string; + port: number; + target: string; + project: string; } interface IJavaSimExtensions { @@ -29,7 +31,7 @@ interface IJavaSimulateInfo { name: string; type: string; extensions: IJavaSimExtensions[]; - env?: Map; + environment?: Map; libraryDir: string; mainClassName: string; } @@ -79,7 +81,7 @@ class DebugCodeDeployer implements ICodeDeployer { return false; } - const debugInfo = await readFileAsync(path.join(workspace.uri.fsPath, 'build', 'debug', 'debuginfo.json'), 'utf8'); + const debugInfo = await readFileAsync(path.join(workspace.uri.fsPath, 'build', 'debug', 'debug_info.json'), 'utf8'); const parsedDebugInfo: IJavaDebugInfo[] = jsonc.parse(debugInfo) as IJavaDebugInfo[]; if (parsedDebugInfo.length === 0) { await vscode.window.showInformationMessage('No debug configurations found. Is this a robot project?', { @@ -91,27 +93,51 @@ class DebugCodeDeployer implements ICodeDeployer { if (parsedDebugInfo.length > 1) { const arr: JavaQuickPick[] = []; for (const i of parsedDebugInfo) { - arr.push(new JavaQuickPick(i, i.artifact)); + arr.push(new JavaQuickPick(i, i.name)); } const picked = await vscode.window.showQuickPick(arr, { - placeHolder: 'Select an artifact', + placeHolder: 'Select a target', }); if (picked === undefined) { - vscode.window.showInformationMessage('Artifact cancelled'); + vscode.window.showInformationMessage('Target cancelled'); return false; } targetDebugInfo = picked.debugInfo; } - const debugPath = path.join(workspace.uri.fsPath, 'build', 'debug', targetDebugInfo.debugfile); + const debugPath = targetDebugInfo.path; const targetReadInfo = await readFileAsync(debugPath, 'utf8'); - const targetInfoParsed = jsonc.parse(targetReadInfo) as ITargetInfo; + const targetInfoArray = jsonc.parse(targetReadInfo) as ITargetInfo[]; + + if (targetInfoArray.length === 0) { + await vscode.window.showInformationMessage('No debug configurations found. Is this a robot project?', { + modal: true, + }); + return false; + } + + // TODO Filter this off of type + let targetInfoParsed = targetInfoArray[0]; + if (targetInfoArray.length > 1) { + const arr: JavaQuickPick[] = []; + for (const i of targetInfoArray) { + arr.push(new JavaQuickPick(i, i.name)); + } + const picked = await vscode.window.showQuickPick(arr, { + placeHolder: 'Select an artifact', + }); + if (picked === undefined) { + vscode.window.showInformationMessage('Artifact cancelled'); + return false; + } + targetInfoParsed = picked.debugInfo; + } const config: IDebugCommands = { - project: targetDebugInfo.project, - serverAddress: targetInfoParsed.ipAddress, - serverPort: targetInfoParsed.port, + project: targetInfoParsed.project, + serverAddress: targetInfoParsed.target, + serverPort: targetInfoParsed.port.toString(10), workspace, }; @@ -246,7 +272,7 @@ class SimulateCodeDeployer implements ICodeDeployer { } const config: ISimulateCommands = { - environment: targetSimulateInfo.env, + environment: targetSimulateInfo.environment, extensions, librarydir: targetSimulateInfo.libraryDir, mainclass: targetSimulateInfo.mainClassName,