replace task.json args and compile.bat keil path yourself
Last active
May 18, 2021 09:05
-
-
Save nariichi3322/7c00680da050d7a1adac86a0d30569a9 to your computer and use it in GitHub Desktop.
Keil C compiler task for vscode (replace args yourself)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM bat file for clean keil project object files. | |
REM Param: Project obj root path | |
:Loop | |
IF "%~1" == "" GOTO Continue | |
del /s /q %1 | |
SHIFT | |
GOTO Loop | |
:Continue | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM bat file for compile keil project. | |
REM Param 1: Project files (uvproj file) folder path | |
REM Param 2: Project files (uvproj file) name | |
REM Param 3: Project target name | |
REM Param 4: object folder path | |
REM Param 5: bin folder path (optional) | |
IF EXIST C:\Keil_v5 ( | |
:: version 5 | |
::Keil C51 Bin files folder | |
set KEIL_BIN_FOLDER=C:\Keil_v5\C51\BIN | |
:: Keil uVision exec path | |
set KEIL_UV4=C:\Keil_v5\UV4\UV4.exe | |
) ELSE IF EXIST C:\Keil ( | |
::Keil C51 Bin files folder | |
set KEIL_BIN_FOLDER=C:\Keil\C51\BIN | |
:: Keil uVision exec path | |
set KEIL_UV4=C:\Keil\UV4\UV4.exe | |
) ELSE ( | |
echo "Keil uVision exec path not found" | |
exit 1 | |
) | |
:: Project directory path | |
set KEIL_PROJECT_DIR=%1 | |
:: Project files path | |
set KEIL_PROJECT=%1\%2.uvproj | |
:: Project target name | |
set KEIL_PROJECT_TARGET=%3 | |
:: Project objects folder path | |
set KEIL_PROJECT_OBJECT_DIR=%4 | |
:: Project bin folder path | |
IF "%~5" == "" ( | |
set KEIL_PROJECT_BIN_DIR=%KEIL_PROJECT_OBJECT_DIR% | |
) ELSE ( | |
set KEIL_PROJECT_BIN_DIR=%5 | |
) | |
:: Check folder exist | |
IF not EXIST %KEIL_PROJECT_OBJECT_DIR% mkdir %KEIL_PROJECT_OBJECT_DIR% | |
IF not EXIST %KEIL_PROJECT_BIN_DIR% mkdir %KEIL_PROJECT_BIN_DIR% | |
:: Setting terminal output file | |
set KEIL_BUILD_OUTPUT_FILE=%KEIL_PROJECT_OBJECT_DIR%\OUTPUTFILE.TXT | |
cls | |
:: Build | |
%KEIL_UV4% -j0 -b %KEIL_PROJECT% -t "%KEIL_PROJECT_TARGET%" -o"%KEIL_BUILD_OUTPUT_FILE%" | |
:: Show output | |
type %KEIL_BUILD_OUTPUT_FILE% | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// See https://go.microsoft.com/fwlink/?LinkId=733558 | |
// for the documentation about the tasks.json format | |
"version": "2.0.0", | |
"options": { | |
"shell": { | |
"executable": "cmd.exe", | |
"args": [ | |
"/d", "/c" | |
] | |
} | |
}, | |
"tasks": [ | |
{ | |
"label": "Compile", | |
"type": "process", | |
"command": "${workspaceFolder}\\.vscode\\compile.bat", | |
"args": [ | |
"project\\folder\\path", | |
"project-files-name", | |
"project-target-name", | |
"object\\folder\\path", | |
"bin\\folder\\path" | |
], | |
"options": {}, | |
"presentation": { | |
"reveal": "always", | |
"panel": "shared", | |
"focus": false, | |
"echo": true | |
}, | |
"group": { | |
"kind": "build", | |
"isDefault": true | |
}, | |
"problemMatcher": [ | |
{ | |
"owner": "c", | |
"fileLocation": "absolute", | |
"pattern": [ | |
{ | |
"regexp": "(ERROR|WARNING|NOTE|INFO) C(\\d*) IN LINE (\\d*) OF (.*?): (.*)", | |
"file": 4, | |
"line": 3, | |
"code": 2, | |
"severity": 1, | |
"message": 5 | |
} | |
] | |
}, | |
{ | |
"owner": "c", | |
"fileLocation": "absolute", | |
"pattern": [ | |
{ | |
"regexp": "(ERROR|WARNING|NOTE|INFO) L(\\d*): (.*)", | |
"code": 2, | |
"severity": 1, | |
"message": 3 | |
}, | |
{ | |
"regexp": ": (.*)", | |
"line": 1 | |
}, | |
{ | |
"regexp": ": (.*) ((.*))", | |
"file": 1 | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"label": "Clean", | |
"type": "process", | |
"command": "${workspaceFolder}\\.vscode\\cleanObj.bat", | |
"args": [ | |
"object\\folder\\path", | |
"support\\multiple\\folders" | |
], | |
"options": {}, | |
"presentation": { | |
"reveal": "always", | |
"panel": "shared", | |
"focus": false, | |
"echo": true | |
}, | |
"group": "none", | |
"problemMatcher": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment