-
Notifications
You must be signed in to change notification settings - Fork 30
/
BUILD.bazel
119 lines (108 loc) · 3.07 KB
/
BUILD.bazel
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
load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library", "kt_jvm_test")
load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//tools/project:build_defs.bzl", "project")
project()
genrule(
name = "copy_link_jni_md_header",
srcs = select({
"@platforms//os:freebsd": ["@bazel_tools//tools/jdk:jni_md_header-freebsd"],
"@platforms//os:linux": ["@bazel_tools//tools/jdk:jni_md_header-linux"],
"@platforms//os:osx": ["@bazel_tools//tools/jdk:jni_md_header-darwin"],
"@platforms//os:windows": ["@bazel_tools//tools/jdk:jni_md_header-windows"],
}),
outs = ["lib/src/main/cpp/jni_md.h"],
cmd = "cp -f $< $@",
tags = ["java"],
)
genrule(
name = "copy_link_jni_header",
srcs = ["@bazel_tools//tools/jdk:jni_header"],
outs = ["lib/src/main/cpp/jni.h"],
cmd = "cp -f $< $@",
tags = ["java"],
)
proto_library(
name = "jni_proto",
srcs = [
"lib/src/main/proto/Av.proto",
"lib/src/main/proto/Core.proto",
],
tags = ["java"],
)
cc_proto_library(
name = "jni_cc_proto",
tags = ["java"],
deps = [":jni_proto"],
)
java_proto_library(
name = "jni_java_proto",
tags = ["java"],
deps = [":jni_proto"],
)
cc_binary(
name = "libtox4j-c.so",
srcs = glob([
"lib/src/main/cpp/**/*.cpp",
"lib/src/main/cpp/**/*.h",
]) + [
":lib/src/main/cpp/jni.h",
":lib/src/main/cpp/jni_md.h",
],
includes = [
"lib/src/main/cpp",
"lib/src/main/proto",
],
linkopts = select({
"@platforms//os:freebsd": ["-Wl,--version-script,$(location lib/src/main/cpp/libtox4j-c.ld)"],
"@platforms//os:linux": ["-Wl,--version-script,$(location lib/src/main/cpp/libtox4j-c.ld)"],
"@platforms//os:osx": [],
"@platforms//os:windows": [],
}),
linkshared = True,
tags = ["java"],
visibility = ["//visibility:public"],
deps = [
"lib/src/main/cpp/libtox4j-c.ld",
":jni_cc_proto",
"//c-toxcore",
"@libsodium",
],
)
kt_jvm_library(
name = "jvm-toxcore-c",
srcs = glob([
"lib/src/main/**/*.java",
"lib/src/main/**/*.kt",
]),
data = ["libtox4j-c.so"],
tags = ["java"],
visibility = ["//visibility:public"],
deps = [":jni_java_proto"],
)
kt_jvm_test(
name = "ToxCoreTest",
size = "small",
srcs = glob(["lib/src/test/**/*.kt"]),
jvm_flags = ["-Djava.library.path=jvm-toxcore-c"],
tags = ["java"],
test_class = "im.tox.tox4j.core.ToxCoreTest",
deps = [
":jvm-toxcore-c",
"@maven//:org_jetbrains_kotlin_kotlin_test_junit",
"@maven//:org_jetbrains_kotlinx_kotlinx_coroutines_core",
],
)
ktlint_fix(
name = "ktlint_fix",
srcs = glob(["**/*.kt"]),
)
ktlint_test(
name = "ktlint_test",
size = "small",
srcs = glob(["**/*.kt"]),
tags = ["java"],
)