Skip to content

Instantly share code, notes, and snippets.

@tekknolagi
Created February 24, 2017 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekknolagi/1d0c58396db2fb1971e819d2ee86b469 to your computer and use it in GitHub Desktop.
Save tekknolagi/1d0c58396db2fb1971e819d2ee86b469 to your computer and use it in GitHub Desktop.
open Ocamlbuild_pack
open Ocamlbuild_plugin
let astgen = "./astgen.native"
let compile_c ~impl ~native tags arg out =
let tags =
tags ++ "ocaml" ++ (if native then "native" else "byte") ++ "compile"
in
let specs =
[ if native then !Options.ocamlopt else !Options.ocamlc;
A "-c";
T tags;
Ocaml_utils.ocaml_ppflags tags;
Ocaml_utils.ocaml_include_flags arg;
A "-pp"; P astgen;
A "-o"; Px out;
A "-impl"; P arg ]
in
Cmd (S specs);;
let byte_compile_scm_implem ?tag scm cmo env build =
let scm = env scm and cmo = env cmo in
Ocaml_compiler.prepare_compile build scm;
compile_c ~impl:true
~native:false
(Tags.union (tags_of_pathname scm) (tags_of_pathname cmo)++"implem"+++tag)
scm
cmo;;
rule "scm -> cmo"
~prod:"%.cmo"
~deps:["%.scm"]
(byte_compile_scm_implem ~tag:"debug" "%.scm" "%.cmo")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment