Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/template/template_name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpp_boilerplate_project
1 change: 1 addition & 0 deletions .github/template/template_repository
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpp-best-practices/cpp_boilerplate_project
47 changes: 38 additions & 9 deletions .github/workflows/template-janitor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# This workflow should cleanup everything unneeded from the template project

name: Template Janitor

on:
pull_request:
release:
types: [published]
push:
tags:
branches:
- develop
- main # maybe all to run "tests" on every change?
- main
- develop

env:
TEMPLATES_PATH: ".github/template"
Expand All @@ -23,7 +28,7 @@ jobs:
run: |
echo "NEW_ORG=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "NEW_PROJECT=${{ github.event.repository.name }}" >> $GITHUB_ENV
echo "NEW_URL=${{ github.repositoryUrl}}" >> $GITHUB_ENV
echo "NEW_URL=${{ github.repositoryUrl }}" >> $GITHUB_ENV

- uses: octokit/request-action@v2.x
id: get_repo_meta
Expand All @@ -41,17 +46,17 @@ jobs:
sed -i "s/myproject/${{ github.event.repository.name }}/gi" CMakeLists.txt configured_files/config.hpp.in

# Update URL placeholders for project
sed -i "s/%%myurl%%/${{ github.event.repositoryUrl }}/gi" CMakeLists.txt
sed -i "s|%%myurl%%|${{ fromJson(steps.get_repo_meta.outputs.data).html_url }}|gi" CMakeLists.txt

# fill in placeholders of readme and move it into place
sed -i "s/%%myorg%%/${{ env.NEW_ORG }}/g" ${{ env.TEMPLATES_PATH }}/README.md
sed -i "s/%%myproject%%/${{ env.NEW_PROJECT }}/g" ${{ env.TEMPLATES_PATH }}/README.md
sed -i "s/%%description%%/${{ fromJson(steps.get_repo_meta.outputs.data).description }}/g" ${{ env.TEMPLATES_PATH }}/README.md
sed -i "s|%%description%%|${{ fromJson(steps.get_repo_meta.outputs.data).description }}|g" ${{ env.TEMPLATES_PATH }}/README.md
cp ${{ env.TEMPLATES_PATH }}/README.md README.md

- name: Print diff after replacement
run: |
# Exclude the README as that is checked seperatly!
# Exclude the README as that is checked separately!
git diff ':!README.md'
# following should not have any diffs
diff ${{ env.TEMPLATES_PATH }}/README.md README.md
Expand All @@ -63,11 +68,35 @@ jobs:

- name: Clean up before commit and push
run: |
rm -rf ${{ env.TEMPLATES_PATH }}
rm -r ${{ env.TEMPLATES_PATH }}

# Can we get that from a variabl?
# Can we get that from a variable?
# Remove this workflow as it has fulfilled its purpose
rm -rf .github/workflows/template-janitor.yml
rm .github/workflows/template-janitor.yml
rm .github/workflows/template-renamer.yml

- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: gcc

cmake: true
ninja: false
conan: true
vcpkg: false
ccache: false
clangtidy: false

cppcheck: false

gcovr: false
opencppcoverage: false


- name: Test simple configuration to make sure nothing broke (default compiler,cmake,developer_mode OFF)
run: |
cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=DEBUG -DENABLE_DEVELOPER_MODE:BOOL=OFF -DOPT_ENABLE_COVERAGE:BOOL=OFF


- uses: EndBug/add-and-commit@v4
# only commit and push if we are not a template project anymore!
Expand Down
94 changes: 94 additions & 0 deletions .github/workflows/template-renamer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# This workflow should cleanup everything unneeded from the template project

name: Template Renamer

on:
pull_request:
release:
types: [published]
push:
tags:
branches:
- main
- develop

env:
TEMPLATES_PATH: ".github/template"

jobs:

template-rename:
name: Renames template when a new name is detected
runs-on: ubuntu-latest
steps:
- name: Fetch Sources
uses: actions/checkout@v2.4.0

- name: Get organization and project name
run: |
echo "TEST_RUN=false" >> $GITHUB_ENV
echo "NEW_ORG=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "NEW_PROJECT=${{ github.event.repository.name }}" >> $GITHUB_ENV
echo "NEW_REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV
echo "TEMPLATE_NAME=`cat ${{ env.TEMPLATES_PATH }}/template_name`" >> $GITHUB_ENV
echo "TEMPLATE_REPOSITORY=`cat ${{ env.TEMPLATES_PATH }}/template_repository`" >> $GITHUB_ENV

- uses: octokit/request-action@v2.x
id: get_repo_meta
with:
route: GET /repos/{owner}/{repo}
owner: ${{ env.NEW_ORG }}
repo: ${{ env.NEW_PROJECT }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup fake test org/project names if project didn't change
if: env.TEMPLATE_NAME == env.NEW_PROJECT
run: |
echo "TEST_RUN=true" >> $GITHUB_ENV
echo "NEW_ORG=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "NEW_PROJECT=TEST_PROJECT" >> $GITHUB_ENV
echo "NEW_REPOSITORY=TEST_REPOSITORY" >> $GITHUB_ENV


# Rename all cpp_starter_project occurrences to current repository and remove this workflow
- name: Update repository to match new template information
run: |
# Update the README and template files to match the new org / repository names
sed -i "s|${{ env.TEMPLATE_REPOSITORY }}|${{ env.NEW_REPOSITORY }}|g" README.md ${{ env.TEMPLATES_PATH }}/template_repository
sed -i "s|${{ env.TEMPLATE_NAME }}|${{ env.NEW_PROJECT }}|g" README.md ${{ env.TEMPLATES_PATH }}/template_name

- name: Print diff after template name replacement
run: |
git diff

- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: gcc

cmake: true
ninja: false
conan: true
vcpkg: false
ccache: false
clangtidy: false

cppcheck: false

gcovr: false
opencppcoverage: false

- name: Test simple configuration to make sure nothing broke (default compiler,cmake,developer_mode OFF)
run: |
cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=DEBUG -DENABLE_DEVELOPER_MODE:BOOL=OFF -DOPT_ENABLE_COVERAGE:BOOL=OFF

- uses: EndBug/add-and-commit@v4
# only commit and push if we are a template and project name has changed
if: fromJson(steps.get_repo_meta.outputs.data).is_template == true && env.TEST_RUN == 'false'
with:
author_name: Template Janitor
author_email: template.janitor@example.com
message: 'Change Template Name'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ set(CMAKE_CXX_STANDARD 20)
# when compiling with PCH enabled
set(CMAKE_CXX_EXTENSIONS OFF)

include(FetchContent)

set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
FetchContent_Declare(ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
GIT_TAG v2.0.0
)

FetchContent_GetProperties(ftxui)
if(NOT ftxui_POPULATED)
FetchContent_Populate(ftxui)
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()



# Note: by default ENABLE_DEVELOPER_MODE is True
# This means that all analysis (sanitizers, static analysis)
# is enabled and all warnings are treated as errors
Expand All @@ -22,7 +38,6 @@ set(OPT_WARNINGS_AS_ERRORS_DEVELOPER_DEFAULT TRUE)

# Add project_options v0.17.0
# https://github.com/cpp-best-practices/project_options
include(FetchContent)
FetchContent_Declare(_project_options
URL https://github.com/cpp-best-practices/project_options/archive/refs/tags/v0.17.0.zip)
FetchContent_MakeAvailable(_project_options)
Expand All @@ -37,7 +52,7 @@ project(
myproject
VERSION 0.0.1
DESCRIPTION ""
HOMEPAGE_URL "%%url%%"
HOMEPAGE_URL "%%myurl%%"
LANGUAGES CXX C)

set(GIT_SHA
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![ci](https://github.com/cpp-best-practices/cpp_boilerplate_project/actions/workflows/ci.yml/badge.svg)](https://github.com/cpp-best-practices/cpp_boilerplate_project/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/cpp-best-practices/cpp_boilerplate_project/branch/main/graph/badge.svg)](https://codecov.io/gh/cpp-best-practices/cpp_boilerplate_project)
[![Language grade: C++](https://img.shields.io/lgtm/grade/cpp/github/cpp-best-practices/cpp_boilerplate_project)](https://lgtm.com/projects/g/cpp-best-practices/cpp_starter_project/context:cpp)
[![Language grade: C++](https://img.shields.io/lgtm/grade/cpp/github/cpp-best-practices/cpp_boilerplate_project)](https://lgtm.com/projects/g/cpp-best-practices/cpp_boilerplate_project/context:cpp)
[![CodeQL](https://github.com/cpp-best-practices/cpp_boilerplate_project/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/cpp-best-practices/cpp_boilerplate_project/actions/workflows/codeql-analysis.yml)

## About cpp_boilerplate_project
Expand All @@ -28,9 +28,9 @@ It requires
* conan
* a compiler

If you want a more complex example project, check out the [cpp_starter_project](https://github.com/cpp-best-practices/cpp_starter_project).

Ths Boilerplate project will merge new features first, then they will be merged (as appropriate) into cpp_starter_project.
This project gets you started with a simple example of using FTXUI, which happens to also be a game


## Getting Started

Expand Down
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ target_link_libraries(
fmt::fmt
spdlog::spdlog)

target_include_directories(intro PRIVATE "${CMAKE_BINARY_DIR}/configured_files/include")
target_link_system_libraries(
intro
PRIVATE
ftxui::screen
ftxui::dom
ftxui::component)

target_include_directories(intro PRIVATE "${CMAKE_BINARY_DIR}/configured_files/include")
Loading