Skip to content
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

Any reference to ${command:cmake.getLaunchTargetPath} will reconfigure after a cmake configure task #2878

Closed
trondhe opened this issue Dec 1, 2022 · 8 comments · Fixed by #3238
Assignees
Labels
bug a bug in the product Feature: tasks more info needed More info is needed from the community for us to properly triage and investigate.
Projects
Milestone

Comments

@trondhe
Copy link

trondhe commented Dec 1, 2022

Brief Issue Summary

Running a configure task such as

{
    "label": "cmake configure",
    "type": "cmake",
    "command": "configure",
    "preset": "${command:cmake.activeConfigurePresetName}",
},

to completion, build with

{
  "label": "cmake build",
  "type": "cmake",
  "command": "build",
  "preset": "${command:cmake.activeConfigurePresetName}",
  "targets": [
      "${command:cmake.buildTargetName}"
  ],
}

a follow up with

{
    "label": "cmake run target",
    "type": "shell",
    "command": "${command:cmake.getLaunchTargetPath}",
    "dependsOn": "cmake build",
},

will always reconfigure.

It seems that the command:cmake.<vars> state are not saved/fetched when using a cmake configure task. Such that the extension itself need to load it by doing a configure for itself.
Deleting the build folder, configuring, building and running the cmake run target task directly after this does not make it reconfigure a second time, which I guess perhaps is also wrong?
If one does Ctrl+shift+p -> Developer: Reload window after the project is fully configured and built, the cmake run target task will make the cmake tools extension reconfigure again.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

@bobbrow bobbrow added bug a bug in the product Feature: tasks labels Dec 2, 2022
@elahehrashedi
Copy link
Contributor

Thank you for reporting this issue. We will take a look into it.

@elahehrashedi elahehrashedi modified the milestones: On Deck, 1.14 Dec 2, 2022
@benmcmorran benmcmorran modified the milestones: 1.14, 1.15 Apr 20, 2023
@gcampbell-msft gcampbell-msft added this to Triage in 1.15 via automation Jul 5, 2023
@gcampbell-msft gcampbell-msft moved this from Triage to To do in 1.15 Jul 5, 2023
@gcampbell-msft
Copy link
Collaborator

@trondhe Following up on this. Are you still able to reproduce this issue? If so, could you please help us repro by providing an example/repro project?

Looking forward to investigating this.

@gcampbell-msft gcampbell-msft added the more info needed More info is needed from the community for us to properly triage and investigate. label Jul 10, 2023
@trondhe
Copy link
Author

trondhe commented Jul 11, 2023

I am not sure if something changed since last time, not sure it behaves quite the same as before. However there is still a common (to me) flow that often happens.
It seems to be problematic to me as vcpkg often forces reconfigures (a problem on its own outside of this of course). But it seems to be triggered via something this extension might be able to avoid I hope.

This order of sequence will always end up re-configuring twice for me:

  • Ensure an existing project configure step has been run
  • (Re)open vscode (or Developer: Reload Window from command palette)
  • Do any change that will trigger a reconfigure (edit cmake, vcpkg needs (aka in some cases even the path variable changed etc)
  • Run a "run binary shell command" using ${command:cmake.getLaunchTargetPath} that depends on a task of type cmake with buildas command
  • Now it reconfigures first on the terminal, and then another time in the extension before the build command is run and executed.

This simple project gives a reproducible setup running the _cmake run target task after the reload and a change that requires reconfigure has been applied

// .vscode/tasks.json
{
	"version": "2.0.0",
	"windows": {
		"options": {
			"shell": {
				"executable": "powershell.exe"
			}
		}
	},
	"tasks": [
		{
			"label": "_cmake configure",
			"type": "cmake",
			"command": "configure",
			"preset": "${command:cmake.activeConfigurePresetName}",
		},
		{
			"label": "_cmake build",
			"type": "cmake",
			"command": "build",
			"preset": "${command:cmake.activeConfigurePresetName}",
			"targets": [
				"${command:cmake.buildTargetName}"
			],
		},
		{
			"label": "_cmake run target",
			"type": "shell",
			"command": "${command:cmake.getLaunchTargetPath}",
			"dependsOn": "cmake build",
		},
	]
}
# CMakeLists.txt
cmake_minimum_required(VERSION 3.20)

project(test)

add_executable(mybin main.cpp)

set(seconds 3)
message("Intentionally sleeping for ${seconds} seconds to slow down configure step")
foreach(i RANGE 1 ${seconds})
    message("${i} sec")
    execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
endforeach()
// CMakePresets.json
{
    "version": 6,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 23,
        "patch": 0
    },
    "configurePresets": [
        {
            "name": "default",
            "displayName": "Default Config",
            "description": "Default build using Ninja generator",
            "generator": "Ninja",
            "binaryDir": "${sourceDir}/build/default"
        }
    ],
    "buildPresets": [
        {
            "name": "default",
            "configurePreset": "default"
        }
    ]
}
// main.cpp
#include <iostream>

int main() {
  std::cout << "Hello, World!\n";
  return 0;
}

@trondhe
Copy link
Author

trondhe commented Jul 11, 2023

More direct breakage which I think was my original problem:

Same initial steps to the problem

  • Have a configured build setup
  • Reopen or reload vscode
  • Edit a cmakelist file
  • run the task _cmake configure, it will now configure
  • run the task _cmake run target, it will now configure again

@gcampbell-msft
Copy link
Collaborator

@trondhe Do you have any automatic configuring settings turned on? For example: cmake.automaticReconfigure, cmake.configureOnEdit, cmake.configureOnOpen. I'm not able to reproduce your issue right now. I'm finding that it behaves as expected where it simply runs the most recent build and runs the target.

Thanks for any information that could help. Running CMake: Log Diagnostics may provide helpful information

@gcampbell-msft
Copy link
Collaborator

Here is a video of me attempting your repro and everything behaving as expected.

Thanks for all of your information!

Repro

@gcampbell-msft gcampbell-msft added more info needed More info is needed from the community for us to properly triage and investigate. and removed more info needed More info is needed from the community for us to properly triage and investigate. labels Jul 13, 2023
@trondhe
Copy link
Author

trondhe commented Jul 14, 2023

Its because it automatically has already configured it for you via the extension.
I dont have automatically reconfigure on and when I invoke a task that is specifically cmake and configure as shown as my tasks, this should instruct the extension as I would understand to do the configure, so it should know about it, but it still reconfigures.

Here is a video that reproduces how it re-configures twice. (btw snipping tool is awesome, just wish it could set a target export size)

cmake_double_reconfigure_repro.mp4

Here is the diagnostics:

{
  "os": "win32",
  "vscodeVersion": "1.80.1",
  "cmtVersion": "1.14.34",
  "configurations": [
    {
      "folder": "c:\\repos\\cmaketoolstest",
      "cmakeVersion": "3.26.3",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": true,
      "compilers": {
        "C": "C:/Programs/LLVM/bin/clang.exe",
        "CXX": "C:/Programs/LLVM/bin/clang++.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

@gcampbell-msft
Copy link
Collaborator

I successfully am able to reproduce now. I will investigate the issue. Thanks for helping me get the repro!

1.15 automation moved this from To do to Done Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the product Feature: tasks more info needed More info is needed from the community for us to properly triage and investigate.
Projects
No open projects
1.15
Done
Development

Successfully merging a pull request may close this issue.

6 participants