Repository navigation
Copy the Linux CEF files once per destination and retry setup-cmake in CI #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
4e4ada8
Copy the Linux CEF files once per destination and retry setup-cmake i…
ambroise-leclerc c5ccaf4
Copy CEF files to the target's output directory only when they change…
ambroise-leclerc be75abb
Hash the CMake archive from standard input in the setup action
ambroise-leclerc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| name: Set up CMake | ||
| description: >- | ||
| Installs an exact CMake release from its Kitware archive, checked against a SHA-256 pinned here. No GitHub API call | ||
| lists the releases, so the installation cannot fail on an incomplete answer ("Unable to find version matching"). | ||
| inputs: | ||
| version: | ||
| description: Exact CMake version; its archives must have a pinned SHA-256 below. | ||
| required: true | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Install CMake ${{ inputs.version }} | ||
| shell: bash | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| run: | | ||
| set -euo pipefail | ||
| case "$RUNNER_OS" in | ||
| Linux) platform=linux-x86_64; extension=tar.gz; bin=bin ;; | ||
| macOS) platform=macos-universal; extension=tar.gz; bin=CMake.app/Contents/bin ;; | ||
| Windows) platform=windows-x86_64; extension=zip; bin=bin ;; | ||
| *) echo "::error::No CMake archive for $RUNNER_OS"; exit 1 ;; | ||
| esac | ||
| name="cmake-$VERSION-$platform" | ||
| # From cmake-<version>-SHA-256.txt of each Kitware release. | ||
| case "$name.$extension" in | ||
| cmake-4.4.4-linux-x86_64.tar.gz) expected=e5bb807f7728cb60cd8b27ebc97a2edb469b68655f21e844a600c3575b76f5bb ;; | ||
| cmake-4.4.4-macos-universal.tar.gz) expected=4b7b73704b1db9b374e5c9ab8e17ac6148b817b6396ee75cd94a852cbac9d305 ;; | ||
| cmake-4.4.4-windows-x86_64.zip) expected=bace36e94b31c68ab6fa295f26dfa11219e0701cf7c94b0284a7d1cb13dac536 ;; | ||
| cmake-4.3.1-linux-x86_64.tar.gz) expected=208d76804009cbe8ec9aea0aa052c857c6e59bd289b43b9941c99324dc78b1d8 ;; | ||
| cmake-4.3.1-macos-universal.tar.gz) expected=c21fe4ade82a6a236aae0b9fbd8263c7ac6824a3fb32d03594456e30b06f3b7f ;; | ||
| cmake-4.3.1-windows-x86_64.zip) expected=03a610be931546474e46a442d171ef10532f4fc847de9cf76b7a8065bbef6a23 ;; | ||
| *) echo "::error::No pinned SHA-256 for $name.$extension: add it to .github/actions/setup-cmake/action.yml"; exit 1 ;; | ||
| esac | ||
| archive="$RUNNER_TEMP/$name.$extension" | ||
| curl -fsSL --retry 5 --retry-all-errors --retry-delay 15 -o "$archive" \ | ||
| "https://github.com/Kitware/CMake/releases/download/v$VERSION/$name.$extension" | ||
| # From standard input: with a file name, sha256sum escapes a Windows path and prefixes the hash with "\". | ||
| if command -v sha256sum > /dev/null; then actual=$(sha256sum < "$archive" | cut -d' ' -f1) | ||
| else actual=$(shasum -a 256 < "$archive" | cut -d' ' -f1); fi | ||
| if [ "$actual" != "$expected" ]; then | ||
| echo "::error::$name.$extension has SHA-256 $actual, expected $expected"; exit 1 | ||
| fi | ||
| if [ "$extension" = zip ]; then | ||
| pwsh -NoProfile -Command "Expand-Archive -LiteralPath '$(cygpath -w "$archive")' -DestinationPath '$(cygpath -w "$RUNNER_TEMP")' -Force" | ||
| cygpath -w "$RUNNER_TEMP/$name/$bin" >> "$GITHUB_PATH" | ||
| else | ||
| tar -xzf "$archive" -C "$RUNNER_TEMP" | ||
| echo "$RUNNER_TEMP/$name/$bin" >> "$GITHUB_PATH" | ||
| fi | ||
| "$RUNNER_TEMP/$name/$bin/cmake" --version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # The Linux CEF file copy of cmake/CEFSupport.cmake, with stand-in CEF files: one copy per destination, which is the | ||
| # target's own output directory; nothing copied again by a build with nothing to copy; explicit errors for the output | ||
| # directories it cannot honour. No compiler, SDK or network. | ||
| # cmake -DROOT=<checkout> [-DTEST_GENERATOR=<generator>] -P test/cmake/CheckCEFCopy.cmake | ||
| cmake_minimum_required(VERSION 3.31) | ||
| if(NOT ROOT) | ||
| message(FATAL_ERROR "ROOT must be supplied") | ||
| endif() | ||
| set(generator_args "") | ||
| if(TEST_GENERATOR) | ||
| list(APPEND generator_args -G "${TEST_GENERATOR}") | ||
| endif() | ||
| set(work "${CMAKE_CURRENT_BINARY_DIR}/cef-copy") | ||
| set(source "${work}/source") | ||
| file(REMOVE_RECURSE "${work}") | ||
| file(WRITE "${source}/libcef.so" "library 1") | ||
| file(WRITE "${source}/locales/en-US.pak" "locale") | ||
|
|
||
| function(configure state out_result out_log) | ||
| execute_process( | ||
| COMMAND "${CMAKE_COMMAND}" -S "${ROOT}/test/cmake/cef-copy" -B "${work}/${state}" ${generator_args} | ||
| -DROOT=${ROOT} -DSOURCE_DIR=${source} -DSTATE=${state} -DCMAKE_BUILD_TYPE=Release | ||
| RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error) | ||
| set(${out_result} ${result} PARENT_SCOPE) | ||
| set(${out_log} "${output}${error}" PARENT_SCOPE) | ||
| endfunction() | ||
|
|
||
| function(build out_log) | ||
| execute_process(COMMAND "${CMAKE_COMMAND}" --build "${work}/plan" --config Release | ||
| RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error) | ||
| if(NOT result EQUAL 0) | ||
| message(FATAL_ERROR "Build of the copy fixture failed: ${output}${error}") | ||
| endif() | ||
| set(${out_log} "${output}${error}" PARENT_SCOPE) | ||
| endfunction() | ||
|
|
||
| function(expect_file path content) | ||
| if(NOT EXISTS "${path}") | ||
| message(FATAL_ERROR "Missing copied file ${path}") | ||
| endif() | ||
| file(READ "${path}" actual) | ||
| if(NOT actual STREQUAL content) | ||
| message(FATAL_ERROR "${path} holds '${actual}', expected '${content}'") | ||
| endif() | ||
| endfunction() | ||
|
|
||
| configure(plan result log) | ||
| if(NOT result EQUAL 0) | ||
| message(FATAL_ERROR "Copy destinations: ${log}") | ||
| endif() | ||
| build(first) | ||
| string(REGEX MATCHALL "Copying CEF libcef.so to [^\n]*" copies "${first}") | ||
| list(LENGTH copies count) | ||
| if(NOT count EQUAL 2) | ||
| message(FATAL_ERROR "Each of the two destinations must be copied once, got ${count}: ${first}") | ||
| endif() | ||
| foreach(destination "${work}/plan" "${work}/plan/bin") | ||
| if(NOT EXISTS "${destination}/libcef.so" AND EXISTS "${destination}/Release/libcef.so") | ||
| set(destination "${destination}/Release") | ||
| endif() | ||
| expect_file("${destination}/libcef.so" "library 1") | ||
| expect_file("${destination}/locales/en-US.pak" "locale") | ||
| endforeach() | ||
| build(second) | ||
| if(second MATCHES "Copying CEF") | ||
| message(FATAL_ERROR "A build with nothing to copy must copy nothing: ${second}") | ||
| endif() | ||
| file(WRITE "${source}/libcef.so" "library 2") | ||
| build(third) | ||
| if(NOT third MATCHES "Copying CEF libcef.so" OR third MATCHES "Copying CEF locales") | ||
| message(FATAL_ERROR "Only the changed file must be copied again: ${third}") | ||
| endif() | ||
| foreach(destination "${work}/plan" "${work}/plan/bin") | ||
| if(NOT EXISTS "${destination}/libcef.so" AND EXISTS "${destination}/Release/libcef.so") | ||
| set(destination "${destination}/Release") | ||
| endif() | ||
| expect_file("${destination}/libcef.so" "library 2") | ||
| endforeach() | ||
|
|
||
| configure(per-config result log) | ||
| # CMake wraps long messages: any whitespace may separate the words. | ||
| if(result EQUAL 0 OR NOT log MATCHES "sets[ \t\r\n]+RUNTIME_OUTPUT_DIRECTORY_RELEASE") | ||
| message(FATAL_ERROR "A per-configuration output directory must be refused: ${log}") | ||
| endif() | ||
| configure(late result log) | ||
| if(result EQUAL 0 OR NOT log MATCHES "now[ \t\r\n]+builds[ \t\r\n]+into") | ||
| message(FATAL_ERROR "An output directory set after the copy was planned must be refused: ${log}") | ||
| endif() | ||
| message(STATUS "CEF copy destinations, incremental copies and refusals checked") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: ambroise-leclerc/WebFront
Length of output: 10002
🏁 Script executed:
Repository: ambroise-leclerc/WebFront
Length of output: 582
🌐 Web query:
official CMake add_custom_command OUTPUT path normalization duplicate outputs trailing slash ..💡 Result:
🌐 Web query:
site:github.com/Kitware/CMake cmMakefile AddCustomCommandToOutput duplicate output normalized path💡 Result:
🌐 Web query:
official CMake cmake_path NORMAL_PATH trailing slash root directory💡 Result:
Normaliser la destination avant de calculer la clé de copie.
_cef_shared_copycalcule la clé MD5 à partir du chemin brut. Deux alias du même répertoire produisent donc deux cibles de copie. CMake normalise ensuite les chemins des règlesOUTPUT. Les deux règles peuvent alors désigner le même fichier et provoquer une erreur de génération. La course d’exécution n’est pas nécessaire pour reproduire ce problème.Normalisez les destinations sans expression générateur avant d’ajouter
$<CONFIG>. Préservez le chemin racine.♻️ Correctif proposé
Ajoutez un cas de test où
RUNTIME_OUTPUT_DIRECTORYse termine par/, et vérifiez que les cibles partagent la même cible de copie.🤖 Prompt for AI Agents