1

I'm trying to add a build task to build the current file, just a simple "make path/to/file.o". I'm using vscode on windows 10 over a remote SSH connection to linux.

However, if I use ${relativeFileDirname} it converts the path separators to windows format. Eg...

${fileDirname}=/home/me/git/project/data/source
${relativeFileDirname}=data\source

I've read about explorer.copyRelativePathSeparator. Can that be applied to the build task in tasks.json? Or is there another way?

This is the build task...

{
    "type": "cppbuild",
    "label": "C/C++: gcc build active file",
    "command": "/usr/bin/make",
    "args": [
        "${relativeFileDirname}/${fileBasenameNoExtension}.o"
    ],
    "options": {
        "cwd": "/home/me/git/project"
    },
    "problemMatcher": [
        "$gcc"
    ],
    "group": {
        "kind": "build",
        "isDefault": true
    },
    "detail": "compiler: /usr/bin/gcc",
    "presentation": {
        "clear": true
    }
}

Thanks.

Frank
  • 81
  • 5
  • Related: https://stackoverflow.com/questions/55190115/how-to-reverse-backslashes-in-relativefile-in-visual-studio-code-in-launch-js – fuenfundachtzig Apr 28 '22 at 13:55

1 Answers1

0

There is an extension for Visual Studio Code for this purpose that, after many failed attempts to use string substitution with bash built-ins and sed, was the only working solution for me:

"customOptions": "--workdir /home/user/${command:extension.commandvariable.file.relativeFileDirnamePosix}",
fuenfundachtzig
  • 7,952
  • 13
  • 62
  • 87