-
Notifications
You must be signed in to change notification settings - Fork 13
/
BUILD
81 lines (75 loc) · 2.39 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
java_library(
name = "ffi",
srcs = glob(["ffi/src/main/java/**/*.java"]),
resources = glob(["ffi/src/main/resources/**"]),
visibility = ["//visibility:public"],
)
java_library(
name = "annotation-processor",
srcs = glob(["annotation-processor/src/main/java/**/*.java"]),
resources = glob(["annotation-processor/src/main/resources/**"]),
deps = [":ffi", "@maven//:com_squareup_javapoet"],
visibility = ["//visibility:public"],
)
java_plugin(
name = "plugin",
deps = [":annotation-processor"],
processor_class = "AnnotationProcessor",
generates_api = True,
visibility = ["//visibility:public"],
)
java_library(
name = "llvm",
srcs = glob(["llvm/src/main/java/**/*.java"]),
resources = glob(["llvm/src/main/resources/**"]),
plugins = [":plugin"],
deps = [":ffi"],
visibility = ["//visibility:public"],
)
java_binary(
name = "llvm4jni",
srcs = glob(["llvm/src/main/java/**/*.java",
"llvm4jni-runtime/src/main/java/**/*.java",
"llvm4jni/src/main/java/**/*.java"]),
resources = glob(["llvm/src/main/resources/**",
"llvm4jni-runtime/src/main/resources/**",
"llvm4jni/src/main/resources/**"]),
plugins = [":plugin"],
main_class = "Main",
deps = [":ffi",
"@maven//:com_github_jnr_jnr_ffi",
"@maven//:com_github_jnr_jffi",
"@maven//:org_ow2_asm_asm",
"@maven//:org_ow2_asm_asm_util",
"@maven//:org_ow2_asm_asm_tree",
],
visibility = ["//visibility:public"],
)
genrule(
name = "llvm-jni-srcs",
srcs = [":llvm"],
outs = ["llvm-jni-srcs.zip"],
cmd =
"""
mkdir -p $(@D)/llvm-jni-srcs
$(JAVABASE)/bin/jar xf $(@D)/libllvm.jar
for x in `find . -type f -name "*.cc"`; do cp $$x $(@D)/llvm-jni-srcs/; done
cd $(@D)
zip -rq llvm-jni-srcs.zip llvm-jni-srcs
""",
toolchains = [
"@bazel_tools//tools/jdk:current_java_runtime",
],
visibility = ["//visibility:public"],
)
genrule(
name = "llvm-jni-so",
srcs = [":llvm-jni-srcs"],
outs = ["libllvm4jni.so"],
cmd =
"""
unzip $(@D)/llvm-jni-srcs.zip
$$LLVM_HOME/bin/clang++ -I $$LLVM_HOME/include -I $$JAVA_HOME/include/ -I $$JAVA_HOME/include/linux/ -fPIC -shared -o $@ llvm-jni-srcs/*.cc
""",
visibility = ["//visibility:public"],
)