build embed the client with declarative dune rules

The rule that embedded the compiled client shelled out to bash, made a temporary directory with mktemp, copied the file in, ran ocaml-crunch, and cleaned up. It was the one step in the build dune could not see into or cache properly. ocaml-crunch embeds a directory, so a rule in client/ now copies the bundle there under the name the asset route serves, and the parent rule crunches that directory. Both steps are plain dune actions: dune tracks the dependency and reruns only when the client changes. The embedded entry name and content are unchanged.

Commit
e5292fcbf2ed6d3b9fa61dcb7cd84defc3bfa9c2
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/web/client/dune
index 00000000..7b10c2ca 000000..100644
@@ -0,0 +1,10 @@
1 Added: ; The compiled client, under the name the asset route serves. ocaml-crunch
2 Added: ; embeds a directory, and this directory holds exactly this one file. The
3 Added: ; parent directory's crunch rule reads it. A plain copy, so dune tracks the
4 Added: ; dependency and reruns only when the client changes.
5 Added:
6 Added: (rule
7 Added: (target workout_client.js)
8 Added: (deps ../workout_client.bc.js)
9 Added: (action
10 Added: (copy %{deps} %{target})))
lib/web/dune
index bd3423fe..b3bb9153 100644..100644
@@ -23,17 +23,17 @@
23 23 (action
24 24 (run %{bin:ocaml-crunch} --silent --mode plain --output %{targets} assets)))
25 25
26 Added: ; ocaml-crunch embeds a directory, so the compiled client is first copied into
27 Added: ; client/ under the name the asset route serves (see client/dune). This
28 Added: ; declarative pair replaces the earlier shell script with its temporary
29 Added: ; directory: dune tracks both files and the crunch reruns only when the client
30 Added: ; changes.
31 Added:
26 32 (rule
27 33 (target workout_client_asset.ml)
28 Removed: (deps workout_client.bc.js)
34 Added: (deps client/workout_client.js)
29 35 (action
30 Removed: (run
31 Removed: bash
32 Removed: -c
33 Removed: "tmp=$(mktemp -d); cp \"$1\" \"$tmp/workout_client.js\"; %{bin:ocaml-crunch} --silent --mode plain --output \"$2\" \"$tmp\"; rm -rf \"$tmp\""
34 Removed: --
35 Removed: %{dep:workout_client.bc.js}
36 Removed: %{target})))
36 Added: (run %{bin:ocaml-crunch} --silent --mode plain --output %{target} client)))
37 37
38 38 (library
39 39 (name hito_web)