|
|
@@ -425,9 +425,11 @@ task :ci_setup_cache do
|
|
|
# AppVeyor on Windows host has different kind of cache mechanism, not based on ccache
|
|
|
if ENV['APPVEYOR']
|
|
|
system "bash -c 'rm -rf #{ENV['build_tree']}'" if clear
|
|
|
- if File.exists?("#{ENV['build_tree']}/.commit")
|
|
|
- last_commit = File.read "#{ENV['build_tree']}/.commit"
|
|
|
- system "bash -c 'find CMakeLists.txt CMake Docs Source |xargs touch -r #{ENV['build_tree']}/CMakeCache.txt && touch $(git diff --name-only #{last_commit} #{ENV['APPVEYOR_REPO_COMMIT']})'"
|
|
|
+ if File.exists?("#{ENV['build_tree']}/.commits")
|
|
|
+ # Find the last valid commit SHA because the recorded commit SHAs may no longer be valid due to git reset/forced push
|
|
|
+ last_commit = File.read("#{ENV['build_tree']}/.commits").split.find { |sha| system "git cat-file -e #{sha}" }
|
|
|
+ # AppVeyor prefers CMD's FIND over MSYS's find, so we have to use fully qualified path to the MSYS's find
|
|
|
+ system "bash -c '/c/Program\\ Files/Git/usr/bin/find CMakeLists.txt CMake Docs Source |xargs touch -r #{ENV['build_tree']}/CMakeCache.txt && touch $(git diff --name-only #{last_commit} #{ENV['APPVEYOR_REPO_COMMIT']})'"
|
|
|
end
|
|
|
next
|
|
|
# Use internal cache store instead of using Travis CI one (this is a workaround for using ccache on Travis CI legacy build infra)
|
|
|
@@ -453,9 +455,11 @@ desc 'Teardown build cache'
|
|
|
task :ci_teardown_cache do
|
|
|
# AppVeyor on Windows host has different kind of cache mechanism, not based on ccache
|
|
|
if ENV['APPVEYOR']
|
|
|
- File.write("#{ENV['build_tree']}/.commit", ENV['APPVEYOR_REPO_COMMIT']) if Dir.exist?(ENV['build_tree'])
|
|
|
- # Temporarily exclude build artifacts from being cached due to cache size limitation
|
|
|
- system "bash -c 'rm #{ENV['build_tree']}/bin/*.{exe,dll}'"
|
|
|
+ # Keep the last 10 commit SHAs
|
|
|
+ commits = (File.exists?("#{ENV['build_tree']}/.commits") ? File.read("#{ENV['build_tree']}/.commits").split : []).unshift(`git rev-parse #{ENV['APPVEYOR_REPO_COMMIT']}`.chomp).take 10
|
|
|
+ File.open("#{ENV['build_tree']}/.commits", 'w') { |file| file.puts commits } if Dir.exist?(ENV['build_tree'])
|
|
|
+ # Exclude build artifacts from being cached due to cache size limitation
|
|
|
+ system "bash -c 'rm -f #{ENV['build_tree']}/bin/*.{exe,dll}'"
|
|
|
next
|
|
|
# Upload cache to internal cache store if it is our own
|
|
|
elsif ENV['USE_CCACHE'].to_i == 2
|