Skip to content

Commit

Permalink
On Mac the timings are incorrect #50
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Sep 17, 2021
1 parent 507821d commit 1833953
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ function topologicalSortPerform(node, result, loop, i, s) {

function currentTimeMillis( script, res) {
res = executeGetLine("date +%s%3N")
sub(/%3N/, "000", res) # if date doesn't support %N (macos?) just use second-precision
sub(/%?3N/, "000", res) # if date doesn't support %N (macos?) just use second-precision
return +res
}

Expand Down
33 changes: 15 additions & 18 deletions makesure_stable
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function checkBeforeRun( i,dep,depCnt) {
}
}
function doWork(\
i,j,goalName,depCnt,dep,reachedIf,reachedGoals,emptyGoals,definesLine,
i,j,goalName,gnLen,gnMaxLen,depCnt,dep,reachedIf,reachedGoals,emptyGoals,definesLine,
body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
started("end")
checkBeforeRun()
Expand All @@ -293,13 +293,20 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
list="-l" in Args || "--list" in Args
if (list || "-la" in Args || "--list-all" in Args) {
print "Available goals:"
for (i = 0; i in GoalNames; i++) {
goalName = GoalNames[i]
if (list && GoalsByName[goalName])
continue
if ((gnLen = length(goalName)) > gnMaxLen && gnLen <= 30)
gnMaxLen = gnLen
}
for (i = 0; i in GoalNames; i++) {
goalName = GoalNames[i]
if (list && GoalsByName[goalName])
continue
printf " "
if (goalName in Doc)
printf "%s - %s\n", goalName, Doc[goalName]
printf "%-" gnMaxLen "s : %s\n", goalName, Doc[goalName]
else
print goalName
}
Expand Down Expand Up @@ -335,18 +342,6 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
}
}
goalBody[0] = ""
if (!("silent" in Options)) {
addStr(goalBody, "echo \" goal '\''" goalName "'\'' ")
if (reachedGoals[goalName])
addStr(goalBody, "[already satisfied].")
else if (emptyGoals[goalName])
addStr(goalBody, "[empty].")
else
addStr(goalBody, "...")
addStr(goalBody, "\"")
}
if (reachedGoals[goalName])
addLine(goalBody, "exit 0")
addLine(goalBody, definesLine[0])
if (goalName in GoalToLib)
addLine(goalBody, Lib[GoalToLib[goalName]])
Expand All @@ -367,7 +362,9 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
goalTimed = "timing" in Options && !reachedGoals[goalName] && !emptyGoals[goalName]
if (goalTimed)
t1 = t2 ? t2 : currentTimeMillis()
exitCode = shellExec(goalBodies[goalName])
if (!("silent" in Options))
print " goal '\''" goalName "'\'' " (reachedGoals[goalName] ? "[already satisfied]." : emptyGoals[goalName] ? "[empty]." : "...")
exitCode = (reachedGoals[goalName] || emptyGoals[goalName]) ? 0 : shellExec(goalBodies[goalName])
if (exitCode != 0)
print " goal '\''" goalName "'\'' failed"
if (goalTimed) {
Expand Down Expand Up @@ -467,8 +464,8 @@ function topologicalSortPerform(node, result, loop, i, s) {
}
function currentTimeMillis( script, res) {
res = executeGetLine("date +%s%3N")
sub(/%3N/, "000", res)
return res + 0
sub(/%?3N/, "000", res)
return +res
}
function selfUpdate( url, tmp, err, newVer) {
url = "https://raw.githubusercontent.com/xonixx/makesure/main/makesure_stable?token=" rand()
Expand Down Expand Up @@ -544,7 +541,7 @@ function addStr(target, str) { target[0] = target[0] str }
function addLine(target, line) { target[0] = addL(target[0], line) }
function addL(s, l) { return s ? s "\n" l : l }
function arrPush(arr, elt) { arr[arr[-7]++] = elt }
function arrLen(arr) { return 0 + arr[-7] }
function arrLen(arr) { return +arr[-7] }
function arrLast(arr) { return arr[arrLen(arr)-1] }
function commandExists(cmd) { return ok("command -v " cmd " >/dev/null") }
function ok(cmd) { return system(cmd) == 0 }
Expand Down

0 comments on commit 1833953

Please sign in to comment.