Add CMake file for vscode build via ninja

This commit is contained in:
Tilen Majerle 2021-12-12 21:19:32 +01:00
parent 467dabaa6d
commit 6a7a247d44
6 changed files with 158 additions and 20 deletions

51
.gitignore vendored
View File

@ -24,26 +24,29 @@
*.i *.i
*.txt *.txt
!docs/*.txt !docs/*.txt
!CMakeLists.txt
RTE/ RTE/
# IAR Settings *debug
**/settings/*.crun
**/settings/*.dbgdt
**/settings/*.cspy
**/settings/*.cspy.*
**/settings/*.xcl
**/settings/*.dni
**/settings/*.wsdt
**/settings/*.wspos
# IAR Debug Exe # IAR Settings
**/Exe/*.sim **/settings/*.crun
**/settings/*.dbgdt
**/settings/*.cspy
**/settings/*.cspy.*
**/settings/*.xcl
**/settings/*.dni
**/settings/*.wsdt
**/settings/*.wspos
# IAR Debug Obj # IAR Debug Exe
**/Obj/*.pbd **/Exe/*.sim
**/Obj/*.pbd.*
**/Obj/*.pbi # IAR Debug Obj
**/Obj/*.pbi.* **/Obj/*.pbd
**/Obj/*.pbd.*
**/Obj/*.pbi
**/Obj/*.pbi.*
*.TMP *.TMP
/docs_src/x_Doxyfile.doxy /docs_src/x_Doxyfile.doxy
@ -69,6 +72,7 @@ RTE/
[Dd]ebugPublic/ [Dd]ebugPublic/
[Rr]elease/ [Rr]elease/
[Rr]eleases/ [Rr]eleases/
[Dd]ebug*/
x64/ x64/
x86/ x86/
bld/ bld/
@ -76,6 +80,7 @@ bld/
[Oo]bj/ [Oo]bj/
[Ll]og/ [Ll]og/
_build/ _build/
build/
# Visual Studio 2015/2017 cache/options directory # Visual Studio 2015/2017 cache/options directory
.vs/ .vs/
@ -274,7 +279,7 @@ ClientBin/
*.publishsettings *.publishsettings
orleans.codegen.cs orleans.codegen.cs
# Including strong name files can present a security risk # Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424) # (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk #*.snk
@ -370,7 +375,7 @@ __pycache__/
# OpenCover UI analysis results # OpenCover UI analysis results
OpenCover/ OpenCover/
# Azure Stream Analytics local run output # Azure Stream Analytics local run output
ASALocalRun/ ASALocalRun/
# MSBuild Binary and Structured Log # MSBuild Binary and Structured Log
@ -383,3 +388,13 @@ log_file.txt
project.ioc project.ioc
mx.scratch mx.scratch
*.tilen majerle *.tilen majerle
# Altium
Project outputs*
History/
*.SchDocPreview
*.$$$Preview
# VSCode projects
project_vscode_compiled.exe

23
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,23 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}\\dev\\VisualStudio\\",
"${workspaceFolder}\\lwshell\\src\\include\\"
],
"defines": [
"WIN32",
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "c:\\msys64\\mingw64\\bin\\gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x86",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}

20
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}\\build\\LwSHELL.exe",
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"console": "integratedTerminal"
}
]
}

54
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,54 @@
{
"version": "2.0.0",
/* For this builds, you need
*
* - Ninja build system
* - MSYS2 compiler with ninja support
* - C/C++ extension for VSCode
* - CMake-Tools extension for VSCode
*/
"tasks": [
{
"type": "cppbuild",
"label": "Build project",
"command": "cmake",
"args": [
"--build",
"\"build\""
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "Clean project",
"command": "cmake",
"args": [
"--build",
"\"build\"",
"--target",
"clean"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
},
{
"type": "shell",
"label": "Run application",
"command": "${workspaceFolder}\\build\\LwSHELL.exe",
"args": [],
"problemMatcher": [],
},
]
}

25
CMakeLists.txt Normal file
View File

@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.0.0)
project(LwSHELL VERSION 0.1.0)
include(CTest)
enable_testing()
add_executable(${PROJECT_NAME}
lwshell/src/lwshell/lwshell.c
dev/VisualStudio/main.c
)
target_include_directories(${PROJECT_NAME} PRIVATE
dev/VisualStudio
lwshell/src/include
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
WIN32
_DEBUG
CONSOLE
)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

View File

@ -88,10 +88,11 @@ main(void) {
/* User input to process every character */ /* User input to process every character */
printf("Start entering your command and press enter...\r\n"); printf("Start entering your command and press enter...\r\n");
while (1) { while (1) {
char c = getch(); char str[255];
fgets(str, sizeof(str), stdin);
/* Insert input to library */ /* Insert input to library */
lwshell_input(&c, 1); lwshell_input(str, strlen(str));
} }
return 0; return 0;
} }