Skip to content

Commit

Permalink
use reason for config/discover.ml
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoRFS committed Jun 23, 2020
1 parent 464c5b7 commit 4d07f14
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 111 deletions.
61 changes: 0 additions & 61 deletions src/reason-font-manager/config/discover.ml

This file was deleted.

64 changes: 64 additions & 0 deletions src/reason-font-manager/config/discover.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
type os =
| Windows
| Mac
| Linux
| Unknown;

let uname = () => {
let ic = Unix.open_process_in("uname");
let uname = input_line(ic);
let () = close_in(ic);
uname;
};

let get_os =
switch (Sys.os_type) {
| "Win32" => Windows
| _ =>
switch (uname()) {
| "Darwin" => Mac
| "Linux" => Linux
| _ => Unknown
}
};

let root = Sys.getenv("cur__root");
let c_flags = [];

let ccopt = s => ["-ccopt", s];
let cclib = s => ["-cclib", s];

let flags =
switch (get_os) {
| Windows => [] @ cclib("-ldwrite") @ cclib("-lstdc++")
| Linux =>
[] @ cclib("-lfontconfig") @ cclib("-lstdc++") @ ccopt("-I/usr/include")
| Mac =>
[]
@ ccopt("-framework CoreText")
@ ccopt("-framework Foundation")
@ cclib("-lstdc++")
| _ => []
};

let flags_with_sanitize =
switch (get_os) {
| Linux => flags @ ccopt("-fsanitize=address")
| _ => flags
};

let cxx_flags =
switch (get_os) {
| Linux => c_flags @ ["-fPIC", "-lstdc++"]
| Mac => c_flags @ ["-x", "objective-c++", "-lstdc++"]
| Windows => c_flags @ ["-fno-exceptions", "-fno-rtti", "-lstdc++"]
| _ => c_flags
};

Configurator.V1.Flags.write_sexp("c_flags.sexp", c_flags);
Configurator.V1.Flags.write_sexp("cxx_flags.sexp", cxx_flags);
Configurator.V1.Flags.write_sexp("flags.sexp", flags);
Configurator.V1.Flags.write_sexp(
"flags_with_sanitize.sexp",
flags_with_sanitize,
);
50 changes: 0 additions & 50 deletions src/reason-harfbuzz/config/discover.ml

This file was deleted.

51 changes: 51 additions & 0 deletions src/reason-harfbuzz/config/discover.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
type os =
| Windows
| Mac
| Linux
| Unknown;

let uname = () => {
let ic = Unix.open_process_in("uname");
let uname = input_line(ic);
let () = close_in(ic);
uname;
};

let get_os =
switch (Sys.os_type) {
| "Win32" => Windows
| _ =>
switch (uname()) {
| "Darwin" => Mac
| "Linux" => Linux
| _ => Unknown
}
};

let c_flags = ["-fPIC", "-I", Sys.getenv("HARFBUZZ_INCLUDE_PATH")];

let ccopt = s => ["-ccopt", s];
let cclib = s => ["-cclib", s];

let extraFlags =
switch (get_os) {
| Linux => ccopt("-L/usr/lib")
| _ => []
};

let lib_path_flags =
switch (get_os) {
| _ => [] @ ccopt("-L" ++ Sys.getenv("HARFBUZZ_LIB_PATH"))
};

let flags = [] @ cclib("-lharfbuzz") @ extraFlags @ lib_path_flags;

let cxx_flags =
switch (get_os) {
| Windows => c_flags @ ["-fno-exceptions", "-fno-rtti", "-lstdc++"]
| _ => c_flags
};

Configurator.V1.Flags.write_sexp("c_flags.sexp", c_flags);
Configurator.V1.Flags.write_sexp("cxx_flags.sexp", cxx_flags);
Configurator.V1.Flags.write_sexp("flags.sexp", flags);

0 comments on commit 4d07f14

Please sign in to comment.