From 4c4968dc44a41c4d6f5dc1b462b165f57b98c78d Mon Sep 17 00:00:00 2001 From: Keryan Didier Date: Fri, 14 Jun 2024 12:02:38 +0200 Subject: [PATCH] Don't let dune forget html pages (#153) --- examples/configure.ml | 27 ++++++++++++++++----------- examples/dune.inc | 19 ++++++------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/examples/configure.ml b/examples/configure.ml index ba5f872..8438a15 100644 --- a/examples/configure.ml +++ b/examples/configure.ml @@ -11,7 +11,11 @@ let has_jsoo = maj > 3 || maj = 3 && min >= 6 with _ -> false -let add_executable name assets = +let htmls = ref [] + +let add_executable ?(custom_html=false) name assets = + if not custom_html then + htmls := (name^".html")::!htmls; Printf.printf {| (executable (name %s) @@ -27,7 +31,6 @@ let add_executable name assets = (rule (target %s-extfs.js) (action (run js_of_ocaml build-fs -o %%{target} -I ../assets%t))) - |} name name (fun oc -> List.iter (fun a -> Printf.printf {| @@ -39,14 +42,6 @@ let add_executable name assets = let () = set_binary_mode_out stdout true; - if has_jsoo then - Printf.printf {| -(rule - (target index.html) - (deps (glob_files *.js)) - (action (run ./make_index/make_index.exe %%{target}))) - -|}; add_executable "hello" [ "frog.png" ]; add_executable "ppm_dump" []; add_executable "arcs" []; @@ -62,7 +57,7 @@ let () = add_executable "spritesheet" [ "spritesheet.png" ]; add_executable "draw" [ "colors.png" ]; add_executable "window_with_textbox" []; - add_executable "suncities" []; + add_executable ~custom_html:true "suncities" []; add_executable "demo1" []; add_executable "demo2" []; @@ -71,3 +66,13 @@ let () = add_executable "demo5" []; add_executable "demo6" []; add_executable "saucisse" []; + + if has_jsoo then + Printf.printf {| +(rule + (targets index.html %s) + (deps (glob_files *.js)) + (action (run ./make_index/make_index.exe %%{targets}))) + +|} + (String.concat " " !htmls); diff --git a/examples/dune.inc b/examples/dune.inc index e2ecc16..148d7bd 100644 --- a/examples/dune.inc +++ b/examples/dune.inc @@ -1,10 +1,4 @@ -(rule - (target index.html) - (deps (glob_files *.js)) - (action (run ./make_index/make_index.exe %{target}))) - - (executable (name hello) (public_name ocaml-canvas-hello) @@ -19,7 +13,6 @@ (action (run js_of_ocaml build-fs -o %{target} -I ../assets frog.png:/static/assets/))) - (executable (name ppm_dump) (public_name ocaml-canvas-ppm_dump) @@ -83,7 +76,6 @@ fabric.png:/static/assets/ dragon.png:/static/assets/))) - (executable (name aim_with_mouse) (public_name ocaml-canvas-aim_with_mouse) @@ -106,7 +98,6 @@ (action (run js_of_ocaml build-fs -o %{target} -I ../assets dragon.png:/static/assets/))) - (executable (name hexagon_grid) (public_name ocaml-canvas-hexagon_grid) @@ -121,7 +112,6 @@ (action (run js_of_ocaml build-fs -o %{target} -I ../assets hexagon.png:/static/assets/))) - (executable (name ball) (public_name ocaml-canvas-ball) @@ -136,7 +126,6 @@ (action (run js_of_ocaml build-fs -o %{target} -I ../assets dragon.png:/static/assets/))) - (executable (name spritesheet) (public_name ocaml-canvas-spritesheet) @@ -151,7 +140,6 @@ (action (run js_of_ocaml build-fs -o %{target} -I ../assets spritesheet.png:/static/assets/))) - (executable (name draw) (public_name ocaml-canvas-draw) @@ -166,7 +154,6 @@ (action (run js_of_ocaml build-fs -o %{target} -I ../assets colors.png:/static/assets/))) - (executable (name window_with_textbox) (public_name ocaml-canvas-window_with_textbox) @@ -238,3 +225,9 @@ (modules saucisse) (libraries ocaml-canvas react)) + +(rule + (targets index.html saucisse.html demo6.html demo5.html demo4.html demo3.html demo2.html demo1.html window_with_textbox.html draw.html spritesheet.html ball.html hexagon_grid.html clipping.html aim_with_mouse.html compositions.html dashing_line.html thicklines.html snake.html gradients.html arcs.html ppm_dump.html hello.html) + (deps (glob_files *.js)) + (action (run ./make_index/make_index.exe %{targets}))) +