diff --git a/README.md b/README.md index 60868c3c..ef529aec 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,21 @@ This extension provides the following settings: * `raspberry-pi-pico.gitPath`: Specify a custom path for Git. * `raspberry-pi-pico.cmakeAutoConfigure`: Provide a GitHub personal access token (classic) with the `public_repo` scope. This token is used to check for available versions of the Pico SDK and other tools. Without it, the extension uses the unauthenticated GitHub API, which has a lower rate limit and may lead to restricted functionality if the limit is exceeded. The unauthenticated rate limit is per public IP address, so a token is more necessary if your IP is shared with many users. +## CMake Tools Extension Integration + +For more complex projects, such as those with multiple executables or when the project name is defined as a variable, this extension can integrate with the CMake Tools extension to enhance CMake parsing. You can enable CMake Tools integration during project generation under the **Advanced Options**. Additionally, to manually enable it, adjust the following settings in your `settings.json`: + +- `raspberry-pi-pico.cmakeAutoConfigure`: Set from `true` to `false`. +- `raspberry-pi-pico.useCmakeTools`: Set from `false` to `true`. + +For optimal functionality, consider enabling: + +- `cmake.configureOnEdit`: true +- `cmake.automaticReconfigure`: true +- `cmake.configureOnOpen`: true + +When prompted, select the `Pico` kit in CMake Tools, and set your build and launch targets accordingly. Use CMake Tools for compilation, but continue using this extension for debugging, as CMake Tools debugging is not compatible with Pico. + ## VS Code Profiles If you work with multiple microcontroller toolchains, consider installing this extension into a [VS Code Profile](https://code.visualstudio.com/docs/editor/profiles) to avoid conflicts with other toolchains. Follow these steps: diff --git a/scripts/pico_project.py b/scripts/pico_project.py index 0f426b1c..8bd0cb94 100644 --- a/scripts/pico_project.py +++ b/scripts/pico_project.py @@ -483,6 +483,7 @@ def ParseCommandLine(): parser.add_argument("-cupy", "--customPython", action='store_true', help="Custom python path used to execute the script.") parser.add_argument("-openOCDVersion", "--openOCDVersion", help="OpenOCD version to use - defaults to 0", default=0) parser.add_argument("-examLibs", "--exampleLibs", action='append', help="Include an examples library in the folder") + parser.add_argument("-ucmt", "--useCmakeTools", action='store_true', help="Enable CMake Tools extension integration") return parser.parse_args() @@ -765,7 +766,7 @@ def GenerateCMake(folder, params): # Generates the requested project files, if any -def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger, sdkVersion, toolchainVersion, picotoolVersion, ninjaPath, cmakePath, customPython, openOCDVersion): +def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger, sdkVersion, toolchainVersion, picotoolVersion, ninjaPath, cmakePath, customPython, openOCDVersion, useCmakeTools): oldCWD = os.getcwd() @@ -929,9 +930,9 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger, "statusBarVisibility": "hidden" }} }}, - "cmake.configureOnEdit": false, - "cmake.automaticReconfigure": false, - "cmake.configureOnOpen": false, + "cmake.configureOnEdit": {"true" if useCmakeTools else "false"}, + "cmake.automaticReconfigure": {"true" if useCmakeTools else "false"}, + "cmake.configureOnOpen": {"true" if useCmakeTools else "false"}, "cmake.generator": "Ninja", "cmake.cmakePath": "{cmakePath.replace(user_home, "${userHome}") if use_home_var else cmakePath}", "C_Cpp.debugShortcut": false, @@ -965,8 +966,8 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger, {os.path.dirname(ninjaPath.replace(user_home, "${env:HOME}") if use_home_var else ninjaPath)}:\ ${{env:PATH}}" }}, - "raspberry-pi-pico.cmakeAutoConfigure": true, - "raspberry-pi-pico.useCmakeTools": false, + "raspberry-pi-pico.cmakeAutoConfigure": {"false" if useCmakeTools else "true"}, + "raspberry-pi-pico.useCmakeTools": {"true" if useCmakeTools else "false"}, "raspberry-pi-pico.cmakePath": "{cmakePath.replace(user_home, "${HOME}") if use_home_var else cmakePath}", "raspberry-pi-pico.ninjaPath": "{ninjaPath.replace(user_home, "${HOME}") if use_home_var else ninjaPath}"''' @@ -1236,7 +1237,8 @@ def DoEverything(parent, params): params["ninjaPath"], params["cmakePath"], params["customPython"], - params["openOCDVersion"]) + params["openOCDVersion"], + params['useCmakeTools']) if params['wantBuild']: os.system(makeCmd) @@ -1360,7 +1362,8 @@ def DoEverything(parent, params): 'cmakePath' : args.cmakePath, 'customPython' : args.customPython, 'openOCDVersion': args.openOCDVersion, - 'exampleLibs' : args.exampleLibs if args.exampleLibs is not None else [] + 'exampleLibs' : args.exampleLibs if args.exampleLibs is not None else [], + 'useCmakeTools' : args.useCmakeTools } DoEverything(None, params) diff --git a/src/webview/newProjectPanel.mts b/src/webview/newProjectPanel.mts index 85d9bb82..4eed11c2 100644 --- a/src/webview/newProjectPanel.mts +++ b/src/webview/newProjectPanel.mts @@ -82,6 +82,7 @@ interface ImportProjectMessageValue { // debugger debugger: number; + useCmakeTools: boolean; } interface SubmitExampleMessageValue extends ImportProjectMessageValue { @@ -268,6 +269,7 @@ interface ImportProjectOptions { ninjaExecutable: string; cmakeExecutable: string; debugger: Debugger; + useCmakeTools: boolean; } interface NewExampleBasedProjectOptions extends ImportProjectOptions { @@ -1123,6 +1125,7 @@ export class NewProjectPanel { }, ninjaExecutable, cmakeExecutable, + useCmakeTools: data.useCmakeTools, }; await this._executePicoProjectGenerator( @@ -1147,6 +1150,7 @@ export class NewProjectPanel { }, ninjaExecutable, cmakeExecutable, + useCmakeTools: data.useCmakeTools, }; await this._executePicoProjectGenerator( @@ -1168,6 +1172,7 @@ export class NewProjectPanel { ninjaExecutable, cmakeExecutable, debugger: data.debugger === 1 ? Debugger.swd : Debugger.debugProbe, + useCmakeTools: data.useCmakeTools, }; await this._executePicoProjectGenerator( @@ -1987,18 +1992,30 @@ export class NewProjectPanel { ` : "" } -