Skip to content

feat: Auto-generation of launch.json and tasks.json #977

Open
@yuxuan-z19

Description

@yuxuan-z19

Is there an existing request for this?

  • I have searched the existing issues

Feature Request

I'd like to request a feature "Fortran: gfortran build and debug active file", just like what the C/C++ extension does when someone debugs his .c or .cpp source code. Obviously we need tasks.json configured as well (to setup a preLaunchTask).

Here are my configurations:

// .vscode/launch.json
{
    "configurations": [
        {
            "name": "Fortran: gfortran build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "preLaunchTask": "Fortran: gfortran build active file", 
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}
// .vscode/tasks.json
{
    "tasks": [
        {
            "type": "shell",
            "label": "Fortran: gfortran build active file",
            "command": "/usr/bin/gfortran",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger"
        }
    ],
    "version": "2.0.0"
}

I was wondering if there's a way to generate launch.json and tasks.json automatically with minor modification to this extension.

Activity

fedebenelli

fedebenelli commented on Sep 19, 2023

@fedebenelli

While I agree that some automatic generation of tasks.json and launch.json files for debugging would be really nice.

I think that a more complete approach would be a command that generates a new fpm project at the current directory with something like fpm new --backfill and also the .vscode files with some setting similar to fortran-lang/fpm#479 (reply in thread)

gnikit

gnikit commented on Sep 19, 2023

@gnikit
Member

While I agree that some automatic generation of tasks.json and launch.json files for debugging would be really nice.

I think that a more complete approach would be a command that generates a new fpm project at the current directory with something like fpm new --backfill and also the .vscode files with some setting similar to fortran-lang/fpm#479 (reply in thread)

This is a great idea @fedebenelli. FYI there are plans for making fpm fully integrated with VS Code similar to CMake, but we will probably save that for a GSoC project or a funding proposal, since the dev time required would be in the hundreds of hours.

gnikit

gnikit commented on Sep 19, 2023

@gnikit
Member

@yuxuan-z19 No it is not currently possible. We rely 100% on the C++ extension so for me software-wise it makes sense not duplicating these file generation processes, since they will inevitably get outdated. I appreciate that this is not the most reasonable thing for a user though. Users just want to have these scripts ready.

Maybe there is a way (through some registered command) to call the C++ extension's task and launch generation scripts and then edit them.

TheFibonacciEffect

TheFibonacciEffect commented on Nov 20, 2024

@TheFibonacciEffect

I red in the description that the extension somehow uses the C/C++ extension for debugging. How do I do it? Somehow there is no run or debug button like in C/C++

I tried using the C/C++: Add Debug Configuration option, but it throws an error and says Cannot build and debug because the active file is not a C or C++ source file.

yuxuan-z19

yuxuan-z19 commented on Nov 28, 2024

@yuxuan-z19
Author

@TheFibonacciEffect I assume you have installed the (Microsoft) C/C++ and Modern Fortran extensions. Referring to this post, place the config files under a .vscode folder in your workspace (or working directory).

Image

Following what it says, your debugging console should be ready.

Image

I've made the configs available here. Feel free to use ; )

fedebenelli

fedebenelli commented on Nov 29, 2024

@fedebenelli

I also have made some sane defaults here: https://github.com/ipqa-research/vscode-fortran if anyone is intersted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gnikit@fedebenelli@TheFibonacciEffect@yuxuan-z19

        Issue actions

          feat: Auto-generation of `launch.json` and `tasks.json` · Issue #977 · fortran-lang/vscode-fortran-support