Skip to content

Commit ce76541

Browse files
authored
Only show tool warning if trying to use built-in tools (#409)
* only show tool warning if trying to use built-in --------- Signed-off-by: Jens Reinecke <jens.reinecke@arm.com>
1 parent 96bc681 commit ce76541

5 files changed

Lines changed: 44 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## Unreleased
4+
5+
- Fixes [#407](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/issues/407): Warning pops up when using an absolute path in the launch config.
6+
37
## 0.5.0
48

59
- **IMPORTANT**: This release updates the [license](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/blob/main/LICENSE) for the CMSIS Debugger extension from `Apache License 2.0` to `Apache License 2.0 and GNU General Public License v3.0 or later`.

src/debug-configuration/gdbtarget-configuration-provider.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
JlinkConfigurationProvider
2525
} from './subproviders';
2626
import { BuiltinToolPath } from '../desktop/builtin-tool-path';
27+
import { resolveToolPath } from '../desktop/tool-path-utils';
2728

2829
const GDB_TARGET_DEBUGGER_TYPE = 'gdbtarget';
2930
const ARM_NONE_EABI_GDB_NAME = 'arm-none-eabi-gdb';
@@ -139,19 +140,8 @@ export class GDBTargetConfigurationProvider implements vscode.DebugConfiguration
139140
): Promise<vscode.DebugConfiguration | null | undefined> {
140141
// Only resolve GDB path once, otherwise regexp check will fail
141142
logger.debug('resolveDebugConfigurationWithSubstitutedVariables: Resolve GDB path');
142-
this.resolveGdbPath(debugConfiguration);
143+
debugConfiguration.gdb = resolveToolPath(debugConfiguration.gdb, ARM_NONE_EABI_GDB_NAME, ARM_NONE_EABI_GDB_EXECUTABLE_ONLY_REGEXP, this.builtinArmNoneEabiGdb);
143144
return this.resolveDebugConfigurationByResolverType('resolveDebugConfigurationWithSubstitutedVariables', folder, debugConfiguration, token);
144145
}
145146

146-
protected resolveGdbPath(config: GDBTargetConfiguration): void {
147-
const gdb = config.gdb;
148-
const useBuiltin = !gdb || ARM_NONE_EABI_GDB_EXECUTABLE_ONLY_REGEXP.test(gdb);
149-
const updateUri = useBuiltin ? this.builtinArmNoneEabiGdb.getAbsolutePath() : undefined;
150-
if (updateUri) {
151-
config.gdb = updateUri.fsPath;
152-
} else {
153-
vscode.window.showWarningMessage(`Cannot find ${ARM_NONE_EABI_GDB_BUILTIN_PATH} in CMSIS Debugger installation.\nUsing ${ARM_NONE_EABI_GDB_NAME} from PATH instead.`);
154-
}
155-
}
156-
157147
}

src/debug-configuration/subproviders/pyocd-configuration-provider.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import * as vscode from 'vscode';
1817
import { BaseConfigurationProvider } from './base-configuration-provider';
1918
import { GDBTargetConfiguration, TargetConfiguration } from '../gdbtarget-configuration';
2019
import { BuiltinToolPath } from '../../desktop/builtin-tool-path';
2120
import { getCmsisPackRootPath } from '../../utils';
2221
import { logger } from '../../logger';
22+
import { resolveToolPath } from '../../desktop/tool-path-utils';
2323

2424
const PYOCD_NAME = 'pyocd';
2525
const PYOCD_BUILTIN_PATH = 'tools/pyocd/pyocd';
@@ -33,17 +33,6 @@ const PYOCD_CLI_ARG_CBUILDRUN = '--cbuild-run';
3333
export class PyocdConfigurationProvider extends BaseConfigurationProvider {
3434
protected builtinPyocd = new BuiltinToolPath(PYOCD_BUILTIN_PATH);
3535

36-
protected resolveServerPath(target: TargetConfiguration): void {
37-
const targetServer = target.server;
38-
const useBuiltin = !targetServer || PYOCD_EXECUTABLE_ONLY_REGEXP.test(targetServer);
39-
const updateUri = useBuiltin ? this.builtinPyocd.getAbsolutePath() : undefined;
40-
if (updateUri) {
41-
target.server = updateUri.fsPath;
42-
} else {
43-
vscode.window.showWarningMessage(`Cannot find ${PYOCD_BUILTIN_PATH} in CMSIS Debugger installation.\nUsing ${PYOCD_NAME} from PATH instead.`);
44-
}
45-
}
46-
4736
protected resolveCmsisPackRootPath(target: TargetConfiguration): void {
4837
if (target.environment?.CMSIS_PACK_ROOT) {
4938
return;
@@ -59,7 +48,7 @@ export class PyocdConfigurationProvider extends BaseConfigurationProvider {
5948
return debugConfiguration;
6049
}
6150
// server
62-
this.resolveServerPath(debugConfiguration.target);
51+
debugConfiguration.target.server = resolveToolPath(debugConfiguration.target.server, PYOCD_NAME, PYOCD_EXECUTABLE_ONLY_REGEXP, this.builtinPyocd);
6352
// serverParameters
6453
debugConfiguration.target.serverParameters ??= [];
6554
const parameters = debugConfiguration.target.serverParameters;

src/desktop/builtin-tool-path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { isWindows } from '../utils';
2222
import assert from 'assert';
2323

2424
export class BuiltinToolPath {
25-
constructor(protected toolPath: string) {
25+
constructor(public readonly toolPath: string) {
2626
assert(toolPath.length, 'BuiltinToolManager: \'toolPath\' must not be empty');
2727
}
2828

src/desktop/tool-path-utils.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright 2025 Arm Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import * as vscode from 'vscode';
18+
import { BuiltinToolPath } from './builtin-tool-path';
19+
20+
export const resolveToolPath = (toolpath: string | undefined, toolName: string, toolRegexp: RegExp, builtInTool: BuiltinToolPath): string => {
21+
const useBuiltin = !toolpath || toolRegexp.test(toolpath);
22+
if (!useBuiltin) {
23+
// Leave as is
24+
return toolpath;
25+
}
26+
const updateUri = builtInTool.getAbsolutePath();
27+
if (!updateUri) {
28+
const warnMessage =
29+
`Cannot find './${builtInTool.toolPath}' in CMSIS Debugger extension installation.\n`
30+
+ `Using '${toolName}' from PATH instead.`;
31+
vscode.window.showWarningMessage(warnMessage);
32+
return toolName;
33+
}
34+
return updateUri.fsPath;
35+
};

0 commit comments

Comments
 (0)