Skip to content

Commit

Permalink
v0.3.0 (#86)
Browse files Browse the repository at this point in the history
* preparing for v0.3.0

* rebase

* add clearLine method. fix #42

* update readme. fix #121

* for loop refactor in a C++ way

* refactor _setCharAtCursorPosition name

* refactor clearLine

* add fill method. Fix #113

* decouple VgaTerminal drawing functionality to Window. Fix #122

* cursor blinking flag. Fix #39

* cursor speed from enum class, partially fix #38

* [cmake] macro to generate example. Fix #126

* update version string to 0.3.0 fixes #129

* build switch for precise timer,fixes #131 cursor blinking test macOS

* replace -fPIC with CMAKE_POSITION_INDEPENDENT_CODE flag. fix #132

* [appveyor | macOS] disable precise timer fix #131

* [TuiTerminal] phase 1 ver 0.1-showcase and example. Fixes #133

* [cmake] using GoogleTest module and macro for test. Fixes#128

* TODOs review

* define specific runtime_error exception. Fixes # 139

* fixes #91

* [wont fix] snapshot testing on CI. Fixes #141

* publish test report and code coverage on analysis pipeline. Fixes #143

* publish test reports even if test task failed. Fixes #130

* add .gittribute

* [lint] line ending LF

* [lint] replace TABS with SPACES

* [lint] end line LF. [azure-pipelines] cpplint analisys

* [azure-pipelines] add cpplint job. Fixes #140

* compilers warning fixes #146

* Apply suggestions from code review
  • Loading branch information
Raffaello authored May 22, 2020
1 parent 350683e commit 777012d
Show file tree
Hide file tree
Showing 49 changed files with 3,944 additions and 2,796 deletions.
2 changes: 2 additions & 0 deletions .gitattribute
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto

10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/out/
/.vs/
/CmakeSettings.json
/build
.vscode/
/out/
/.vs/
/CmakeSettings.json
/build
.vscode/
79 changes: 40 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
cmake_minimum_required (VERSION 3.16)

if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
endif()

project ("sdl2-vga-terminal" VERSION 0.2.2 DESCRIPTION "Vga Terminal on SDL2")


################################ Packages ####################################
set (CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CPACK_SYSTEM_NAME win64)
else()
set(CPACK_SYSTEM_NAME win32)
endif()
endif()
set(CPACK_PACKAGE_FILE_NAME ${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${CPACK_SYSTEM_NAME}-${CMAKE_BUILD_TYPE})
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_GENERATOR "ZIP")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CMAKE_PROJECT_DESCRIPTION})
include(CPack)


################################# Options ####################################
option(BUILD_SHARED_LIBS "build shared libs with C inteface" ON)
option(BUILD_EXAMPLES "build examples" ON)
include(CTest)
option(ENABLE_CODE_COVERAGE "compile Debug with code coverage" OFF)
option(BUILD_SNAPSHOT "build snapshot test" OFF)
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(TEST_DUMP_SNAPSHOT "build test to dump the expected output instead of verifing it" OFF
"BUILD_SNAPSHOT" OFF)
option(WITH_SDL2_STATIC "linking STATIC LIB with SDL2 STATIC" OFF)

enable_testing()
add_subdirectory ("sdl2-vga-terminal")
cmake_minimum_required (VERSION 3.16)

if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
endif()

project ("sdl2-vga-terminal" VERSION 0.3.0 DESCRIPTION "Vga Terminal on SDL2")


################################ Packages ####################################
set (CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CPACK_SYSTEM_NAME win64)
else()
set(CPACK_SYSTEM_NAME win32)
endif()
endif()
set(CPACK_PACKAGE_FILE_NAME ${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${CPACK_SYSTEM_NAME}-${CMAKE_BUILD_TYPE})
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_GENERATOR "ZIP")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CMAKE_PROJECT_DESCRIPTION})
include(CPack)


################################# Options ####################################
option(BUILD_SHARED_LIBS "build shared libs with C inteface" ON)
option(BUILD_EXAMPLES "build examples" ON)
include(CTest)
option(ENABLE_CODE_COVERAGE "compile Debug with code coverage" OFF)
option(BUILD_SNAPSHOT "build snapshot test" OFF)
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(TEST_DUMP_SNAPSHOT "build test to dump the expected output instead of verifing it" OFF
"BUILD_SNAPSHOT" OFF)
option(WITH_SDL2_STATIC "linking STATIC LIB with SDL2 STATIC" OFF)
option(HAVE_PRECISE_TIMER "if SDL2 timers are precise" ON)

enable_testing()
add_subdirectory ("sdl2-vga-terminal")
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2020 Raffaello Bertini

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2020 Raffaello Bertini
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 28 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@

there are 5 pipelines, 1 for each OS and one dedicated to "Analysis", plus 1 for matrix build.

- the CI pipelines related to each OS are building multiple times based on the below matrix.
The result of the tests are published in Azure Devops as well through `ctest -T Test` flag.
- The CI pipelines related to each OS are building and generating the artifacts.

Only Linux is not runnig the tests due to missing video driver on CI.

The test results are published in Azure Devops through `ctest -T Test` flag.

- the Analysis pipeline is analyzing the code, generating coverage and publish to codecov and SonarCloud
- the Matrix pipeline is an overkill so it is just triggered manually when required.

The Matrix build is reflecting this table:
- The Analysis pipeline is analyzing the code, generating coverage and publish to codecov and SonarCloud.
it also performing a `cpplint` job and publish as artifact the result.
- The Matrix pipeline is an overkill so it is just triggered manually when required.
It is reflecting this table:

| FLAGS\OS | Windows | Linux | macos |
|:--------------------:|:------------------:|:------------------:|:------------------:|
Expand Down Expand Up @@ -69,14 +72,12 @@ It should be on 16 colors in the classic way, but can support more thanks to SDL

It is just a matter of fonts and a terminal grid for displaying texts.


## Requirements

- `SDL2`

## Compiling


These are the requirements to compile the project from source:

- `cmake 3.16`
Expand Down Expand Up @@ -113,9 +114,25 @@ The filename generated are based on the test that are running, ideally: `[Test-s

Just as a convention.

## Tui Terminal (Experimental)

This is just a show case and has not to be considered following the semantic versioning of the project,
it implies things might change with no objective reason at all.

It might could be detached completely and be its own library using this one.

At the moment is really very basic, error-prone and not well designed neither.

There is an example too among the examples.

### Screenshot

This is a TUI screenshot used in the snapshot test too.

![alt text](./sdl2-vga-terminal/test/snapshot/TuiTerminal.Snapshot.png "Title")

## Projects Idea to be done in the future

- `VT Snake` (retro-gaming style snake in an emulated DOS Text Mode)
- `VT Tetris` (retro-gaming style Tetris in an emulated DOS Text Mode)
- `VT Pong` (retro-gaming style Pong in an emulated DOS Text Mode)
- `VT Snake` (retro-gaming style snake in an emulated DOS Text Mode)
- `VT Tetris` (retro-gaming style Tetris in an emulated DOS Text Mode)
- `VT Pong` (retro-gaming style Pong in an emulated DOS Text Mode)
18 changes: 3 additions & 15 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ configuration:
environment:
VCPKG_SCRIPT: scripts/buildsystems/vcpkg.cmake
ENABLE_CODE_COVERAGE: OFF
HAVE_PRECISE_TIMER: ON

matrix:
allow_failures:
Expand Down Expand Up @@ -47,7 +48,7 @@ for:
environment:
WS: /Users/appveyor/projects
TRIPLET: $PLATFORM-osx
# ENABLE_CODE_COVERAGE: ON
HAVE_PRECISE_TIMER: OFF
cache:
#- $WS/vcpkg
- $WS/vcpkg/installed
Expand All @@ -56,20 +57,8 @@ for:
- sh: brew install p7zip #lcov
- sh: cd $WS && git clone https://github.com/Microsoft/vcpkg.git
- sh: cd $APPVEYOR_BUILD_FOLDER
# /Library/Developer/CommandLineTools/usr/bin/llvm-cov
#- sh: sudo find / -name llvm-cov 2> /dev/null
#- sh: llvm-cov --help
test_script:
- sh: ctest -V
#- sh: find . -name *.gcda
#- sh: echo '#!/bin/bash' > g.sh
#- sh: echo 'exec /Library/Developer/CommandLineTools/usr/bin/llvm-cov gcov "$@"' >> g.sh
#- sh: chmod +x g.sh
#- sh: ./g.sh -f -b -u $(find . -name *.gcda)
#- sh: lcov --directory . --base-directory . --gcov-tool ./g.sh --capture -o cov.info
#- sh: lcov --remove cov.info '/Applications/*' --output-file coverage.info
#- sh: lcov --list coverage.info
#- sh: bash <(curl -s https://codecov.io/bash) -f coverage.info -t b8f07100-6985-49f7-aa4c-14e36f29ac80

skip_commits:
files:
Expand All @@ -83,7 +72,6 @@ skip_commits:
cache:
- C:\tools\vcpkg\installed


install:
- cmd: if "%PLATFORM%" == "x64" call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
- cmd: if "%PLATFORM%" == "x86" call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
Expand All @@ -104,7 +92,7 @@ build_script:
- mkdir out
- cd out
- cmd: cmake -G "Ninja" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DWITH_SDL2_STATIC=OFF -DBUILD_SNAPSHOT=OFF -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/%VCPKG_SCRIPT% ..
- sh : cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION -DWITH_SDL2_STATIC=ON -DBUILD_SNAPSHOT=OFF -DENABLE_CODE_COVERAGE=$ENABLE_CODE_COVERAGE -DCMAKE_TOOLCHAIN_FILE=$WS/vcpkg/$VCPKG_SCRIPT ..
- sh : cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION -DWITH_SDL2_STATIC=ON -DBUILD_SNAPSHOT=OFF -DENABLE_CODE_COVERAGE=$ENABLE_CODE_COVERAGE -DHAVE_PRECISE_TIMER=$HAVE_PRECISE_TIMER -DCMAKE_TOOLCHAIN_FILE=$WS/vcpkg/$VCPKG_SCRIPT ..
- cmake --build .

test_script:
Expand Down
36 changes: 23 additions & 13 deletions azure-pipelines/analyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,8 @@ stages:
BUILD_EXAMPLES: OFF
BUILD_SHARED_LIBS: ON
ENABLE_CODE_COVERAGE: ON
HAVE_PRECISE_TIMER: OFF
jobs:
# - template: 'templates/sonarcloud-job.yml'
# parameters:
# imageName: ${{ variables.windows_image }}
# jobName: SonarCloud_win
# jobDisplayName: SonarCloud (WIN)
# vcpkg_key_cache: $(CACHE_VCPKG_KEY)
# triplet: x64-windows
# arch: 64
# build_type: Debug
# sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip'
# build_wrapper: 'build-wrapper-win-x86\build-wrapper-win-x86-64.exe'
# build_wrapper_path: build/build-wrapper-win-x86
# cmake_ignore_path: $(CMAKE_IGNORE_PATH_WIN)
- template: 'templates/sonarcloud-job.yml'
parameters:
imageName: ${{ variables.mac_image }}
Expand All @@ -78,3 +66,25 @@ stages:
sonar_wrapper_url: 'https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip'
build_wrapper: 'build-wrapper-macosx-x86/build-wrapper-macosx-x86'
build_wrapper_path: build/build-wrapper-macosx-x86

### the cmake-gen-build-steps should be geneneralized to accept different
### arguments from the build-wrapper, and the build wrapper in this case
### is scan-build tool, at the moment make it working, 2nd iteration
### generalize that themplate.
- job: cpplint
pool:
vmImage: ${{ variables.mac_image }}
steps:
- script: pip install cpplint
displayName: install cpplint
- script: chmod +x cpplint.sh && ./cpplint.sh 2> cpplint.log || echo "-==*** ignoring linting warnings ***==-"
displayName: cpplint
continueOnError: true
# Publish (upload) a file or directory as a named artifact for the current run
- task: PublishPipelineArtifact@1
inputs:
targetPath: cpplint.log
artifactName: 'cpplint.log'
- script: cat cpplint.log
displayName: cpplint result

2 changes: 2 additions & 0 deletions azure-pipelines/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ stages:
- stage: CI
jobs:
- job: macOS
variables:
HAVE_PRECISE_TIMER: OFF
strategy:
matrix:
Debug:
Expand Down
2 changes: 2 additions & 0 deletions azure-pipelines/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ stages:
- stage: matrix_macos
displayName: Matrix MacOS
dependsOn: Dep
variables:
HAVE_PRECISE_TIMER: OFF
jobs:
- template: 'templates/matrix-job.yml'
parameters:
Expand Down
17 changes: 3 additions & 14 deletions azure-pipelines/templates/ci-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,9 @@ steps:
arch: ${{ parameters.arch }}
#build_wrapper:
- ${{ if eq(parameters.test, true) }}:
- script: ctest -C ${{ parameters.build_type }} -v -V -T Test
displayName: cmake test (ctest)
workingDirectory: build
- task: PublishTestResults@2
inputs:
testResultsFormat: 'cTest' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: '**/Test.xml'
searchFolder: build # Optional
#mergeTestResults: false # Optional
#failTaskOnFailedTests: false # Optional
#testRunTitle: # Optional
#buildPlatform: # Optional
#buildConfiguration: # Optional
#publishRunAttachments: true # Optional
- template: 'cmake-test-steps.yml'
parameters:
build_type: ${{ parameters.build_type }}

- ${{ if eq(parameters.install, true) }}:
- script: cmake --build . --target install
Expand Down
21 changes: 21 additions & 0 deletions azure-pipelines/templates/cmake-test-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
parameters:
- name: build_type
displayName: Build Type
type: string

steps:
- script: ctest -C ${{ parameters.build_type }} -v -V -T Test
displayName: cmake test (ctest)
workingDirectory: build
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFormat: 'cTest' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: '**/Test.xml'
searchFolder: build # Optional
#mergeTestResults: false # Optional
#failTaskOnFailedTests: false # Optional
#testRunTitle: # Optional
#buildPlatform: # Optional
#buildConfiguration: # Optional
#publishRunAttachments: true # Optional
Loading

0 comments on commit 777012d

Please sign in to comment.