Multi-task setting file task.json in VS code for Gnu Fortran in Windows


A quick sample of task.json in VS code for some one need to use multi-command while compiling source by Gnu Fortran in Windows

It will automatically compile and after that Self Signed Certification to exe file

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "compile using gfortran in mingw64 shell",
            "type": "shell",
            "command": [
                "gfortran",
                "-g -fbacktrace -ffpe-trap=zero,overflow,underflow",
                "-O",
                "${fileBasename}",
                "-lmpr -lNetapi32 ",  //linked library
                "-o",
                "${fileBasenameNoExtension}",
                "-IC:/msys64/mingw64/include",
                "-I./",
                "-I./mod_file/", //.mod file directory(for USE)
                "-J./mod_file" //.mod file directory(for USE)
            ],
            
            "options":{
                "cwd": "${fileDirname}",
                "shell": {
                    "executable": "C:\\msys64\\usr\\bin\\bash.exe",
                    "args": ["-c"],
                }
            },

            "args": [],
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": true,
                "panel": "shared",
                "showReuseMessage": true,
                "clear": false
            },
        },
           {
               "label": "Code Self Signed Certification",
               "type": "shell",
               "command":["Set-AuthenticodeSignature ",
               "${fileBasenameNoExtension}.exe ",
               "-Certificate (Get-ChildItem Cert:\\CurrentUser\\My -CodeSigningCert) \""
               ],
               "options":{
                   "cwd": "${fileDirname}",
                   "shell": {
                       "executable": "powershell.exe",
                       "args": ["-command "],
                   },
               },
               "args": [],
               "presentation": {
                   "echo": true,
                   "reveal": "always",
                   "focus": true,
                   "panel": "shared",
                   "showReuseMessage": true,
                   "clear": false
               },
           },
   // this need to add to last to setup default command will run when you use shortcut ctrl + shift + b to build something
           {
               "label": "Build",
               "dependsOrder": "sequence",
               "dependsOn": ["complie using gfortran in mingw64 shell", "Code Self Signed Certification"],
               "problemMatcher": [],
               "group": {
                   "kind": "build",
                   "isDefault": true
               }
           }
       ]
   }
   

Leave a Reply

Your email address will not be published. Required fields are marked *