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

The tasks' targets are not resolved when "cmake.buildTask" is used #2970

Closed
elahehrashedi opened this issue Jan 24, 2023 · 4 comments · Fixed by #3009
Closed

The tasks' targets are not resolved when "cmake.buildTask" is used #2970

elahehrashedi opened this issue Jan 24, 2023 · 4 comments · Fixed by #3009

Comments

@elahehrashedi
Copy link
Contributor

elahehrashedi commented Jan 24, 2023

Brief Issue Summary

When searching for matching tasks, we try to compare the targets.

if (presetName) {
matchingTargetTasks = buildTasks.filter(task => task.definition.preset === presetName);
} else {
matchingTargetTasks = buildTasks.filter(task => {
const taskTargets: string[] = task.definition.targets || [];
const inputTargets: string[] = targets || [];
return taskTargets.length === inputTargets.length && taskTargets.every((item, index) => item === inputTargets[index]);
});
}

However, we don't resolve the targets such as "${command:cmake.buildTargetName}" before comparison.

@elahehrashedi elahehrashedi added this to the Backlog milestone Jan 24, 2023
@elahehrashedi
Copy link
Contributor Author

piomis since you have contributed to this code before, do you think you can take a look at this issue? Thank you.

@elahehrashedi elahehrashedi changed the title The tasks' targets are not resolved correctly when "cmake.buildTask" is used The tasks' targets are not resolved when "cmake.buildTask" is used Jan 24, 2023
@piomis
Copy link
Contributor

piomis commented Jan 28, 2023

@elahehrashedi I will take a look.
Can you please provide me a way how to reproduce it?

@eseiler
Copy link

eseiler commented Feb 3, 2023

Seems to be related to #2959

As for an example, the following just runs CMake build as a task.
tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build ",
            "command": "/usr/bin/bash",
            "args": ["-c", "${command:cmake.tasksBuildCommand}"],
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "clear": true,
                "panel": "dedicated",
                "echo": true,
                "showReuseMessage" : true
            },
            "options": {
                "cwd": "${command:cmake.buildDirectory}"
            },
            "problemMatcher": "$gcc"
        }
    ]
}

I think you need to have "cmake.buildTask": true set.

With v1.12.27, this task was detected (e.g., when building a target via the status bar button), but it is not any more with v1.13.XX. As far as I understand, the extension now defines a kind of task and checks for tasks with "type": "cmake".

Personally, I prefer using a (generic "type": "shell") task because:

  • there is colored output
  • tasks are run in the Terminal tab (instead of the Output tab)

But it's also handy when you need to do some things (via task's dependsOn config) before running cmake build or ctest.

@piomis
Copy link
Contributor

piomis commented Feb 3, 2023

This report is for sure not related to behaviour which you observe.
Like I wrote in #2959 - shell task behaviour was changed.
I proposed to keep #2959 to track discussion about tasks types.

@github-actions github-actions bot locked and limited conversation to collaborators May 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants