-
Notifications
You must be signed in to change notification settings - Fork 4
/
myocamlbuild.ml
150 lines (134 loc) · 4.22 KB
/
myocamlbuild.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
open Nonstd
open Solvuu_build.Std
let (//) = Filename.concat
let failwithf fmt = ksprintf failwith fmt
let project_name = "biokepi"
let version = "0.0.0+dev"
let build_tests =
try Sys.getenv "WITH_TESTS" = "true" with _ -> false
let findlib_deps = [
"ketrew"; "ppx_deriving.std";
]
let ocaml_options (f : _ Project.with_options) =
f ~bin_annot:()
~short_paths:()
~g:()
~w:"+9"
~strict_sequence:()
~safe_string:()
let project_lib =
(ocaml_options Project.lib)
~build_plugin:true
let project_app =
(ocaml_options Project.app)
let meta_dot_ml = "src/run_environment/metadata.ml"
let generate_meta_data () =
let cmd_option cmd =
try
Some (
Ocamlbuild_pack.My_unix.run_and_read cmd
|> fun x -> String.sub x 0 (String.length x - 1)
)
with _ -> None in
let git_last_commit () = cmd_option "git rev-parse HEAD" in
let git_describe () = cmd_option "git describe --tags --long --dirty" in
let option_to_string =
Option.value_map ~default:"None" ~f:(sprintf "Some %S") in
Solvuu_build.Util.Rule.rule
~name:"meta-data-generation"
~prods:[meta_dot_ml]
~deps:[]
~insert:`bottom
begin fun env builder ->
let def name ~doc fmt =
ksprintf (fun s -> sprintf "\n(** %s *)\nlet %s = %s" doc name s) fmt in
let lines =
List.map ~f:(sprintf "%s\n") [
"(** Metadata Module Generated by the Build System *)";
def "version" ~doc:"Official version string of the current build"
"lazy %S" version;
def "git_commit" ~doc:"Current Git commit (if avaiable at build-time)"
"%s" (git_last_commit () |> option_to_string);
def "git_description"
~doc:"Current result of [\"git describe\"] \
(if avaiable at build-time)"
"%s" (git_describe () |> option_to_string);
] in
let open Ocamlbuild_plugin in
Seq [
Echo (lines, meta_dot_ml);
]
end
let run_environment_lib : Project.item =
project_lib (project_name ^ ".run_environment")
~thread:()
~findlib_deps
~ml_files:(`Add [Filename.basename meta_dot_ml])
~dir:"src/run_environment"
~style:(`Pack (project_name ^ "_run_environment"
|> String.capitalize_ascii))
let sub_lib sub ~internal_deps =
let name = project_name ^ "." ^ sub in
project_lib name
~thread:()
~dir:(sprintf "src/%s/" sub)
~internal_deps
~findlib_deps
~style:(`Pack (project_name ^ "_" ^ sub |> String.capitalize_ascii))
let environment_setup_lib : Project.item =
sub_lib "environment_setup"
~internal_deps:[run_environment_lib]
let bfx_tools_lib : Project.item =
sub_lib "bfx_tools" ~internal_deps:[run_environment_lib]
let pipeline_edsl_lib : Project.item =
sub_lib "pipeline_edsl" ~internal_deps:[run_environment_lib; bfx_tools_lib]
let biokepi_lib : Project.item =
project_lib project_name
~thread:()
~findlib_deps
~internal_deps:[run_environment_lib; environment_setup_lib;
pipeline_edsl_lib; bfx_tools_lib]
~dir:"src/lib"
~style:`Basic
let demo : Project.item =
project_app (project_name ^ "-demo")
~thread:()
~file:"src/app/main.ml"
~internal_deps:[biokepi_lib]
let test_apps : Project.item list =
if build_tests
then
begin
let mkt n p = n, p in
let tests = [
mkt "tests" "src/test/main.ml";
mkt "test-all-downloads" "src/test/all_downloads.ml";
mkt "test-ttfi-pipeline" "src/test/ttfi_pipeline.ml";
mkt "hla-typer" "src/app/hla_typer.ml";
mkt "input-generator" "src/app/input_gen.ml";
mkt "edsl-input-json" "src/test/edsl_input_json.ml";
] in
List.map tests ~f:(fun (name, file) ->
project_app (project_name ^ "-" ^ name)
~thread:()
~file
~install:`No
~internal_deps:[biokepi_lib])
end
else []
let ocamlinit_postfix = [
sprintf "open %s" (String.capitalize_ascii project_name);
]
let () =
Project.basic1 ~project_name ~version ~ocamlinit_postfix
~additional_rules:[
generate_meta_data;
]
([
run_environment_lib;
environment_setup_lib;
bfx_tools_lib;
pipeline_edsl_lib;
biokepi_lib;
demo;
] @ test_apps)