-
Notifications
You must be signed in to change notification settings - Fork 9
/
gen.ml
22 lines (18 loc) 路 689 Bytes
/
gen.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(*! Embed resources/* into resources.ml at build time !*)
let read fname =
let inc = open_in (Filename.concat "resources/" fname) in
let contents = really_input_string inc (in_channel_length inc) in
close_in inc;
contents
let quote str =
Str.global_replace (Str.regexp "[\"\\]") "\\\\\\0" str
let defvar out varname fname =
Printf.fprintf out "let %s = \"%s\"" varname (quote (read fname))
let _ =
let out = open_out "resources.ml" in
defvar out "cuttlesim_hpp" "cuttlesim.hpp";
defvar out "cuttlesim_cpp" "cuttlesim.cpp";
defvar out "verilator_hpp" "verilator.hpp";
defvar out "verilator_cpp" "verilator.cpp";
defvar out "makefile" "Makefile";
close_out out