Skip to content

Fix regression in overriding remapped debug configuration data via debug_custom.json #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 5, 2024
Merged
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
14 changes: 12 additions & 2 deletions src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ async function mergeLaunchConfig(
(config) => config.configId === configId
);
const name = createName(board, programmer);
const launchConfig = {
// Create base configuration data
let launchConfig = {
configId,
cwd: '${workspaceRoot}',
request: 'launch',
Expand All @@ -315,17 +316,26 @@ async function mergeLaunchConfig(
...(debugInfo.customConfigs
? debugInfo.customConfigs[cortexDebug] ?? {}
: {}),
...(customConfig ? customConfig : {}),
name,
};

// Remap Arduino CLI debug config properties to launch.json keys
replaceValue('serverPath', 'serverpath', launchConfig);
replaceValue('server', 'servertype', launchConfig);
replaceValue('toolchainPath', 'armToolchainPath', launchConfig);
replaceValue('serverConfiguration.scripts', 'configFiles', launchConfig);
// Remove unused Arduino CLI debug config data
unsetValue(launchConfig, 'customConfigs');
unsetValue(launchConfig, 'serverConfiguration');
unsetValue(launchConfig, 'programmer'); // The programmer is not used by the debugger https://github.com/arduino/arduino-cli/pull/2391
unsetValue(launchConfig, 'toolchain'); // The toolchain is also unused by IDE2 or the cortex-debug VSIX

// Merge configuration from debug_custom.json
launchConfig = {
...launchConfig,
...(customConfig ? customConfig : {}),
};

return launchConfig;
}

Expand Down
35 changes: 31 additions & 4 deletions src/test/suite/debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,27 @@ describe('debug', () => {
const actual = await mergeLaunchConfig(
board,
programmer,
{ executable },
[{ configId, cwd: 'alma' }]
{
executable,
toolchainPrefix: 'toolchain-prefix',
serverPath: 'path/to/server',
server: 'openocd',
toolchainPath: 'path/to/toolchain',
serverConfiguration: {
scripts: ['path/to/config-file'],
},
},
[
{
configId,
cwd: 'alma',
toolchainPrefix: 'custom-toolchain-prefix',
serverpath: '/path/to/custom-server',
servertype: 'jlink',
armToolchainPath: '/path/to/custom-arm-toolchain',
configFiles: ['/path/to/custom-config'],
},
]
);
assert.deepStrictEqual(actual, {
configId,
Expand All @@ -154,6 +173,11 @@ describe('debug', () => {
name: 'ABC (p1)',
request: 'launch',
type: 'cortex-debug',
toolchainPrefix: 'custom-toolchain-prefix',
serverpath: '/path/to/custom-server',
servertype: 'jlink',
armToolchainPath: '/path/to/custom-arm-toolchain',
configFiles: ['/path/to/custom-config'],
});
});

Expand Down Expand Up @@ -230,8 +254,11 @@ describe('debug', () => {
const actual = await mergeLaunchConfig(
board,
programmer,
{ executable },
[{ configId, [key]: value }]
{
executable,
[key]: value,
},
[]
);
assert.deepStrictEqual(actual, expected);
})
Expand Down