Skip to content

Commit

Permalink
Fix compilation of dune_test_515 on MacOS
Browse files Browse the repository at this point in the history
Signed-off-by: Kakadu <Kakadu@pm.me>
  • Loading branch information
Kakadu committed Jan 27, 2024
1 parent 8189297 commit 80ee2c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 0 additions & 2 deletions dune_test_515/dune
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
-O3)))
(link_flags
(-ccopt
-Wl,-no-as-needed
-ccopt
-fPIC
-cclib
-lstdc++
Expand Down
18 changes: 14 additions & 4 deletions ppx/gencpp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ module FilesKey = struct
| (_, CSRC), (_, CHDR) -> -1
| (_, CHDR), (_, CSRC) -> 1
| (x, _), (y, _) -> cmp_string x y

let realname = function
| (classname, CSRC) -> sprintf "%s_c.%s" classname PpxQtCfg.config.ext
| (classname, CHDR) -> sprintf "%s.h" classname
end

module FilesMap = Stdlib.Map.Make (FilesKey)
Expand All @@ -126,11 +130,17 @@ let get_smart_ppf f ~classname =
let only_open ~classname =
(*print_endline "Opening files....";*)
let destdir = PpxQtCfg.config.destdir in
let ext = PpxQtCfg.config.ext in
let src =
Stdio.Out_channel.create (sprintf "%s/%s_c.%s" destdir classname ext)
let src_name = sprintf "%s/%s" destdir FilesKey.(realname (classname,CSRC)) in
let h_name = sprintf "%s/%s" destdir FilesKey.(realname (classname,CHDR)) in
let () =
(* On MacOS we need to make files writable. No idea why. *)
if Stdlib.Sys.file_exists src_name
then Unix.chmod src_name 0o644;
if Stdlib.Sys.file_exists h_name
then Unix.chmod h_name 0o644;
in
let hdr = Stdio.Out_channel.create (sprintf "%s/%s.h" destdir classname) in
let src = Stdio.Out_channel.create src_name in
let hdr = Stdio.Out_channel.create h_name in
(files := FilesMap.(add (classname, FilesKey.CHDR) hdr !files));
files := FilesMap.(add (classname, FilesKey.CSRC) src !files)

Expand Down

0 comments on commit 80ee2c0

Please sign in to comment.