-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01e16ec
commit d64c530
Showing
7 changed files
with
172 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Project: ESP-IDF VSCode Extension | ||
* File Created: Monday, 26th February 2024 2:54:26 pm | ||
* Copyright 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { | ||
CancellationToken, | ||
DebugConfiguration, | ||
DebugConfigurationProvider, | ||
WorkspaceFolder, | ||
} from "vscode"; | ||
import { readParameter } from "../idfConfiguration"; | ||
import { getProjectName } from "../workspaceConfig"; | ||
import { join } from "path"; | ||
import { pathExists } from "fs-extra"; | ||
import { verifyAppBinary } from "../espIdf/debugAdapter/verifyApp"; | ||
import { OpenOCDManager } from "../espIdf/openOcd/openOcdManager"; | ||
import { Logger } from "../logger/logger"; | ||
|
||
export class CDTDebugConfigurationProvider | ||
implements DebugConfigurationProvider { | ||
public async resolveDebugConfiguration( | ||
folder: WorkspaceFolder | undefined, | ||
config: DebugConfiguration, | ||
token?: CancellationToken | ||
): Promise<DebugConfiguration> { | ||
try { | ||
if (!config.program) { | ||
const buildDirPath = readParameter("idf.buildPath", folder) as string; | ||
const projectName = await getProjectName(buildDirPath); | ||
const elfFilePath = join(buildDirPath, `${projectName}.elf`); | ||
const elfFileExists = await pathExists(elfFilePath); | ||
if (!elfFileExists) { | ||
throw new Error( | ||
`${elfFilePath} doesn't exist. Build this project first.` | ||
); | ||
} | ||
} | ||
if (folder && folder.uri && config.verifyAppBinBeforeDebug) { | ||
const isSameAppBinary = await verifyAppBinary(folder.uri); | ||
if (!isSameAppBinary) { | ||
throw new Error( | ||
`Current app binary is different from your project. Flash first.` | ||
); | ||
} | ||
} | ||
const openOCDManager = OpenOCDManager.init(); | ||
if (!openOCDManager.isRunning()) { | ||
await openOCDManager.start(); | ||
} | ||
} catch (error) { | ||
const msg = error.message | ||
? error.message | ||
: "Some build files doesn't exist. Build this project first."; | ||
Logger.error(error.message, error); | ||
} | ||
return config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters