Skip to content

Commit

Permalink
remove support for -p option
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Jan 12, 2021
1 parent b00b4fe commit 7488d99
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Makesure.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
5. [ ] Find a way to share functions
6. [ ] Pre-check? Post-check?
7. [x] make @shell configurable
8. [x] `-p` flag to print generated bash script
8. [ ] \[REJECT] `-p` flag to print generated bash script
9. [x] provide goals to run as argument
10. [x] `-l` flag to show all goals
11. [x] per-goal documentation
Expand Down
31 changes: 3 additions & 28 deletions makesure
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,10 @@ function handle_reached_if( goal_name) {
ReachedIf[goal_name] = trim($0)
}
function do_work( i,j,goal_name,dep_cnt,dep,reached_if_condition,script,my_dir,
function do_work( i,j,goal_name,dep_cnt,dep,reached_if_condition,my_dir,
body,prelude_body,goal_body,goal_bodies,
resolved_goals,cmd,exit_code,
t0,t1,t2) {
script = ""
# if ("tracing" in Options)
# script = issue_line(script, "set -x")
if ("timing" in Options)
t0 = current_time_millis()
Expand All @@ -169,15 +165,12 @@ function do_work( i,j,goal_name,dep_cnt,dep,reached_if_condition,script,my_di
# prelude
body = trim(code[""])
prelude_body = body
script = issue_line(script, my_dir prelude_body)
for (i = 0; i < arr_len(GoalNames); i++) {
goal_name = GoalNames[i]
body = trim(code[goal_name])
script = issue_line(script, "\n" goal_name "() {")
reached_if_condition = ReachedIf[goal_name]
# check valid dependencies
Expand All @@ -200,8 +193,6 @@ function do_work( i,j,goal_name,dep_cnt,dep,reached_if_condition,script,my_di
body = ":"
}
script = issue_line(script, "\n" Shell " -e <<'EOF'")
goal_body = ""
if (!("silent" in Options)) {
goal_body = issue_line(goal_body, " printf \" goal '" goal_name "' \"")
Expand All @@ -223,15 +214,9 @@ function do_work( i,j,goal_name,dep_cnt,dep,reached_if_condition,script,my_di
goal_body = issue_line(goal_body, " " body)
goal_bodies[goal_name] = goal_body
script = issue_line(script, goal_body "EOF\n")
script = issue_line(script, "}")
}
script = issue_resolved_goals_to_run(script, resolved_goals)
# cleanup
if (DefinesFile)
script = issue_line(script, "rm " DefinesFile)
resolve_goals_to_run(resolved_goals)
if ("-d" in Args || "--resolved" in Args) {
printf("Resolved goals to reach for '%s':\n", join(ArgGoals, 0, arr_len(ArgGoals), " "))
Expand All @@ -248,8 +233,6 @@ function do_work( i,j,goal_name,dep_cnt,dep,reached_if_condition,script,my_di
print " " Doc[goal_name, j]
}
}
} else if ("-p" in Args || "--print" in Args) {
print script
} else {
exit_code = shell_exec(my_dir prelude_body)
if (exit_code != 0)
Expand All @@ -276,7 +259,7 @@ function do_work( i,j,goal_name,dep_cnt,dep,reached_if_condition,script,my_di
}
}
function issue_resolved_goals_to_run(script, result, i, goal_name, loop) {
function resolve_goals_to_run(result, i, goal_name, loop) {
if (arr_len(ArgGoals) == 0)
arr_push(ArgGoals, "default")
Expand All @@ -291,14 +274,6 @@ function issue_resolved_goals_to_run(script, result, i, goal_name, loop) {
if (loop[0] == 1) {
die_msg("There is a loop in goal dependencies via " loop[1] " -> " loop[2])
}
script = issue_line(script, "__resolved_goals() {")
for (i = 0; i < arr_len(result); i++) {
script = issue_line(script, " " result[i])
}
script = issue_line(script, "}")
script = issue_line(script, "__resolved_goals")
return script
}
function issue_line(script, line) {
Expand Down
11 changes: 0 additions & 11 deletions tests/1_goals.tush
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ $ cd "$MYDIR"; ./makesure -f tests/1_goals.sh --silent
| bbb
| aaa

$ cd "$MYDIR"; ./makesure -f tests/1_goals.sh -p | bash
| goal 'ddd' ...
| ddd
| goal 'ccc' ...
| ccc
| goal 'bbb' ...
| bbb
| goal 'aaa' ...
| aaa
| goal 'default' [empty].

$ cd "$MYDIR"; ./makesure -f tests/1_goals.sh -l
| Available goals:
| default
Expand Down
5 changes: 0 additions & 5 deletions tests/4_trace.tush
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ $ cd "$MYDIR"; ./makesure -f tests/4_trace.sh -x
| A=aaa
@ + echo A=aaa

$ cd "$MYDIR"; ./makesure -f tests/4_trace.sh -x -p | bash
| goal 'default' ...
| A=aaa
@ + echo A=aaa

$ cd "$MYDIR"; ./makesure -f tests/4_trace.sh --tracing
| goal 'default' ...
| A=aaa
Expand Down
6 changes: 0 additions & 6 deletions tests/6_reached_if.tush
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ $ cd "$MYDIR"; ./makesure -f tests/6_reached_if.sh
| aaa
| goal 'default' [empty].

$ cd "$MYDIR"; ./makesure -f tests/6_reached_if.sh -p | bash
| goal 'bbb' [already satisfied].
| goal 'aaa' ...
| aaa
| goal 'default' [empty].

$ cd "$MYDIR"; ./makesure -f tests/6_reached_if.sh -d
| Resolved goals to reach for 'default':
| bbb
Expand Down

0 comments on commit 7488d99

Please sign in to comment.