Skip to content

Commit 6e80150

Browse files
committed
Misc: fix with optional library
1 parent 198b383 commit 6e80150

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

lib/lwt/graphics/jbuild

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1-
(jbuild_version 1)
1+
(* -*- tuareg -*- *)
2+
#require "unix"
3+
let graphics_exists =
4+
try
5+
let ic = Unix.open_process_in "ocamlfind query -a-format -predicates byte graphics" in
6+
let path = input_line ic in
7+
close_in ic;
8+
Sys.file_exists path
9+
with _ -> false
10+
11+
let () =
12+
let jbuild =
13+
if graphics_exists
14+
then {|
215
(library
316
((name graphics_js)
417
(public_name js_of_ocaml-lwt.graphics)
518
(synopsis "Graphics for js_of_ocaml.")
619
(optional)
720
(libraries (js_of_ocaml js_of_ocaml-lwt lwt graphics))
821
(preprocess (pps (js_of_ocaml-ppx)))))
22+
|}
23+
else {||}
24+
in
25+
Printf.ksprintf Jbuild_plugin.V1.send {|
26+
(jbuild_version 1)
27+
%s
28+
|} jbuild

toplevel/lib/camlp4/jbuild

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1-
(jbuild_version 1)
1+
(* -*- tuareg -*- *)
2+
#require "unix"
3+
let camlp4_exists =
4+
try
5+
let ic = Unix.open_process_in "ocamlfind query -a-format -predicates byte camlp4.lib" in
6+
let path = input_line ic in
7+
close_in ic;
8+
Sys.file_exists path
9+
with _ -> false
10+
11+
let () =
12+
let jbuild =
13+
if camlp4_exists
14+
then {|
215
(library
316
((name js_of_ocaml_toplevel_camlp4)
417
(public_name js_of_ocaml-toplevel.camlp4)
5-
(libraries (js_of_ocaml-toplevel camlp4))
18+
(libraries (js_of_ocaml-toplevel camlp4.lib))
619
(optional)
720
(library_flags (-linkall))
821
(preprocess (pps (js_of_ocaml-ppx)))))
22+
|}
23+
else {||}
24+
in
25+
Printf.ksprintf Jbuild_plugin.V1.send {|
26+
(jbuild_version 1)
27+
%s
28+
|} jbuild

0 commit comments

Comments
 (0)