diff --git a/.github/workflows/ubuntu_2204_build_pipeline.yml b/.github/workflows/ubuntu_2204_build_pipeline.yml index 5d626c8..911b471 100644 --- a/.github/workflows/ubuntu_2204_build_pipeline.yml +++ b/.github/workflows/ubuntu_2204_build_pipeline.yml @@ -17,3 +17,5 @@ jobs: run: ./scripts/build.sh - name: Tests run: ./scripts/test.sh --stop-on-failure + - name: Packaging + run: ./scripts/packaging.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 173d980..98da092 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED (VERSION 3.0) -PROJECT (cpp-quality-project) +PROJECT (cpp-quality-project VERSION 0.0.1) ENABLE_TESTING () LIST (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..06ca2a2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# CONTRIBUTING + +## How-to +- Install dependencies: +It is recomended to use the VSCode with the `.devcontainer`. +If you want to defvelop natively on an Ubuntu 22 distribution, you can run +```bash +./.devcontainer/setup_build_environment_on_ubuntu_22.sh +./.devcontainer/setup_documentation_environment_on_ubuntu_22.sh +``` +- Format all files of the repository using relevant `pre-commit` hook +```bash +./scripts/format.sh +``` + +- Configure the project +```bash +./scripts/configure.sh +``` + +- Build the project +```bash +./scripts/build.sh +``` + +- Run all tests +```bash +./scripts/test.sh +``` + +- Generate the project documentation +```bash +./scripts/document.sh +``` + +- Create a debian package of the project +```bash +./scripts/packaging.sh +``` diff --git a/License.txt b/License.txt new file mode 100644 index 0000000..82fe64d --- /dev/null +++ b/License.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [YEAR] [COPYRIGHT HOLDER] + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4d7dbf2 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Cpp Project Template diff --git a/Readme.md b/Readme.md deleted file mode 100644 index 3d46414..0000000 --- a/Readme.md +++ /dev/null @@ -1,59 +0,0 @@ -# Cpp Project Template -## Folder structure -* ./project is where the template project in itself lays. When starting a new c++ project, you may copy/paste it -* ./workflow_test is where tests regarding the workflow with the template project are located (ensuring that various cmake rules work well) - -## TODO -* [ ] Make a test that calls valgrind with memcheck to evaluate memory leaks -* [ ] Make a test that generate coverage report -* [ ] Make a target in the library that make dissasemblies of the librairies -* [ ] Make various version of the library at once (debug, release and various optimization) -* [ ] Make target for assmebly and dissasembly of the library - - - - - -## Testing -### Git-Sort Hash rule -#### Build directory is empty - ``` - - ``` - -#### Scenario: Fresh configure - Build directory is empty - ``` - cmake .. - make all - ``` - build/version.hpp should show latest git commit - - -#### Scenario: Actual built but new commit - Build directory is empty - - ``` - cmake.. - make all - touch ./../foobar - git add foobar - git commit -m "Just a new commit" - make all - ``` - - build/version.hpp should show latest git commit - -#### Actual build no new commit but new generation file - Build directory is emptty - ``` - cmake .. - make all - touch ./../foobar - git add foobar - git commit -m "Just a new commit" - sed 's/getGitShortHash/getGitShortHash2/g' ./../version.hpp.in - make all - ``` - - version.hpp should show latest git commit with latest version file (getGitShortHash2) diff --git a/cmake_modules/Packaging.cmake b/cmake_modules/Packaging.cmake new file mode 100644 index 0000000..7313418 --- /dev/null +++ b/cmake_modules/Packaging.cmake @@ -0,0 +1,12 @@ +INCLUDE (InstallRequiredSystemLibraries) +SET (CPACK_PACKAGE_NAME "${PROJECT_NAME}") +SET (CPACK_PACKAGE_VENDOR "company-name") +SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME} - Brief description") +SET (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}") +SET (CPACK_PACKAGE_HOMEPAGE_URL "http://company-url") +SET (CPACK_PACKAGE_CONTACT "author@company-email.com") +SET (CPACK_DEBIAN_PACKAGE_DEPENDS "") +SET (CPACK_GENERATOR DEB) +SET (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/License.txt) + +INCLUDE (CPack) diff --git a/project/CMakeLists.txt b/project/CMakeLists.txt index 964801a..ad77eb3 100644 --- a/project/CMakeLists.txt +++ b/project/CMakeLists.txt @@ -12,6 +12,8 @@ TARGET_LINK_LIBRARIES (${EXENAME} PUBLIC probe) INSTALL (TARGETS ${EXENAME} RUNTIME DESTINATION bin) +INCLUDE (Packaging) + ADD_CUSTOM_TARGET ( disassemble COMMAND /usr/bin/objdump -S $ > diff --git a/project/version.hpp.in b/project/version.hpp.in index 9dc5057..41df3a7 100644 --- a/project/version.hpp.in +++ b/project/version.hpp.in @@ -1,7 +1,5 @@ -#define VERSION @SHORT_HASH@ +#define VERSION @SHORT_HASH @ - -const char* getVersion() -{ - return "@SHORT_HASH@"; +const char* getVersion() { + return "@CMAKE_PROJECT_VERSION@ - @SHORT_HASH@"; } diff --git a/scripts/packaging.sh b/scripts/packaging.sh new file mode 100755 index 0000000..dc35705 --- /dev/null +++ b/scripts/packaging.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -euxo pipefail +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "$DIR"/../build || exit 1 +make package