-
Notifications
You must be signed in to change notification settings - Fork 31
/
BUILD
214 lines (202 loc) · 7.09 KB
/
BUILD
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package(licenses = ["notice"])
filegroup(
name = "headers_for_export",
srcs = glob(
["*.h"],
exclude = [
"jni_bind_release.h",
"jni_bind_release_for_testing.h",
":jni_bind_release_target",
],
),
visibility = ["//visibility:public"],
)
exports_files(["LICENSE"])
################################################################################
# JNI Bind
#
# Depend on this target to include JNI Bind in your own target.
# For further documentation see https://github.com/google/jni-bind.
################################################################################
cc_library(
name = "jni_bind",
hdrs = ["jni_bind.h"],
visibility = ["//visibility:public"],
deps = [
":jni_dep",
"//class_defs:java_lang_classes",
"//class_defs:java_lang_exception",
"//class_defs:java_lang_throwable",
"//class_defs:java_util_array_list",
"//class_defs:java_util_classes",
"//implementation:array",
"//implementation:array_type_conversion",
"//implementation:array_view",
"//implementation:class",
"//implementation:class_loader",
"//implementation:configuration",
"//implementation:constructor",
"//implementation:default_class_loader",
"//implementation:extends",
"//implementation:field",
"//implementation:find_class_fallback",
"//implementation:forward_declarations",
"//implementation:global_class_loader",
"//implementation:global_object",
"//implementation:global_string",
"//implementation:id",
"//implementation:id_type",
"//implementation:jni_type",
"//implementation:jvm",
"//implementation:jvm_ref",
"//implementation:loaded_by",
"//implementation:local_array",
"//implementation:local_array_string",
"//implementation:local_class_loader",
"//implementation:local_object",
"//implementation:local_string",
"//implementation:method",
"//implementation:no_idx",
"//implementation:params",
"//implementation:promotion_mechanics",
"//implementation:promotion_mechanics_tags",
"//implementation:proxy_convenience_aliases",
"//implementation:ref_base",
"//implementation:return",
"//implementation:selector_static_info",
"//implementation:self",
"//implementation:static",
"//implementation:static_ref",
"//implementation:string_ref",
"//implementation:supported_class_set",
"//implementation:thread_guard",
"//implementation/jni_helper",
"//implementation/jni_helper:fake_test_constants",
"//implementation/jni_helper:field_value_getter",
"//implementation/jni_helper:invoke_static",
"//implementation/jni_helper:jni_env",
"//implementation/jni_helper:lifecycle",
"//implementation/jni_helper:static_field_value",
"//metaprogramming:corpus",
"//metaprogramming:corpus_tag",
],
)
# Intentionally placed at root because of issues in Bazel.
# Note: This target is mangled for 3rd party usage on export.
# In the future, hopefully Google add Android support, although, unlikely.
cc_library(
name = "jni_dep",
srcs = ["@bazel_tools//tools/jdk:current_java_runtime"],
hdrs = ["jni_dep.h"],
includes =
select({
"@platforms//os:linux": ["external/local_jdk/include/linux"],
"@platforms//os:macos": ["external/local_jdk/include/darwin"],
"//conditions:default": [],
}) + [
"external/local_jdk/include",
],
visibility = [":__subpackages__"],
deps = ["@bazel_tools//tools/jdk:jni"],
)
################################################################################
# Testing Targets.
################################################################################
cc_library(
name = "jni_test",
testonly = 1,
hdrs = ["jni_test.h"],
tags = ["nozapfhahn"],
visibility = [":__subpackages__"],
deps = [
":jni_bind",
":mock_jni_env",
":mock_jvm",
"@googletest//:gtest_main",
],
)
cc_library(
name = "mock_jni_env",
testonly = 1,
hdrs = ["mock_jni_env.h"],
tags = ["nozapfhahn"],
visibility = [":__subpackages__"],
deps = [
"//:jni_dep",
"@googletest//:gtest_main",
],
)
cc_library(
name = "mock_jvm",
testonly = 1,
hdrs = ["mock_jvm.h"],
tags = ["nozapfhahn"],
visibility = [":__subpackages__"],
deps = [
"//:jni_dep",
"@googletest//:gtest_main",
],
)
################################################################################
# Release targets.
################################################################################
# for_testing release header for easy adoption to 3P Customers.
# Strictly used for building a copy for the public, do not depend on this.
genrule(
name = "gen_jni_bind_release",
outs = ["jni_bind_release.h"],
cmd = "./$(location build_jni_bind_release.sh) $(location jni_bind_release_input) jni_wrapper $(locations :jni_bind_decorative_text)>$@",
tools = [
":build_jni_bind_release.sh",
":headers_for_export",
":jni_bind_decorative_text",
":jni_bind_release_input",
"//class_defs:headers_for_export",
"//implementation:headers_for_export",
"//implementation/jni_helper:headers_for_export",
"//metaprogramming:headers_for_export",
],
visibility = ["//third_party/jni_wrapper/godbolt:__pkg__"],
)
# Copy of the release header (above) that uses a different filename.
# Strangely, if a file is present with the same name as what's in outs blaze
# will ignore the genrule and depend on the real header, but it will fail
# because there is no cc_library providing the header. jni_bind_release.h is
# checked in, so the above *will* fail.
genrule(
name = "gen_jni_bind_release_for_testing",
outs = ["jni_bind_release_for_testing.h"],
cmd = './$(location build_jni_bind_release.sh) $(location jni_bind_release_input) jni_wrapper $(locations :jni_bind_decorative_text) | sed "s/__JNI_BIND_VERSION__/`cat $(locations JNI_BIND_VERSION.inc)`/" >$@',
tools = [
":JNI_BIND_VERSION.inc",
":build_jni_bind_release.sh",
":headers_for_export",
":jni_bind_decorative_text",
":jni_bind_release_input",
"//class_defs:headers_for_export",
"//implementation:headers_for_export",
"//implementation/jni_helper:headers_for_export",
"//metaprogramming:headers_for_export",
],
visibility = ["//visibility:private"],
)
filegroup(
name = "jni_bind_decorative_text",
srcs = [
"jni_bind_release_leader.inc",
"jni_bind_release_trailer.inc",
],
data = [
"jni_bind_release_leader.inc",
"jni_bind_release_trailer.inc",
],
)
genquery(
name = "jni_bind_release_input",
expression = "deps(//:jni_bind) except //:jni_dep except //:jni_bind.h",
opts = ["--output=maxrank"],
scope = [
"//:jni_bind",
"//:jni_dep",
],
)