diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index dd32ccb4..0c8e5258 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -17,6 +17,7 @@ concurrency: env: CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm-cache + PANDOC_CACHE_DIR: ${{ github.workspace }}/pandoc-cache jobs: build-appimage: @@ -40,6 +41,11 @@ jobs: path: ${{ env.CPM_SOURCE_CACHE }} key: ${{ runner.os }}-cpm-${{ hashFiles('**/vendor.cmake', '**/CMakeLists.txt') }} restore-keys: ${{ runner.os }}-cpm- + - name: Cache pandoc + uses: actions/cache@v4 + with: + path: ${{ env.PANDOC_CACHE_DIR }} + key: ${{ runner.os }}-pandoc-${{ hashFiles('cmake/manual.cmake') }} - name: Cache wayland uses: actions/cache@v4 with: diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 13be2753..20499dd9 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -16,6 +16,7 @@ concurrency: env: CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm-cache + PANDOC_CACHE_DIR: ${{ github.workspace }}/pandoc-cache jobs: build-emscripten: @@ -37,6 +38,11 @@ jobs: path: ${{ env.CPM_SOURCE_CACHE }} key: ${{ runner.os }}-cpm-${{ hashFiles('**/vendor.cmake', '**/CMakeLists.txt') }} restore-keys: ${{ runner.os }}-cpm- + - name: Cache pandoc + uses: actions/cache@v4 + with: + path: ${{ env.PANDOC_CACHE_DIR }} + key: ${{ runner.os }}-pandoc-${{ hashFiles('cmake/manual.cmake') }} - name: Profiler GUI run: | cmake -G Ninja -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=MinSizeRel -DGIT_REV=${{ github.sha }} -DCMAKE_TOOLCHAIN_FILE=${{env.EMSDK}}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index bc6de496..67db22f3 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -16,6 +16,7 @@ concurrency: env: CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm-cache + PANDOC_CACHE_DIR: ${{ github.workspace }}/pandoc-cache jobs: build-linux: @@ -33,6 +34,11 @@ jobs: path: ${{ env.CPM_SOURCE_CACHE }} key: ${{ runner.os }}-cpm-${{ hashFiles('**/vendor.cmake', '**/CMakeLists.txt') }} restore-keys: ${{ runner.os }}-cpm- + - name: Cache pandoc + uses: actions/cache@v4 + with: + path: ${{ env.PANDOC_CACHE_DIR }} + key: ${{ runner.os }}-pandoc-${{ hashFiles('cmake/manual.cmake') }} - name: Determine build parallelism run: | if [ "${ACT:-}" != "true" ] && [ "${FORGEJO_ACTIONS:-}" != "true" ]; then diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 900ec107..9dfcc742 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -17,6 +17,7 @@ concurrency: env: CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm-cache + PANDOC_CACHE_DIR: ${{ github.workspace }}/pandoc-cache jobs: build-macos: @@ -29,6 +30,11 @@ jobs: path: ${{ env.CPM_SOURCE_CACHE }} key: ${{ runner.os }}-cpm-${{ hashFiles('**/vendor.cmake', '**/CMakeLists.txt') }} restore-keys: ${{ runner.os }}-cpm- + - name: Cache pandoc + uses: actions/cache@v4 + with: + path: ${{ env.PANDOC_CACHE_DIR }} + key: ${{ runner.os }}-pandoc-${{ hashFiles('cmake/manual.cmake') }} - name: Install dependencies run: brew install pkg-config meson - name: Trust git repo diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 10da44fe..ddbed689 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -17,6 +17,7 @@ concurrency: env: CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm-cache + PANDOC_CACHE_DIR: ${{ github.workspace }}/pandoc-cache jobs: build-windows: @@ -29,6 +30,11 @@ jobs: path: ${{ env.CPM_SOURCE_CACHE }} key: ${{ runner.os }}-cpm-${{ hashFiles('**/vendor.cmake', '**/CMakeLists.txt') }} restore-keys: ${{ runner.os }}-cpm- + - name: Cache pandoc + uses: actions/cache@v4 + with: + path: ${{ env.PANDOC_CACHE_DIR }} + key: ${{ runner.os }}-pandoc-${{ hashFiles('cmake/manual.cmake') }} - uses: microsoft/setup-msbuild@v2 - name: Trust git repo run: git config --global --add safe.directory '*' diff --git a/cmake/manual.cmake b/cmake/manual.cmake index 3af57ec6..68b49c78 100644 --- a/cmake/manual.cmake +++ b/cmake/manual.cmake @@ -51,23 +51,38 @@ else() endif() endif() - set(TRACY_PANDOC ${CMAKE_BINARY_DIR}/tools/${_pandoc_exe}) + # Shared cache: $PANDOC_CACHE_DIR, else the platform user cache directory. + if(DEFINED ENV{PANDOC_CACHE_DIR}) + set(_pandoc_cache $ENV{PANDOC_CACHE_DIR}) + elseif(WIN32) + set(_pandoc_cache $ENV{LOCALAPPDATA}/tracy/pandoc) + elseif(APPLE) + set(_pandoc_cache $ENV{HOME}/Library/Caches/tracy/pandoc) + elseif(DEFINED ENV{XDG_CACHE_HOME}) + set(_pandoc_cache $ENV{XDG_CACHE_HOME}/tracy/pandoc) + else() + set(_pandoc_cache $ENV{HOME}/.cache/tracy/pandoc) + endif() + + set(TRACY_PANDOC ${_pandoc_cache}/${_pandoc_exe}) if(NOT EXISTS ${TRACY_PANDOC}) + # Concurrent configures on a cold cache can collide; worst case the + # hash check fails and a rerun succeeds. message(STATUS "Downloading pandoc ${PANDOC_VERSION} (${_pandoc_asset})") - file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tools) + file(MAKE_DIRECTORY ${_pandoc_cache}) file(DOWNLOAD https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/${_pandoc_asset} - ${CMAKE_BINARY_DIR}/tools/pandoc.archive + ${_pandoc_cache}/pandoc.archive EXPECTED_HASH SHA256=${_pandoc_hash} STATUS _pandoc_download) list(GET _pandoc_download 0 _pandoc_download_rc) if(NOT _pandoc_download_rc STREQUAL "0") - file(REMOVE ${CMAKE_BINARY_DIR}/tools/pandoc.archive) + file(REMOVE ${_pandoc_cache}/pandoc.archive) message(FATAL_ERROR "Failed to download pandoc ${PANDOC_VERSION}: ${_pandoc_download}") endif() file(ARCHIVE_EXTRACT - INPUT ${CMAKE_BINARY_DIR}/tools/pandoc.archive - DESTINATION ${CMAKE_BINARY_DIR}/tools) - file(REMOVE ${CMAKE_BINARY_DIR}/tools/pandoc.archive) + INPUT ${_pandoc_cache}/pandoc.archive + DESTINATION ${_pandoc_cache}) + file(REMOVE ${_pandoc_cache}/pandoc.archive) endif() endif()