Permalink
Browse files

Merge pull request #66 from evoldoers/regex

Regex dependency
  • Loading branch information...
ihh committed Sep 30, 2018
2 parents 04dbee2 + 82d9ea4 commit 19bf1829027af9ebe52a16b6caa3184509cc4b24
Showing with 50 additions and 3 deletions.
  1. 0 .gitmodules
  2. +18 −1 prolog/biomake/biomake.pl
  3. +24 −2 prolog/biomake/queue.pl
  4. +5 −0 prolog/test/test.pl
  5. +1 −0 t/ref/testregex_apple
  6. +2 −0 t/target/Makefile.regex
No changes.
@@ -56,12 +56,16 @@
report_run_exec/4,
update_hash/3,

shell_var_specified/1,

bindvar/3,
bindvar_rule/4,
expand_vars/2,
expand_vars/3
]).

:- use_module(library(pcre)).

:- use_module(library(biomake/utils)).
:- use_module(library(biomake/functions)).
:- use_module(library(biomake/embed)).
@@ -476,6 +480,10 @@
get_opt(oneshell,true,Opts),
!,
run_execs_in_script(Rule,SL,Opts).
run_execs_now(Rule,SL,Opts) :-
shell_var_specified(_),
!,
run_execs_in_script(Rule,SL,Opts).
run_execs_now(Rule,SL,Opts) :-
rule_target(Rule,T,Opts),
rule_dependencies(Rule,DL,Opts),
@@ -542,13 +550,22 @@

silent_run_exec(Exec,T,SL,Opts) :-
get_time(T1),
shell(Exec,Err),
run_shell(Exec,Err),
get_time(T2),
DT is T2-T1,
debug_report(build,' Return: ~w Time: ~w',[Err,DT],SL),
handle_exec_error(Exec,Err,T,SL,Opts),
!.

shell_var_specified(Sh) :-
atom_string(SHELL,"SHELL"),
global_binding(SHELL,Sh).

run_shell(Exec,Err) :-
!,
debug_report(shell,'sh ~w',[Exec]),
shell(Exec,Err).

handle_exec_error(_,0,_,_,_) :- !.
handle_exec_error(Exec,Err,T,SL,Opts) :-
( get_opt(keep_going_on_error,true,Opts)
@@ -193,21 +193,43 @@
append(ShellExecs,ShellCleanup,ExecsWithCleanup),
write_script_file_contents(T,Headers,ExecsWithCleanup,Opts,Subdirs,ScriptFilename).

write_script_file_contents(T,Headers,Execs,_Opts,Subdirs,ScriptFilename) :-
write_script_file_contents(T,Headers,Execs,Opts,Subdirs,ScriptFilename) :-
working_directory(CWD,CWD),
open_script_file(T,Subdirs,ScriptFilename,IO),
shell_path(Sh),
concat_string_list(Execs,ExecStr," &&\n"),
wrap_shell_execs(T,Execs,Opts,Subdirs,ExecStr),
concat_string_list(Headers,HeaderStr,"\n"),
format(IO,"#!~w~n~w~ncd ~w~n~w~n",[Sh,HeaderStr,CWD,ExecStr]),
close(IO),
format(string(Chmod),"chmod +x ~w",[ScriptFilename]),
shell(Chmod).

wrap_shell_execs(T,Execs,_Opts,Subdirs,ShellFilename) :-
shell_var_specified(Sh),
!,
open_shell_file(T,Subdirs,ShellFilename,IO),
concat_string_list(Execs,ExecStr,"\n"),
format(IO,"#!~w~n~w~n",[Sh,ExecStr]),
close(IO),
format(string(Chmod),"chmod +x ~w",[ShellFilename]),
shell(Chmod).

wrap_shell_execs(_T,Execs,_Opts,_Subdirs,ExecStr) :-
!,
join_with_ands(Execs,ExecStr).

join_with_ands(List,Str) :-
!,
concat_string_list(List,Str," &&\n").

open_script_file(Target,Subdirs,Filename,Stream) :-
append(Subdirs,["script"],SubdirsScript),
open_biomake_private_file(Target,SubdirsScript,Filename,Stream).

open_shell_file(Target,Subdirs,Filename,Stream) :-
append(Subdirs,["shell"],SubdirsShell),
open_biomake_private_file(Target,SubdirsShell,Filename,Stream).

% ----------------------------------------
% No queue engine (runs execs immediately)
% ----------------------------------------
@@ -309,6 +309,11 @@
run_test("-f Makefile.dcg","dcg_test"),
run_test("-f Makefile.dcg","mismatch_dcg_test"),

announce("PCRE REGEX LIBRARY"),
run_test("-f Makefile.regex","testregex_apple"),
run_failure_test("-f Makefile.regex","testregex_cat"),
run_failure_test("-f Makefile.regex","testregex_ALBACORE"), % fails due to default case-sensitivity of regexes

% All done
report_counts,
( failed_test(_,_)
@@ -0,0 +1 @@
Fired rule for testregex_apple
@@ -0,0 +1,2 @@
testregex_$(ABC): { re_match('^a',ABC) }
echo Fired rule for $@ >$@

0 comments on commit 19bf182

Please sign in to comment.