Skip to content

Commit

Permalink
fixes #35 with a test
Browse files Browse the repository at this point in the history
  • Loading branch information
ihh committed Dec 30, 2016
1 parent 1512cff commit ae57ec2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
21 changes: 14 additions & 7 deletions prolog/biomake/biomake.pl
Expand Up @@ -435,9 +435,8 @@
rule_target(Rule,T,Opts),
rule_execs(Rule,Execs,Opts),
forall(member(Exec,Execs),
(string_chars(Exec,['@'|EC])
-> (string_chars(ES,EC),
report('~w',[ES],SL,Opts))
(has_modifier(Exec,'@',ES)
-> report('~w',[ES],SL,Opts)
; report('~w',[Exec],SL,Opts))),
flag_as_rebuilt(T).

Expand Down Expand Up @@ -499,14 +498,12 @@
run_execs(Es,T,SL,Opts).

run_exec(Exec,T,SL,Opts) :-
string_chars(Exec,['-'|RealExecChars]),
has_modifier(Exec,'-',RealExec),
!,
string_chars(RealExec,RealExecChars),
run_exec(RealExec,T,SL,[keep_going_on_error(true)|Opts]).
run_exec(Exec,T,SL,Opts) :-
string_chars(Exec,['@'|SilentChars]),
has_modifier(Exec,'@',Silent),
!,
string_chars(Silent,SilentChars),
silent_run_exec(Silent,T,SL,Opts).
run_exec(Exec,T,SL,Opts) :-
running_silent(T,Opts),
Expand All @@ -527,6 +524,16 @@
member(T,TL),
\+ get_opt(dry_run,true,Opts).

has_modifier(InStr,ModChar,StrippedStr) :-
string_chars(InStr,InChars),
phrase(strip_mod(ModChar,StrippedChars),InChars),
string_chars(StrippedStr,StrippedChars).

strip_mod(M,S) --> [' '], strip_mod(M,S).
strip_mod(M,S) --> [M], strip_mod_tail(S).
strip_mod_tail([C|S]) --> [C], strip_mod_tail(S).
strip_mod_tail([]) --> [].

silent_run_exec(Exec,T,SL,Opts) :-
get_time(T1),
shell(Exec,Err),
Expand Down
2 changes: 2 additions & 0 deletions prolog/test/test.pl
Expand Up @@ -80,6 +80,8 @@
run_test("-f Makefile.targetexpr","function_in_deplist"),
run_test("-f Makefile.targetexpr","slash_var_in_deplist"),
run_test("-f Makefile.targetexpr","var_slash_var_in_deplist"),
run_test("-f Makefile.modifier","padded_modifier"),
run_test("-f Makefile.modifier","padded_modifier_from_foreach"),

announce("SPECIAL TARGETS"),
run_test("-f Makefile.oneshell","oneshell"),
Expand Down
1 change: 1 addition & 0 deletions t/ref/padded_modifier
@@ -0,0 +1 @@
Should be silent
1 change: 1 addition & 0 deletions t/ref/padded_modifier_from_foreach
@@ -0,0 +1 @@
a @echo b @echo c @echo d
8 changes: 8 additions & 0 deletions t/target/Makefile.modifier
@@ -0,0 +1,8 @@
# -*- makefile-gmake -*-

X=a b c d
padded_modifier_from_foreach:
$(foreach o, $(X), @echo $o ) >$@

padded_modifier:
@echo Should be silent >$@

0 comments on commit ae57ec2

Please sign in to comment.