Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii committed Nov 29, 2024
1 parent af33f2d commit d449132
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions xmake/research.lua
Original file line number Diff line number Diff line change
Expand Up @@ -297,25 +297,6 @@ target("research") do
end
end

function execWithRetry(command, args, maxRetries, retryDelay)
local retries = 0
local result

while retries <= maxRetries do
result = os.execute(command .. " " .. table.concat(args, " "))
if result then
return true, "Command executed successfully"
else
retries = retries + 1
if retries > maxRetries then
return false, "Command failed after " .. maxRetries .. " retries"
else
-- os.execute("sleep " .. retryDelay)
end
end
end
end

target("research_packager") do
set_enabled(is_plat("macosx") and is_mode("release"))
set_kind("phony")
Expand All @@ -341,12 +322,27 @@ target("research_packager") do
local app_dir = target:installdir() .. "/../../"
os.cp("$(buildir)/Info.plist", app_dir .. "/Contents")
os.execv("codesign", {"--force", "--deep", "--sign", "-", app_dir})
hdiutil_command= "/usr/bin/sudo /usr/bin/hdiutil create $(buildir)/" .. dmg_name .. " -fs HFS+ -srcfolder " .. app_dir
local success, message= execWithRetry(hdiutil_command, {}, 5, 1)
if success then
print(message)
else
print("Error: " .. message)

local hdiutil_command= "/usr/bin/sudo /usr/bin/hdiutil create $(buildir)/" .. dmg_name .. " -fs HFS+ -srcfolder " .. app_dir
io.write("Execute: ")
print(hdiutil_command)
print("Remove /usr/bin/sudo if you want to package it by your own")

local maxRetries= 5
local retries = 0
while retries <= maxRetries do
result = os.execv(hdiutil_command)
if result then
return true, "Command executed successfully"
else
retries = retries + 1
if retries > maxRetries then
return false, "Command failed after " .. maxRetries .. " retries"
else
io.write("Retrying, attempt ")
print(retries)
end
end
end
end)
end

0 comments on commit d449132

Please sign in to comment.