Skip to content

Commit

Permalink
Release 0.9.18 #108
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Feb 11, 2022
1 parent 579ed45 commit 459e6d2
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.9.18
- Optimizations and fixes to `@reached_if` handling in [#104](https://github.com/xonixx/makesure/issues/104) and [#29](https://github.com/xonixx/makesure/issues/29) (thanks @08d2)
- Added autocompletion script for bash in [#75](https://github.com/xonixx/makesure/issues/75)

## v0.9.17
- Allows `@define` in any position in file [#95](https://github.com/xonixx/makesure/issues/95)

Expand Down
2 changes: 1 addition & 1 deletion Makesurefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# vim: syntax=bash
@options timing

@define NEXT_VERSION='0.9.17'
@define NEXT_VERSION='0.9.18'
@define GOAWK_VERSION='1.15.0'
@define JUST_VERSION='0.10.5'
@define GOAWK="goawk$GOAWK_VERSION"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ By default, all scripts inside goals are executed with `bash`. If you want to us

```
$ ./makesure -h
makesure ver. 0.9.17
makesure ver. 0.9.18
Usage: makesure [options...] [-f buildfile] [goals...]
-f,--file buildfile
set buildfile to use (default Makesurefile)
Expand Down
67 changes: 40 additions & 27 deletions makesure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
if command -v gawk >/dev/null;then makesure_awk='gawk -ltime -v Gawk=1';makesure_pre='';else makesure_awk=awk;makesure_pre='function gettimeofday(){}';fi
exec $makesure_awk -v "Version=0.9.17" -v "Prog=$0" "$makesure_pre"'
exec $makesure_awk -v "Version=0.9.18" -v "Prog=$0" "$makesure_pre"'
BEGIN {
Shell = "bash"
SupportedShells["bash"]
Expand Down Expand Up @@ -296,8 +296,13 @@ function checkBeforeRun( i,j,dep,depCnt,goalName,visited) {
}
}
}
function getPreludeCode( a) {
addLine(a, MyDirScript)
addLine(a, DefinesCode)
return a[0]
}
function doWork(\
i,j,goalName,gnLen,gnMaxLen,depCnt,dep,reachedIf,reachedGoals,emptyGoals,definesLine,
i,j,goalName,gnLen,gnMaxLen,depCnt,dep,reachedGoals,emptyGoals,preludeCode,
body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
started("end")
checkBeforeRun()
Expand Down Expand Up @@ -326,37 +331,35 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
} else {
if (timingOn())
t0 = currentTimeMillis()
addLine(definesLine, MyDirScript)
addLine(definesLine, DefinesCode)
for (i = 0; i in GoalNames; i++) {
goalName = GoalNames[i]
body = trim(Code[goalName])
reachedIf = ReachedIf[goalName]
reachedGoals[goalName] = reachedIf ? checkConditionReached(goalName, definesLine[0], reachedIf) : 0
emptyGoals[goalName] = length(body) == 0
depCnt = DependenciesCnt[goalName]
depCnt = DependenciesCnt[goalName = GoalNames[i]]
for (j=0; j < depCnt; j++) {
dep = Dependencies[goalName, j]
if (!reachedGoals[goalName]) {
topologicalSortAddConnection(goalName, dep)
} else {
}
topologicalSortAddConnection(goalName, dep)
}
}
topologicalSort(0,GoalNames)
topologicalSort(1,ArgGoals,resolvedGoals,reachedGoals)
preludeCode = getPreludeCode()
for (i = 0; i in GoalNames; i++) {
goalName = GoalNames[i]
body = trim(Code[goalName])
emptyGoals[goalName] = length(body) == 0
goalBody[0] = ""
addLine(goalBody, definesLine[0])
addLine(goalBody, preludeCode)
if (goalName in GoalToLib)
addLine(goalBody, Lib[GoalToLib[goalName]])
addLine(goalBody, body)
goalBodies[goalName] = goalBody[0]
}
resolveGoalsToRun(resolvedGoals)
if ("-d" in Args || "--resolved" in Args) {
printf "Resolved goals to reach for"
for (i = 0; i in ArgGoals; i++)
printf " %s", quote2(ArgGoals[i],1)
print ":"
for (i = 0; i in resolvedGoals; i++)
print " " quote2(resolvedGoals[i])
if (!reachedGoals[goalName=resolvedGoals[i]] && !emptyGoals[goalName])
print " " quote2(goalName)
} else {
for (i = 0; i in resolvedGoals; i++) {
goalName = resolvedGoals[i]
Expand All @@ -382,15 +385,16 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
}
}
}
function resolveGoalsToRun(result, i, goalName, loop) {
if (arrLen(ArgGoals) == 0)
arrPush(ArgGoals, "default")
for (i = 0; i in ArgGoals; i++) {
goalName = ArgGoals[i]
function topologicalSort(includeReachedIf,requestedGoals,result,reachedGoals, i,goalName,loop) {
topologicalSortReset()
if (arrLen(requestedGoals) == 0)
arrPush(requestedGoals, "default")
for (i = 0; i in requestedGoals; i++) {
goalName = requestedGoals[i]
if (!(goalName in GoalsByName)) {
die("Goal not found: " goalName)
}
topologicalSortPerform(goalName, result, loop)
topologicalSortPerform(includeReachedIf,reachedGoals, goalName, result, loop)
}
if (loop[0] == 1) {
die("There is a loop in goal dependencies via " loop[1] " -> " loop[2])
Expand All @@ -412,8 +416,8 @@ function die(msg, out) {
close(out)
realExit(1)
}
function checkConditionReached(goalName, definesLine, conditionStr, script) {
script = definesLine
function checkConditionReached(goalName, conditionStr, script) {
script = getPreludeCode()
if (goalName in GoalToLib)
script = script "\n" Lib[GoalToLib[goalName]]
script = script "\n" conditionStr
Expand Down Expand Up @@ -455,16 +459,25 @@ function addCodeLine(line, goalName, name, i) {
function addCodeLineToGoal(name, line) {
Code[name] = addL(Code[name], line)
}
function topologicalSortReset() {
split("",Visited)
}
function topologicalSortAddConnection(from, to) {
Slist[from, ++Scnt[from]] = to
}
function topologicalSortPerform(node, result, loop, i, s) {
function topologicalSortPerform(includeReachedIf,reachedGoals, node, result, loop, i, s) {
if (Visited[node] == 2)
return
if (includeReachedIf && node in ReachedIf && checkConditionReached(node, ReachedIf[node])){
Visited[node] = 2
arrPush(result, node)
reachedGoals[node] = 1
return
}
Visited[node] = 1
for (i = 1; i <= Scnt[node]; i++) {
if (Visited[s = Slist[node, i]] == 0)
topologicalSortPerform(s, result, loop)
topologicalSortPerform(includeReachedIf,reachedGoals, s, result, loop)
else if (Visited[s] == 1) {
loop[0] = 1
loop[1] = s
Expand Down
2 changes: 1 addition & 1 deletion makesure_candidate
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
if command -v gawk >/dev/null;then makesure_awk='gawk -ltime -v Gawk=1';makesure_pre='';else makesure_awk=awk;makesure_pre='function gettimeofday(){}';fi
exec $makesure_awk -v "Version=0.9.17" -v "Prog=$0" "$makesure_pre"'
exec $makesure_awk -v "Version=0.9.18" -v "Prog=$0" "$makesure_pre"'
BEGIN {
Shell = "bash"
SupportedShells["bash"]
Expand Down

0 comments on commit 459e6d2

Please sign in to comment.