From 7cb2a1d2116f1474fc64796f7b2c17c193ab4fff Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 28 Apr 2023 21:32:47 -0600 Subject: [PATCH 01/14] Attempt to work around workflow commit permission --- .github/variables/PROJECT_NAME | 1 + .github/workflows/ci.yml | 6 +++++- .github/workflows/template-janitor.yml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .github/variables/PROJECT_NAME diff --git a/.github/variables/PROJECT_NAME b/.github/variables/PROJECT_NAME new file mode 100644 index 00000000..25189a02 --- /dev/null +++ b/.github/variables/PROJECT_NAME @@ -0,0 +1 @@ +myproject diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72e2af3a..247ce68c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,6 @@ on: env: CLANG_TIDY_VERSION: "15.0.2" VERBOSE: 1 - PROJECT_NAME: myproject jobs: @@ -136,6 +135,11 @@ jobs: package_maintainer_mode: ${{ matrix.package_maintainer_mode }} generator: ${{ matrix.generator }} + - name: Project name + run: | + echo "PROJECT_NAME=`cat .github/variables/project_name`" >> $GITHUB_ENV + + - name: Setup Cpp uses: aminya/setup-cpp@v1 with: diff --git a/.github/workflows/template-janitor.yml b/.github/workflows/template-janitor.yml index d188cc3b..a57062f6 100644 --- a/.github/workflows/template-janitor.yml +++ b/.github/workflows/template-janitor.yml @@ -74,7 +74,7 @@ jobs: - name: Insert new org and project run: | # rename the CMake project to match the github project - find src include test fuzz_test cmake -type f -exec sed -i "s/myproject/${{ env.NEW_SAFE_PROJECT }}/gi" CMakeLists.txt Dependencies.cmake ProjectOptions.cmake .github/workflows/ci.yml .github/workflows/codeql-analysis.yml configured_files/config.hpp.in {} + + find src include test fuzz_test cmake -type f -exec sed -i "s/myproject/${{ env.NEW_SAFE_PROJECT }}/gi" .github/variables/PROJECT_NAME CMakeLists.txt Dependencies.cmake ProjectOptions.cmake .github/workflows/ci.yml .github/workflows/codeql-analysis.yml configured_files/config.hpp.in {} + # Update URL placeholders for project sed -i "s|%%myurl%%|${{ fromJson(steps.get_repo_meta.outputs.data).html_url }}|gi" CMakeLists.txt From 0a59adb2c9d68cb69158ceed1aabf74ccc65a0e9 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 28 Apr 2023 22:30:41 -0600 Subject: [PATCH 02/14] Try to fix loading of project_name --- .github/workflows/ci.yml | 4 ++-- .github/workflows/codeql-analysis.yml | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 247ce68c..daa5969f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,9 +135,9 @@ jobs: package_maintainer_mode: ${{ matrix.package_maintainer_mode }} generator: ${{ matrix.generator }} - - name: Project name + - name: Project Name run: | - echo "PROJECT_NAME=`cat .github/variables/project_name`" >> $GITHUB_ENV + echo "PROJECT_NAME=`cat .github/variables/PROJECT_NAME`" >> $GITHUB_ENV - name: Setup Cpp diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d527156f..0bb7b029 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -20,8 +20,6 @@ on: schedule: - cron: '38 0 * * 5' -env: - PROJECT_NAME: myproject jobs: analyze: @@ -60,6 +58,10 @@ jobs: packaging_maintainer_mode: ${{ matrix.packaging_maintainer_mode }} generator: ${{ matrix.generator }} + - name: Project Name + run: | + echo "PROJECT_NAME=`cat .github/variables/PROJECT_NAME`" >> $GITHUB_ENV + - name: Setup Cpp uses: aminya/setup-cpp@v1 From 0b3d1d79d4f404fa75e22c5eae81a8bcc05600be Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 28 Apr 2023 22:43:34 -0600 Subject: [PATCH 03/14] take a different approach to fixing project_name loading --- .github/variables/PROJECT_NAME | 1 - .github/workflows/ci.yml | 5 +++-- .github/workflows/codeql-analysis.yml | 5 +++-- .github/workflows/constants.env | 1 + .github/workflows/template-janitor.yml | 10 ++++++++-- 5 files changed, 15 insertions(+), 7 deletions(-) delete mode 100644 .github/variables/PROJECT_NAME create mode 100644 .github/workflows/constants.env diff --git a/.github/variables/PROJECT_NAME b/.github/variables/PROJECT_NAME deleted file mode 100644 index 25189a02..00000000 --- a/.github/variables/PROJECT_NAME +++ /dev/null @@ -1 +0,0 @@ -myproject diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index daa5969f..ac00215c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,8 +136,9 @@ jobs: generator: ${{ matrix.generator }} - name: Project Name - run: | - echo "PROJECT_NAME=`cat .github/variables/PROJECT_NAME`" >> $GITHUB_ENV + uses: cardinalby/export-env-action@v2 + with: + envFile: 'constants.env' - name: Setup Cpp diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0bb7b029..bacc7454 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -59,8 +59,9 @@ jobs: generator: ${{ matrix.generator }} - name: Project Name - run: | - echo "PROJECT_NAME=`cat .github/variables/PROJECT_NAME`" >> $GITHUB_ENV + uses: cardinalby/export-env-action@v2 + with: + envFile: 'constants.env' - name: Setup Cpp diff --git a/.github/workflows/constants.env b/.github/workflows/constants.env new file mode 100644 index 00000000..5c8528a0 --- /dev/null +++ b/.github/workflows/constants.env @@ -0,0 +1 @@ +PROJECT_NAME=myproject diff --git a/.github/workflows/template-janitor.yml b/.github/workflows/template-janitor.yml index a57062f6..9085a92c 100644 --- a/.github/workflows/template-janitor.yml +++ b/.github/workflows/template-janitor.yml @@ -74,7 +74,7 @@ jobs: - name: Insert new org and project run: | # rename the CMake project to match the github project - find src include test fuzz_test cmake -type f -exec sed -i "s/myproject/${{ env.NEW_SAFE_PROJECT }}/gi" .github/variables/PROJECT_NAME CMakeLists.txt Dependencies.cmake ProjectOptions.cmake .github/workflows/ci.yml .github/workflows/codeql-analysis.yml configured_files/config.hpp.in {} + + find src include test fuzz_test cmake -type f -exec sed -i "s/myproject/${{ env.NEW_SAFE_PROJECT }}/gi" .github/workflows/constants.env CMakeLists.txt Dependencies.cmake ProjectOptions.cmake .github/workflows/ci.yml .github/workflows/codeql-analysis.yml configured_files/config.hpp.in {} + # Update URL placeholders for project sed -i "s|%%myurl%%|${{ fromJson(steps.get_repo_meta.outputs.data).html_url }}|gi" CMakeLists.txt @@ -122,10 +122,16 @@ jobs: gcovr: false opencppcoverage: false + - name: Project Name + uses: cardinalby/export-env-action@v2 + with: + envFile: 'constants.env' + + - name: Test simple configuration to make sure nothing broke run: | - cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -DENABLE_DEVELOPER_MODE:BOOL=${{ matrix.developer_mode }} -DOPT_ENABLE_COVERAGE:BOOL=OFF + cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=ON # Build it because we may have broken something in the cpp/hpp files cmake --build build From cf72a4365a14c094145fe30d1067173697e8f99f Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 28 Apr 2023 22:59:32 -0600 Subject: [PATCH 04/14] Fix variable location --- .github/actions/setup_cache/action.yml | 11 ++++------- .github/workflows/auto-clang-format.yml | 2 +- .github/workflows/ci.yml | 24 ++++++++++++------------ .github/workflows/codeql-analysis.yml | 4 ++-- .github/workflows/template-janitor.yml | 10 +++++----- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/.github/actions/setup_cache/action.yml b/.github/actions/setup_cache/action.yml index 197e5571..7bf260e2 100644 --- a/.github/actions/setup_cache/action.yml +++ b/.github/actions/setup_cache/action.yml @@ -11,7 +11,7 @@ inputs: generator: required: true type: string - developer_mode: + packaging_maintainer_mode: required: true type: string @@ -20,16 +20,13 @@ runs: using: "composite" steps: - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: # You might want to add .ccache to your cache configuration? path: | ~/.cache/pip - ${{ env.HOME }}/.cache/vcpkg/archives - ${{ env.XDG_CACHE_HOME }}/vcpkg/archives - ${{ env.LOCALAPPDATA }}\vcpkg\archives - ${{ env.APPDATA }}\vcpkg\archives - key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}-${{ inputs.generator }}-${{ inputs.developer_mode }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}} + ~/.ccache + key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}-${{ inputs.generator }}-${{ inputs.packaging_maintainer_mode }}-${{ hashFiles('**/CMakeLists.txt') }} restore-keys: | ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }} diff --git a/.github/workflows/auto-clang-format.yml b/.github/workflows/auto-clang-format.yml index c39fb5e7..b4e0a1b9 100644 --- a/.github/workflows/auto-clang-format.yml +++ b/.github/workflows/auto-clang-format.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: DoozyX/clang-format-lint-action@v0.13 with: source: '.' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac00215c..07a6b7e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: build_type: - Release - Debug - package_maintainer_mode: + packaging_maintainer_mode: - ON - OFF build_shared: @@ -68,7 +68,7 @@ jobs: # Set up preferred package generators, for given build configurations - build_type: Release - package_maintainer_mode: OFF + packaging_maintainer_mode: OFF package_generator: TBZ2 # This exists solely to make sure a non-multiconfig build works @@ -77,7 +77,7 @@ jobs: generator: "Unix Makefiles" build_type: Debug gcov_executable: gcov - package_maintainer_mode: On + packaging_maintainer_mode: On enable_ipo: Off # Windows msvc builds @@ -85,34 +85,34 @@ jobs: compiler: msvc generator: "Visual Studio 17 2022" build_type: Debug - package_maintainer_mode: On + packaging_maintainer_mode: On enable_ipo: On - os: windows-2022 compiler: msvc generator: "Visual Studio 17 2022" build_type: Release - package_maintainer_mode: On + packaging_maintainer_mode: On enable_ipo: On - os: windows-2022 compiler: msvc generator: "Visual Studio 17 2022" build_type: Debug - package_maintainer_mode: Off + packaging_maintainer_mode: Off - os: windows-2022 compiler: msvc generator: "Visual Studio 17 2022" build_type: Release - package_maintainer_mode: Off + packaging_maintainer_mode: Off package_generator: ZIP - os: windows-2022 compiler: msvc generator: "Visual Studio 17 2022" build_type: Release - package_maintainer_mode: On + packaging_maintainer_mode: On enable_ipo: On build_shared: On @@ -125,20 +125,20 @@ jobs: script: | core.setFailed('There is a mismatch between configured llvm compiler and clang-tidy version chosen') - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Cache uses: ./.github/actions/setup_cache with: compiler: ${{ matrix.compiler }} build_type: ${{ matrix.build_type }} - package_maintainer_mode: ${{ matrix.package_maintainer_mode }} + packaging_maintainer_mode: ${{ matrix.packaging_maintainer_mode }} generator: ${{ matrix.generator }} - name: Project Name uses: cardinalby/export-env-action@v2 with: - envFile: 'constants.env' + envFile: '.github/workflows/constants.env' - name: Setup Cpp @@ -161,7 +161,7 @@ jobs: - name: Configure CMake run: | - cmake -S . -B ./build -G "${{matrix.generator}}" -D${{ env.PROJECT_NAME }}_ENABLE_IPO=${{matrix.enable_ipo }} -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.package_maintainer_mode}} -D${{ env.PROJECT_NAME }}_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }} + cmake -S . -B ./build -G "${{matrix.generator}}" -D${{ env.PROJECT_NAME }}_ENABLE_IPO=${{matrix.enable_ipo }} -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.packaging_maintainer_mode}} -D${{ env.PROJECT_NAME }}_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }} - name: Build # Execute the build. You can specify a specific target with "--target " diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index bacc7454..bedace5d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -48,7 +48,7 @@ jobs: steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Cache uses: ./.github/actions/setup_cache @@ -61,7 +61,7 @@ jobs: - name: Project Name uses: cardinalby/export-env-action@v2 with: - envFile: 'constants.env' + envFile: '.github/workflows/constants.env' - name: Setup Cpp diff --git a/.github/workflows/template-janitor.yml b/.github/workflows/template-janitor.yml index 9085a92c..1c709bd9 100644 --- a/.github/workflows/template-janitor.yml +++ b/.github/workflows/template-janitor.yml @@ -33,7 +33,7 @@ jobs: - OFF steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Cache uses: ./.github/actions/setup_cache @@ -125,13 +125,13 @@ jobs: - name: Project Name uses: cardinalby/export-env-action@v2 with: - envFile: 'constants.env' + envFile: '.github/workflows/constants.env' - name: Test simple configuration to make sure nothing broke run: | - cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=ON + cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -D${{ env.NEW_SAFE_PROJECT }}_PACKAGING_MAINTAINER_MODE:BOOL=ON # Build it because we may have broken something in the cpp/hpp files cmake --build build @@ -162,7 +162,7 @@ jobs: - OFF steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Cache uses: ./.github/actions/setup_cache @@ -229,7 +229,7 @@ jobs: - name: Test simple configuration to make sure nothing broke (default compiler,cmake,developer_mode OFF) run: | - cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -DENABLE_DEVELOPER_MODE:BOOL=${{ matrix.developer_mode }} -DOPT_ENABLE_COVERAGE:BOOL=OFF + cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=ON - uses: EndBug/add-and-commit@v4 # only commit and push if we are a template and project name has changed From a90d7e8fd82f8100c71346aa159004ff900185ac Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 28 Apr 2023 23:19:40 -0600 Subject: [PATCH 05/14] Prevent UBSAN minimal runtime on windows/clang --- ProjectOptions.cmake | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/ProjectOptions.cmake b/ProjectOptions.cmake index b469cae7..2709aa1a 100644 --- a/ProjectOptions.cmake +++ b/ProjectOptions.cmake @@ -3,16 +3,8 @@ include(cmake/LibFuzzer.cmake) include(CMakeDependentOption) include(CheckCXXCompilerFlag) -macro(myproject_setup_options) - option(myproject_ENABLE_HARDENING "Enable hardening" ON) - option(myproject_ENABLE_COVERAGE "Enable coverage reporting" OFF) - cmake_dependent_option( - myproject_ENABLE_GLOBAL_HARDENING - "Attempt to push hardening options to built dependencies" - ON - myproject_ENABLE_HARDENING - OFF) +macro(myproject_supports_sanitizers) if((CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*" OR CMAKE_CXX_COMPILER_ID MATCHES ".*GNU.*") AND NOT WIN32) set(SUPPORTS_UBSAN ON) else() @@ -24,6 +16,19 @@ macro(myproject_setup_options) else() set(SUPPORTS_ASAN ON) endif() +endmacro() + +macro(myproject_setup_options) + option(myproject_ENABLE_HARDENING "Enable hardening" ON) + option(myproject_ENABLE_COVERAGE "Enable coverage reporting" OFF) + cmake_dependent_option( + myproject_ENABLE_GLOBAL_HARDENING + "Attempt to push hardening options to built dependencies" + ON + myproject_ENABLE_HARDENING + OFF) + + myproject_supports_sanitizers() if(NOT PROJECT_IS_TOP_LEVEL OR myproject_PACKAGING_MAINTAINER_MODE) option(myproject_ENABLE_IPO "Enable IPO/LTO" OFF) @@ -90,9 +95,12 @@ macro(myproject_global_options) myproject_enable_ipo() endif() + myproject_supports_sanitizers() + if(myproject_ENABLE_HARDENING AND myproject_ENABLE_GLOBAL_HARDENING) include(cmake/Hardening.cmake) - if(myproject_ENABLE_SANITIZER_UNDEFINED + if(NOT SUPPORTS_UBSAN + OR myproject_ENABLE_SANITIZER_UNDEFINED OR myproject_ENABLE_SANITIZER_ADDRESS OR myproject_ENABLE_SANITIZER_THREAD OR myproject_ENABLE_SANITIZER_LEAK) @@ -177,7 +185,11 @@ macro(myproject_local_options) if(myproject_ENABLE_HARDENING AND NOT myproject_ENABLE_GLOBAL_HARDENING) include(cmake/Hardening.cmake) - if(myproject_ENABLE_SANITIZER_UNDEFINED) + if(NOT SUPPORTS_UBSAN + OR myproject_ENABLE_SANITIZER_UNDEFINED + OR myproject_ENABLE_SANITIZER_ADDRESS + OR myproject_ENABLE_SANITIZER_THREAD + OR myproject_ENABLE_SANITIZER_LEAK) set(ENABLE_UBSAN_MINIMAL_RUNTIME FALSE) else() set(ENABLE_UBSAN_MINIMAL_RUNTIME TRUE) From 56c91e3ca45c072044b42026dc9dedfd22bfe9bd Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 29 Apr 2023 08:51:22 -0600 Subject: [PATCH 06/14] Move to add and commit v9 --- .github/workflows/template-janitor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/template-janitor.yml b/.github/workflows/template-janitor.yml index 1c709bd9..fcae0d9a 100644 --- a/.github/workflows/template-janitor.yml +++ b/.github/workflows/template-janitor.yml @@ -231,7 +231,7 @@ jobs: run: | cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=ON - - uses: EndBug/add-and-commit@v4 + - uses: EndBug/add-and-commit@v9 # 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: From ca06944002c9d54cc908e8b6a81fc32546907d77 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 29 Apr 2023 08:55:17 -0600 Subject: [PATCH 07/14] Move workflows file --- .github/{workflows => }/constants.env | 0 .github/workflows/ci.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/template-janitor.yml | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) rename .github/{workflows => }/constants.env (100%) diff --git a/.github/workflows/constants.env b/.github/constants.env similarity index 100% rename from .github/workflows/constants.env rename to .github/constants.env diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07a6b7e9..db6c6110 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -138,7 +138,7 @@ jobs: - name: Project Name uses: cardinalby/export-env-action@v2 with: - envFile: '.github/workflows/constants.env' + envFile: '.github/constants.env' - name: Setup Cpp diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index bedace5d..e21dc29e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -61,7 +61,7 @@ jobs: - name: Project Name uses: cardinalby/export-env-action@v2 with: - envFile: '.github/workflows/constants.env' + envFile: '.github/constants.env' - name: Setup Cpp diff --git a/.github/workflows/template-janitor.yml b/.github/workflows/template-janitor.yml index fcae0d9a..01c40363 100644 --- a/.github/workflows/template-janitor.yml +++ b/.github/workflows/template-janitor.yml @@ -74,7 +74,7 @@ jobs: - name: Insert new org and project run: | # rename the CMake project to match the github project - find src include test fuzz_test cmake -type f -exec sed -i "s/myproject/${{ env.NEW_SAFE_PROJECT }}/gi" .github/workflows/constants.env CMakeLists.txt Dependencies.cmake ProjectOptions.cmake .github/workflows/ci.yml .github/workflows/codeql-analysis.yml configured_files/config.hpp.in {} + + find src include test fuzz_test cmake -type f -exec sed -i "s/myproject/${{ env.NEW_SAFE_PROJECT }}/gi" .github/constants.env CMakeLists.txt Dependencies.cmake ProjectOptions.cmake .github/workflows/ci.yml .github/workflows/codeql-analysis.yml configured_files/config.hpp.in {} + # Update URL placeholders for project sed -i "s|%%myurl%%|${{ fromJson(steps.get_repo_meta.outputs.data).html_url }}|gi" CMakeLists.txt @@ -125,7 +125,7 @@ jobs: - name: Project Name uses: cardinalby/export-env-action@v2 with: - envFile: '.github/workflows/constants.env' + envFile: '.github/constants.env' From 0cba4db99abb1f906568ae2c29dd5f6d4b1498af Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 29 Apr 2023 10:12:31 -0600 Subject: [PATCH 08/14] Try to make janitor more robust, cause errors --- .github/workflows/template-janitor.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/template-janitor.yml b/.github/workflows/template-janitor.yml index 01c40363..071ead0b 100644 --- a/.github/workflows/template-janitor.yml +++ b/.github/workflows/template-janitor.yml @@ -135,13 +135,15 @@ jobs: # Build it because we may have broken something in the cpp/hpp files cmake --build build - - uses: EndBug/add-and-commit@v4 + - uses: EndBug/add-and-commit@v9 # only commit and push if we are not a template project anymore! if: fromJson(steps.get_repo_meta.outputs.data).is_template != true with: + add: -A author_name: Template Janitor author_email: template.janitor@example.com message: 'Cleanup template and initialize repository' + pathspec_error_handling: exitImmediately env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -235,8 +237,10 @@ jobs: # 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: + add: -A author_name: Template Janitor author_email: template.janitor@example.com message: 'Change Template Name' + pathspec_error_handling: exitImmediately env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4e774d4348d88aefdac13fd1a0db97b9f31a1396 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 29 Apr 2023 17:36:27 -0600 Subject: [PATCH 09/14] Only enabled FORTIFY_SOURCE in non-Debug --- cmake/Hardening.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/Hardening.cmake b/cmake/Hardening.cmake index 5f61d229..aea5aaf8 100644 --- a/cmake/Hardening.cmake +++ b/cmake/Hardening.cmake @@ -17,9 +17,11 @@ macro( set(NEW_CXX_DEFINITIONS "${NEW_CXX_DEFINITIONS} -D_GLIBCXX_ASSERTIONS") message(STATUS "*** GLIBC++ Assertions (vector[], string[], ...) enabled") - set(NEW_COMPILE_OPTIONS "${NEW_COMPILE_OPTIONS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3") - message(STATUS "*** g++/clang _FORTIFY_SOURCE=3 enabled") - + if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(NEW_COMPILE_OPTIONS "${NEW_COMPILE_OPTIONS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3") + message(STATUS "*** g++/clang _FORTIFY_SOURCE=3 enabled") + endif() + # check_cxx_compiler_flag(-fpie PIE) #if(PIE) # set(NEW_COMPILE_OPTIONS ${NEW_COMPILE_OPTIONS} -fpie) From c73d5fe85fdacf1e493bdf42036fae8d6e339399 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 19 Mar 2024 16:48:27 -0600 Subject: [PATCH 10/14] Fix handling of standard for demo library --- src/sample_library/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sample_library/CMakeLists.txt b/src/sample_library/CMakeLists.txt index b75fe637..cfe2f2b3 100644 --- a/src/sample_library/CMakeLists.txt +++ b/src/sample_library/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_libraries(sample_library PRIVATE myproject_options myproject_warning target_include_directories(sample_library ${WARNING_GUARD} PUBLIC $ $) -target_compile_features(sample_library PUBLIC cxx_std_20) +target_compile_features(sample_library PUBLIC cxx_std_${CMAKE_CXX_STANDARD}) set_target_properties( sample_library From a3c8b264b4316a10d3edafff5d9ef0cad6417820 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 19 Mar 2024 17:07:23 -0600 Subject: [PATCH 11/14] Be sure to compile library with fuzz support if building fuzz tests --- src/sample_library/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sample_library/CMakeLists.txt b/src/sample_library/CMakeLists.txt index cfe2f2b3..211e6fac 100644 --- a/src/sample_library/CMakeLists.txt +++ b/src/sample_library/CMakeLists.txt @@ -12,6 +12,11 @@ target_link_libraries(sample_library PRIVATE myproject_options myproject_warning target_include_directories(sample_library ${WARNING_GUARD} PUBLIC $ $) +if (myproject_BUILD_FUZZ_TESTS) + target_link_libraries(sample_library PRIVATE -fsanitize=fuzzer-no-link) + target_compile_options(sample_library PRIVATE -fsanitize=fuzzer-no-link) +endif() + target_compile_features(sample_library PUBLIC cxx_std_${CMAKE_CXX_STANDARD}) set_target_properties( From f51204bc2b3247e132e71e280c14e8ee9e71146c Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 31 Dec 2025 18:07:33 -0700 Subject: [PATCH 12/14] Add wasm support (#127) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add WebAssembly build infrastructure Port WASM infrastructure from travels project to enable building the intro executable for web browsers using Emscripten. Core WASM infrastructure: - cmake/Emscripten.cmake: Emscripten/WASM build configuration - Detects Emscripten builds and disables incompatible features - Configures pthread support (required by FTXUI) - Provides myproject_configure_wasm_target() function - Optional resource embedding support via INTRO_RESOURCES_DIR - web/shell.html: Custom HTML shell with xterm.js terminal - Dark-themed terminal UI with WebGL rendering - Handles stdin/stdout/stderr buffering for WASM - Supports ?version URL parameter - web/coi-serviceworker.min.js: Service worker for COOP/COEP headers - Required for SharedArrayBuffer/pthread support on GitHub Pages - .github/workflows/wasm.yml: CI/CD workflow - Builds WASM on all CI runs - Deploys to GitHub Pages for main/develop branches and tags CMake integration: - CMakeLists.txt: Include Emscripten.cmake before ProjectOptions - ProjectOptions.cmake: Add EMSCRIPTEN detection to disable sanitizers - src/ftxui_sample/CMakeLists.txt: Apply WASM configuration to intro Critical bug fixes included: - cmake/Hardening.cmake: Fix CMake list handling and global flag propagation (proper add_compile_options() usage) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 * Improve URL parameter to CLI argument handling in shell.html - Support any URL parameter as command-line argument - Smart prefix detection: single-char → -, multi-char → -- - Handle both boolean flags and parameters with values - Add visible usage guide on web page explaining conversion rules Examples: ?version → --version ?v → -v ?file=test.txt → --file test.txt ?verbose&config=app.cfg → --verbose --config app.cfg 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 * Upgrade xterm to 6.0.0 - Update xterm from 5.3.0 to 6.0.0 - Update addon-fit from 0.8.0 to 0.10.0 - Update addon-webgl from 0.16.0 to 0.18.0 - Use new @xterm scoped package names for addons 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 * Fix xterm 6.0 ES modules with proper initialization order Fixes multiple critical issues that prevented xterm 6.0 from working: 1. Package naming: Use @xterm/xterm instead of deprecated xterm package - Changed CSS URL to @xterm/xterm@6.0.0/css/xterm.css - Changed import map to use @xterm/xterm - Changed import statement to match 2. Module initialization timing: Define Module synchronously - Module must exist BEFORE Emscripten's {{{ SCRIPT }}} loads - ES modules execute asynchronously, causing "Module should not be replaced during async compilation" error - Solution: Define Module in regular + +
+

@TARGET_NAME@

+ +
+
+

Loading @TARGET_NAME@...

+

+
+ + + +
+ +
+

Command-Line Arguments via URL

+

Pass command-line arguments to the application using URL parameters:

+ +
+ Conversion Rules: +
    +
  • • Single-character params → short flags: ?v → -v
  • +
  • • Multi-character params → long flags: ?version → --version
  • +
  • • Params with values: ?file=test.txt → --file test.txt
  • +
  • • Multiple params: ?v&help → -v --help
  • +
+
+ +
+ Examples: +
    +
  • intro.html?version
  • +
  • intro.html?h
  • +
  • intro.html?file=data.txt
  • +
  • intro.html?verbose&config=settings.json
  • +
+
+
+
+ + + + + + {{{ SCRIPT }}} + + From 8705bd526aeed181364b5a465afe2014c38c8304 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 1 Jan 2026 10:55:01 -0700 Subject: [PATCH 13/14] Move to water.css and simplify our custom theme/styling --- cmake/Emscripten.cmake | 4 +- web/index_template.html.in | 113 ++++++++++++--------------- web/shell_template.html.in | 155 +++++++++++++++++++------------------ 3 files changed, 130 insertions(+), 142 deletions(-) diff --git a/cmake/Emscripten.cmake b/cmake/Emscripten.cmake index e6115ab8..5082ec6f 100644 --- a/cmake/Emscripten.cmake +++ b/cmake/Emscripten.cmake @@ -186,8 +186,8 @@ function(myproject_create_web_dist) string(APPEND WASM_APPS_HTML " -
${TITLE_ESCAPED}
-
${DESC_ESCAPED}
+

${TITLE_ESCAPED}

+

${DESC_ESCAPED}

") endforeach() diff --git a/web/index_template.html.in b/web/index_template.html.in index a60f681e..1418c856 100644 --- a/web/index_template.html.in +++ b/web/index_template.html.in @@ -4,87 +4,74 @@ @PROJECT_NAME@ - WebAssembly Applications + -
-

@PROJECT_NAME@

-

WebAssembly Applications

+
+
+ + + +
+ +
+

@PROJECT_NAME@

+

WebAssembly Applications

+
@WASM_APPS_HTML@
- -
+
+ Built with CMake and Emscripten | Version @PROJECT_VERSION@ +
+ + + diff --git a/web/shell_template.html.in b/web/shell_template.html.in index 6b98449a..98d5f2c6 100644 --- a/web/shell_template.html.in +++ b/web/shell_template.html.in @@ -4,83 +4,63 @@ @TARGET_TITLE@ + -
-

@TARGET_NAME@

+
+
+ + + +
+ +
+

@TARGET_NAME@

+
@@ -92,31 +72,27 @@
-
-

Command-Line Arguments via URL

-

Pass command-line arguments to the application using URL parameters:

- -
- Conversion Rules: -
    -
  • • Single-character params → short flags: ?v → -v
  • -
  • • Multi-character params → long flags: ?version → --version
  • -
  • • Params with values: ?file=test.txt → --file test.txt
  • -
  • • Multiple params: ?v&help → -v --help
  • -
-
- -
- Examples: -
    -
  • intro.html?version
  • -
  • intro.html?h
  • -
  • intro.html?file=data.txt
  • -
  • intro.html?verbose&config=settings.json
  • -
-
-
-
+
+

Command-Line Arguments via URL

+

Pass command-line arguments to the application using URL parameters:

+ + Conversion Rules: +
    +
  • • Single-character params → short flags: ?v → -v
  • +
  • • Multi-character params → long flags: ?version → --version
  • +
  • • Params with values: ?file=test.txt → --file test.txt
  • +
  • • Multiple params: ?v&help → -v --help
  • +
+ + Examples: +
    +
  • intro.html?version
  • +
  • intro.html?h
  • +
  • intro.html?file=data.txt
  • +
  • intro.html?verbose&config=settings.json
  • +
+
+
+ + + {{{ SCRIPT }}} From 2fa1a63789945e1d9de0a03b9819ca8350c7e478 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 1 Jan 2026 17:21:24 -0700 Subject: [PATCH 14/14] Support targets with different OUTPUT_NAME in WASM builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update myproject_configure_wasm_target to handle cases where the executable name differs from the target name via OUTPUT_NAME property. Changes: - Query and store OUTPUT_NAME for each WASM target - Use OUTPUT_NAME in shell template configuration - Use OUTPUT_NAME when copying artifacts in web-dist 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- cmake/Emscripten.cmake | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/cmake/Emscripten.cmake b/cmake/Emscripten.cmake index 5082ec6f..cc59389b 100644 --- a/cmake/Emscripten.cmake +++ b/cmake/Emscripten.cmake @@ -69,10 +69,17 @@ function(myproject_configure_wasm_target target) set(WASM_DESCRIPTION "WebAssembly application") endif() + # Get the actual output name (may differ from target name) + get_target_property(OUTPUT_NAME ${target} OUTPUT_NAME) + if(NOT OUTPUT_NAME) + set(OUTPUT_NAME "${target}") + endif() + # Register this target in the global WASM targets list set_property(GLOBAL APPEND PROPERTY myproject_WASM_TARGETS "${target}") set_property(GLOBAL PROPERTY myproject_WASM_TARGET_${target}_TITLE "${WASM_TITLE}") set_property(GLOBAL PROPERTY myproject_WASM_TARGET_${target}_DESCRIPTION "${WASM_DESCRIPTION}") + set_property(GLOBAL PROPERTY myproject_WASM_TARGET_${target}_OUTPUT_NAME "${OUTPUT_NAME}") target_compile_definitions(${target} PRIVATE myproject_WASM_BUILD=1) @@ -110,7 +117,7 @@ function(myproject_configure_wasm_target target) endif() # Configure the shell HTML template for this target - set(TARGET_NAME "${target}") + set(TARGET_NAME "${OUTPUT_NAME}") set(TARGET_TITLE "${WASM_TITLE}") set(TARGET_DESCRIPTION "${WASM_DESCRIPTION}") set(AT "@") # For escaping @ in npm package URLs @@ -208,20 +215,22 @@ function(myproject_create_web_dist) # Each target gets its own service worker copy for standalone deployment foreach(target ${WASM_TARGETS}) get_target_property(TARGET_BINARY_DIR ${target} BINARY_DIR) + get_property(OUTPUT_NAME GLOBAL PROPERTY myproject_WASM_TARGET_${target}_OUTPUT_NAME) set(TARGET_DIST_DIR "${WEB_DIST_DIR}/${target}") # Copy WASM artifacts: .html (as index.html), .js, .wasm, and service worker + # Use OUTPUT_NAME instead of target name for file names list(APPEND COPY_COMMANDS COMMAND ${CMAKE_COMMAND} -E make_directory "${TARGET_DIST_DIR}" COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${TARGET_BINARY_DIR}/${target}.html" + "${TARGET_BINARY_DIR}/${OUTPUT_NAME}.html" "${TARGET_DIST_DIR}/index.html" COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${TARGET_BINARY_DIR}/${target}.js" - "${TARGET_DIST_DIR}/${target}.js" + "${TARGET_BINARY_DIR}/${OUTPUT_NAME}.js" + "${TARGET_DIST_DIR}/${OUTPUT_NAME}.js" COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${TARGET_BINARY_DIR}/${target}.wasm" - "${TARGET_DIST_DIR}/${target}.wasm" + "${TARGET_BINARY_DIR}/${OUTPUT_NAME}.wasm" + "${TARGET_DIST_DIR}/${OUTPUT_NAME}.wasm" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${myproject_COI_WORKER}" "${TARGET_DIST_DIR}/coi-serviceworker.min.js"