vscode how to select which project is being used in a multi-project workspace (not multi-config) set up?

uC_Jon
Posts: 18
Joined: Fri Jan 05, 2024 7:03 pm

vscode how to select which project is being used in a multi-project workspace (not multi-config) set up?

Postby uC_Jon » Tue Jul 23, 2024 10:22 am

I want/like to layout my projects/components in a way similar to the following (please note, the exact structure is immaterial and subject to change!):

Code: Select all

component_dir/
    examples/
        .vscode/
        main/
            example_source_code.c
            CMakeLists.txt
        CMakeLists.txt (project)
    component_source.c
    CMakeLists.txt
    idf_component.yml
    test/
        component_source_test.c
        CMakeLists.txt
    test_runner/
        test_runner.c
        CMakeLists.txt (project)
When working on the command line this all kind works. I can move into the test_runner/ directory and compile the unit testing project or move into the examples directory and compile that project. The build directories get created under test_runner/ and examples/ respectively.

In vscode I create a workspace file with the following:

Code: Select all

{
	"folders": [
		{
			"path": "./examples"
		},
		{
			"path": "./test_runner"
		},
		{
			"path": "."
		},
	],
}
The issue I'm having is that I can't find a way to associate the esp-idf with the workspace subfolder folder I'm in. It seems to take the first folder and only work on that one. So clicking on build defaults to the first path (./examples).

There doesn't seem to be a way to tell esp-idf that I wish to perform a build in ./test_runner which seems really odd (or more likely I'm missing something)

So the question is, how to I tell IDF that I have multiple projects (subfolders) and I wish to build a specific one (or potentially a group of them, not "." because that contains no CMakeLists.txt project file and must be included in a real project that uses that component).

I've looked at the on-line documentation(1), and the ESP-IDF Project Configuration option but while that can specify a build directory it doesn't have anything to say which project folder is to be used as the project.

(1) https://github.com/espressif/vscode-esp ... ROJECTS.md which seems to outline what I have already done, but still doesn't tell me what I need to do to make the vscode extension select the project I wish to compile.

I can work on the component code itself (within the ".") because when it compiles the /examples code it pulls in the code from there... but I have to go to the command line if I wish to compile the test_runner code which also pulls in the "." code and the "test/" code which is not specifically added to the workspace file (I can drill down to it via the ".").

I have tried adding a .vscode/ and files to both examples/ and test_runner/ but that doesn't seem to do anything.

I also had to put "C_Cpp.default.compileCommands": "${workspaceFolder:examples}/build/compile_commands.json", into the user level settings.json (Note the :examples) otherwise code in "." would syntax error because obviously the build files were in /examples/build/

Any help would be much appreciated, even if its to say that its not currently possible and that I'll have to use the command line.

uC_Jon
Posts: 18
Joined: Fri Jan 05, 2024 7:03 pm

Re: vscode how to select which project is being used in a multi-project workspace (not multi-config) set up?

Postby uC_Jon » Fri Jul 26, 2024 10:18 am

For the record in case others have a similar issue...

It was staring me right in the face all along :shock: !

The "project" in a multi-folder/multi-project workspace can be selected by either pressing the little folder icon, in front of the setting/clean/build icons, in the task bar (ESP-IDF Current Project /...) or by the usual ctl+shift+P or F1 and then typing "ESP-IDF: Pick a Workspace Folder".

The https://github.com/espressif/vscode-esp ... ROJECTS.md document even states it within the first few lines of text :roll:. I have read that document multiple times, getting more and more frustrated that I couldn't figure out how to do what I wanted. And it was right there on the 13th and 14 line of text! :oops:

Who is online

Users browsing this forum: No registered users and 407 guests