From 6a7a247d44294b611198c63cfbbaf0118c4a962d Mon Sep 17 00:00:00 2001 From: Tilen Majerle Date: Sun, 12 Dec 2021 21:19:32 +0100 Subject: [PATCH] Add CMake file for vscode build via ninja --- .gitignore | 51 +++++++++++++++++++++------------ .vscode/c_cpp_properties.json | 23 +++++++++++++++ .vscode/launch.json | 20 +++++++++++++ .vscode/tasks.json | 54 +++++++++++++++++++++++++++++++++++ CMakeLists.txt | 25 ++++++++++++++++ dev/VisualStudio/main.c | 5 ++-- 6 files changed, 158 insertions(+), 20 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index a872aad..4674b8a 100644 --- a/.gitignore +++ b/.gitignore @@ -24,26 +24,29 @@ *.i *.txt !docs/*.txt +!CMakeLists.txt RTE/ -# IAR Settings -**/settings/*.crun -**/settings/*.dbgdt -**/settings/*.cspy -**/settings/*.cspy.* -**/settings/*.xcl -**/settings/*.dni -**/settings/*.wsdt -**/settings/*.wspos +*debug -# IAR Debug Exe -**/Exe/*.sim +# IAR Settings +**/settings/*.crun +**/settings/*.dbgdt +**/settings/*.cspy +**/settings/*.cspy.* +**/settings/*.xcl +**/settings/*.dni +**/settings/*.wsdt +**/settings/*.wspos -# IAR Debug Obj -**/Obj/*.pbd -**/Obj/*.pbd.* -**/Obj/*.pbi -**/Obj/*.pbi.* +# IAR Debug Exe +**/Exe/*.sim + +# IAR Debug Obj +**/Obj/*.pbd +**/Obj/*.pbd.* +**/Obj/*.pbi +**/Obj/*.pbi.* *.TMP /docs_src/x_Doxyfile.doxy @@ -69,6 +72,7 @@ RTE/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ +[Dd]ebug*/ x64/ x86/ bld/ @@ -76,6 +80,7 @@ bld/ [Oo]bj/ [Ll]og/ _build/ +build/ # Visual Studio 2015/2017 cache/options directory .vs/ @@ -274,7 +279,7 @@ ClientBin/ *.publishsettings 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) #*.snk @@ -370,7 +375,7 @@ __pycache__/ # OpenCover UI analysis results OpenCover/ -# Azure Stream Analytics local run output +# Azure Stream Analytics local run output ASALocalRun/ # MSBuild Binary and Structured Log @@ -383,3 +388,13 @@ log_file.txt project.ioc mx.scratch *.tilen majerle + + +# Altium +Project outputs* +History/ +*.SchDocPreview +*.$$$Preview + +# VSCode projects +project_vscode_compiled.exe \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..d3bcf65 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -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 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..a3a1b80 --- /dev/null +++ b/.vscode/launch.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..2258787 --- /dev/null +++ b/.vscode/tasks.json @@ -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": [], + }, + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..bda065e --- /dev/null +++ b/CMakeLists.txt @@ -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) diff --git a/dev/VisualStudio/main.c b/dev/VisualStudio/main.c index f0237d8..b53aa6e 100644 --- a/dev/VisualStudio/main.c +++ b/dev/VisualStudio/main.c @@ -88,10 +88,11 @@ main(void) { /* User input to process every character */ printf("Start entering your command and press enter...\r\n"); while (1) { - char c = getch(); + char str[255]; + fgets(str, sizeof(str), stdin); /* Insert input to library */ - lwshell_input(&c, 1); + lwshell_input(str, strlen(str)); } return 0; }