-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathocaml_rules.bzl
174 lines (153 loc) · 5.86 KB
/
ocaml_rules.bzl
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under both the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree and the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.
# TODO(cjhopman): This was generated by scripts/hacks/rules_shim_with_docs.py,
# but should be manually edited going forward. There may be some errors in
# the generated docs, and so those should be verified to be accurate and
# well-formatted (and then delete this TODO)
load(":common.bzl", "buck", "prelude_rule")
load(":ocaml_common.bzl", "ocaml_common")
ocaml_binary = prelude_rule(
name = "ocaml_binary",
docs = """
A ocaml\\_binary() rule builds both native and bytecode executables from the supplied set of OCaml and C source files
and dependencies.
Note: Buck is currently tested with 4.X OCaml series.
""",
examples = """
For more examples, check out our [integration tests](https://github.com/facebook/buck/tree/dev/test/com/facebook/buck/features/ocaml/testdata/).
```
ocaml_binary(
name='greet',
srcs=[
'main.ml',
'lex.mll',
'parser.mly',
'hashtable.c',
],
deps=[
':greeting',
':bridge',
],
)
ocaml_library(
name='greeting',
srcs=[
'greeting.ml',
],
deps=[
':join',
],
)
ocaml_library(
name='join',
srcs=[
'join.ml',
],
)
cxx_library(
name='bridge',
srcs=[
'bridge.c',
],
)
```
""",
further = None,
attrs = (
# @unsorted-dict-items
ocaml_common.srcs_arg() |
ocaml_common.deps_arg() |
buck.platform_deps_arg() |
ocaml_common.compiler_flags_arg() |
{
"bytecode_only": attrs.option(attrs.bool(), default = None),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
"linker_flags": attrs.list(attrs.string(), default = []),
"ocamldep_flags": attrs.list(attrs.arg(), default = []),
"platform": attrs.option(attrs.string(), default = None),
"platform_compiler_flags": attrs.list(attrs.tuple(attrs.regex(), attrs.list(attrs.arg())), default = []),
"platform_linker_flags": attrs.list(attrs.tuple(attrs.regex(), attrs.list(attrs.string())), default = []),
"warnings_flags": attrs.option(attrs.string(), default = None),
}
),
)
ocaml_library = prelude_rule(
name = "ocaml_library",
docs = """
A ocaml\\_library() rule builds a native and a bytecode libraries from the
supplied set of OCaml source files and dependencies.
Note: Buck is currently tested with 4.X OCaml series.
""",
examples = """
For more examples, check out our [integration tests](https://github.com/facebook/buck/tree/dev/test/com/facebook/buck/features/ocaml/testdata/).
```
ocaml_library(
name='greeting',
srcs=[
'greeting.ml',
],
deps=[
':join',
],
)
```
""",
further = None,
attrs = (
# @unsorted-dict-items
ocaml_common.srcs_arg() |
ocaml_common.deps_arg() |
buck.platform_deps_arg() |
ocaml_common.compiler_flags_arg() |
{
"bytecode_only": attrs.bool(default = False),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"labels": attrs.list(attrs.string(), default = []),
"licenses": attrs.list(attrs.source(), default = []),
"linker_flags": attrs.list(attrs.arg(), default = []),
"native_plugin": attrs.bool(default = False),
"ocamldep_flags": attrs.list(attrs.arg(), default = []),
"platform_compiler_flags": attrs.list(attrs.tuple(attrs.regex(), attrs.list(attrs.arg())), default = []),
"warnings_flags": attrs.option(attrs.string(), default = None),
}
),
)
prebuilt_ocaml_library = prelude_rule(
name = "prebuilt_ocaml_library",
docs = "",
examples = None,
further = None,
attrs = (
# @unsorted-dict-items
{
"bytecode_c_libs": attrs.list(attrs.string(), default = []),
"bytecode_lib": attrs.option(attrs.string(), default = None),
"bytecode_only": attrs.bool(default = False),
"c_libs": attrs.list(attrs.string(), default = []),
"contacts": attrs.list(attrs.string(), default = []),
"default_host_platform": attrs.option(attrs.configuration_label(), default = None),
"deps": attrs.list(attrs.dep(), default = []),
"include_dir": attrs.string(default = ""),
"labels": attrs.list(attrs.string(), default = []),
"lib_dir": attrs.string(default = ""),
"lib_name": attrs.string(default = ""),
"licenses": attrs.list(attrs.source(), default = []),
"native_c_libs": attrs.list(attrs.string(), default = []),
"native_lib": attrs.option(attrs.string(), default = None),
"platform_deps": attrs.list(attrs.tuple(attrs.regex(), attrs.set(attrs.dep(), sorted = True)), default = []),
}
),
)
ocaml_rules = struct(
ocaml_binary = ocaml_binary,
ocaml_library = ocaml_library,
prebuilt_ocaml_library = prebuilt_ocaml_library,
)