6 let bifu _rs _pqs dst _src
=
10 let ( let* ) = Result.bind
in
11 let* _
= File.mkdir_p
File.pDir dst
in
12 dst
|> File.out_channel_replace
pfrt
14 let mmk rs t
: (string, string) result
=
15 match Make.M2.find_rule rs t
with
17 let j_src'
= r
.prerequisites
|> List.hd
in
18 let j_src = j_src'
|> Make.Jig.make
in
19 let src = v
|> Make.Jig.paste
j_src |> Option.get
in
20 Logr.info
(fun m
-> m
"%s.%s %s -> %s" "Make_test" "test_fkt.build" src t
);
21 src |> bifu rs r
.prerequisites t
22 | None
-> Error
"no rules found to make" in
23 let rs : Make.t list
= [{
24 target
= "%-%/index.xml";
25 prerequisites
= ["app/var/db/%/%.ix"];
26 fresh
= Make.Outdated
;
27 command
= (fun _ _ _ _
-> Error
"Not implemented");
32 |> Assrt.equals_string __LOC__
"o/p-0/index.xml"
35 let ji = "a%b%c" |> Make.Jig.make
in
36 match Make.Jig.cut
ji "aSomebThingc" with
37 | Some
["Some";"Thing"] as v
->
38 Option.bind v
("A_%_B_%_C" |> Make.Jig.make
|> Make.Jig.paste
)
39 |> Option.value ~default
:"-"
40 |> Assrt.equals_string __LOC__
"A_Some_B_Thing_C"
41 | _
-> "Ouch" |> Assrt.equals_string __LOC__
""
45 let jig_src = "%/%.ix" |> Make.Jig.make
in
46 let jig_dst = "%-%/index.xml" |> Make.Jig.make
in
48 |> Make.Jig.cut
jig_src
50 |> Make.Jig.paste
jig_dst
52 |> Assrt.equals_string __LOC__
"o/p-2/index.xml"
55 let jig = "%/%/%.ix" |> Make.Jig.make
in
61 |> equals_string __LOC__
"foo/bar/baz.ix"
65 Logr.info
(fun m
-> m
"%s" __LOC__
);
67 target
= {|a
/b
-%.xml
|};
68 fresh
= Make.Outdated
;
69 prerequisites
= [{|c
/d
-%.ix
|}];
70 command
= (fun _ _r _rz t
->
71 Logr.info
(fun m
-> m
"%s '%s'" __LOC__ t
);
72 t
|> Assrt.equals_string __LOC__
"a/b-37.xml";
75 Make.M2.make
[r] "a/b-37.xml"
77 |> Assrt.equals_string __LOC__
"a/b-37.xml"