Source file preprocessor.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
open Core
let preprocess includes path =
let cmd =
String.concat ~sep:" "
([ "cc" ]
@ List.map ~f:(Printf.sprintf "-I%s") includes
@ [ "-undef"; "-nostdinc"; "-E"; "-x"; "c"; path ])
in
let in_chan = Core_unix.open_process_in cmd in
let program = In_channel.input_all in_chan in
let _ = Core_unix.close_process_in in_chan in
program