build: Clone dependencies with git instead of downloading a zip (#10271) a2e64c0505

It was a cool idea to download the repos as a zip, so that premake
didn't have to rely on any external dependencies, but github was
frequently giving us a successful download of an empty zip file. This
was causing daily flakes on CI.

Instead, just invoke 'git clone --depth=1 --branch ...' from premake.
This should hopefully be more reliable, and it seems safe enough to
depend on git being installed in the environment we're on.

Also:

* Update the dependencies that were using raw branch SHAs to point to
  official tags. 'git clone --branch' requires an official tag, and this
  will be more stable anyway.

* Rename the dependency directories to "owner_project_tag" rather than a
  hash. Sometimes we need to poke around in those directories to debug
  issues, and it's easier to figure out what's what with descriptive
  names.

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
This commit is contained in:
csmartdalton
2025-07-29 22:47:57 +00:00
parent 6eccf329cd
commit dd7a2155de
4 changed files with 23 additions and 37 deletions

View File

@@ -1 +1 @@
45e1b18c68de6288d122ee4345ccb9b004b219f0
a2e64c0505870c2a33e74cf4407989dd70f49387

View File

@@ -17,39 +17,25 @@ function m.github(project, tag)
dependencies = path.getabsolute(_WORKING_DIR) .. '/dependencies'
os.mkdir(dependencies)
end
local hash = string.sub(string.sha1(project .. tag), 0, 9)
if not os.isdir(dependencies .. '/' .. hash) then
function progress(total, current)
local ratio = current / total
ratio = math.min(math.max(ratio, 0), 1)
local percent = math.floor(ratio * 100)
if total == current then
iop('')
else
iop('Downloading ' .. project .. ' ' .. percent .. '%')
local dirname = project .. '_' .. tag
dirname = string.gsub(dirname, '/', '_')
local dependency_path = dependencies .. '/' .. dirname
if not os.isdir(dependency_path) then
print('Fetching dependency ' .. project .. ' at tag ' .. tag .. '...')
local gitcmd = 'git -c advice.detachedHead=false -C '
.. dependencies
.. ' clone --depth 1 --branch '
.. tag
.. ' https://github.com/'
.. project
.. '.git'
.. ' '
.. dirname
if not os.execute(gitcmd) then
error('\nError executing command:\n ' .. cmd)
end
end
local downloadFilename = dependencies .. '/' .. hash .. '.zip'
http.download(
'https://github.com/' .. project .. '/archive/' .. tag .. '.zip',
downloadFilename,
-- Download progress explodes the github logs with megabytes of text.
-- github runners have a "CI" environment variable.
{
progress = not _OPTIONS['no-download-progress']
and os.getenv('CI') ~= 'true'
and progress,
}
)
print('Downloaded ' .. project .. ' to ' .. dependencies .. '/' .. hash)
zip.extract(downloadFilename, dependencies .. '/' .. hash)
os.remove(downloadFilename)
end
local dirs = os.matchdirs(dependencies .. '/' .. hash .. '/*')
local iter = pairs(dirs)
local currentKey, currentValue = iter(dirs)
return currentValue
assert(os.isdir(dependency_path))
return dependency_path
end
return m

View File

@@ -14,7 +14,7 @@ if _OPTIONS['with_vulkan'] then
vulkan_headers = dependency.github('KhronosGroup/Vulkan-Headers', 'vulkan-sdk-1.3.283')
vulkan_memory_allocator = dependency.github(
'GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator',
'7942b798289f752dc23b0a79516fd8545febd718'
'v3.3.0'
)
defines({
'RIVE_VULKAN',
@@ -96,7 +96,7 @@ else
handle:close()
end
nproc = nproc:gsub('%s+', '') -- remove whitespace
local python_ply = dependency.github('dabeaz/ply', '5c4dc94d4c6d059ec127ee1493c735963a5d2645')
local python_ply = dependency.github('dabeaz/ply', '3.11')
local makecommand = 'make -C '
.. path.getabsolute('src/shaders')
.. ' -j'
@@ -104,7 +104,7 @@ local makecommand = 'make -C '
.. ' OUT='
.. pls_shaders_absolute_dir
local minify_flags = '-p ' .. python_ply .. '/src'
local minify_flags = '-p ' .. python_ply
newoption({
trigger = 'raw_shaders',
description = 'don\'t rename shader variables, or remove whitespace or comments',

View File

@@ -8,7 +8,7 @@ if not vulkan_headers or not vulkan_memory_allocator then
end
local dependency = require('dependency')
vk_bootstrap = dependency.github('charles-lunarg/vk-bootstrap', '30a13b2')
vk_bootstrap = dependency.github('charles-lunarg/vk-bootstrap', 'v1.4.307')
includedirs({ 'include' })