Skip to content

Commit

Permalink
Fix #14
Browse files Browse the repository at this point in the history
Remove dependency from non-public dune API
  • Loading branch information
astrada committed Jun 24, 2020
1 parent 323b3fd commit da78a89
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/config/discover.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
open! Stdune
module C = Configurator.V1

let read_file path =
let in_ch = open_in path in
let rec loop acc =
try
let line = input_line in_ch in
loop (acc ^ line)
with End_of_file -> acc
in
try
let result = loop "" in
close_in in_ch;
result
with exc ->
close_in in_ch;
Printf.eprintf "read_file: could not read file: '%s'" path;
raise exc

let () =
C.main ~name:"foo" (fun c ->
let default : C.Pkg_config.package_conf =
Expand All @@ -20,13 +36,13 @@ let () =
Sys.command
(Printf.sprintf "opam config var camlidl:lib > %s" calmidl_fname)
with
| 0 -> String.trim (Io.String_path.read_file calmidl_fname)
| 0 -> String.trim (read_file calmidl_fname)
| _ -> (
match
Sys.command
(Printf.sprintf "ocamlfind query camlidl > %s" calmidl_fname)
with
| 0 -> String.trim (Io.String_path.read_file calmidl_fname)
| 0 -> String.trim (read_file calmidl_fname)
| _ -> C.die "Could not query camlidl lib path" )
in
let camlidl_libs = [ "-L" ^ camlidl_lib_path; "-lcamlidl" ] in
Expand Down

0 comments on commit da78a89

Please sign in to comment.