Skip to content

Commit 8ac965f

Browse files
committed
chore: Add preliminary gradle build.
It can compile stuff, but requires the .so to be in library path.
1 parent fe06f91 commit 8ac965f

File tree

200 files changed

+555
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+555
-125
lines changed

.gitattributes

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
* text=auto
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: ci
3+
4+
on:
5+
pull_request:
6+
branches: [master]
7+
8+
# Cancel old PR builds when pushing new commits.
9+
concurrency:
10+
group: build-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
common:
15+
uses: TokTok/ci-tools/.github/workflows/common-ci.yml@master
16+
17+
docker-jvm:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
- name: Build toxchat/jvm-toxcore-c:jvm
23+
uses: docker/build-push-action@v5
24+
with:
25+
file: docker/jvm.Dockerfile
26+
tags: toxchat/jvm-toxcore-c:jvm

.gitignore

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
# GitHub pages.
2-
/.web
3-
4-
# SBT compiled build system.
5-
/project/project
6-
/project/target
7-
8-
# SBT output directory.
9-
/target
10-
11-
# Generated startup scripts for main classes.
12-
/bin
13-
14-
# Local user settings for SBT and Java.
15-
/local.sbt
16-
/local.properties
17-
181
# CMake build directory.
192
/android-ndk-*.zip
203
_git
@@ -34,14 +17,11 @@ _install
3417
# Virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
3518
hs_err_pid*
3619

37-
# Debug log from toxcore.
38-
libtoxcore.log
39-
4020
# Gradle temporary directory.
4121
.gradle
4222

4323
# Java runtime support for disassembly.
4424
hsdis-*.*
4525

46-
# Generated proguard configuration.
47-
/proguard-sbt.txt
26+
# Ignore Gradle build output directory
27+
build

.restyled.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
exclude:
3+
- "gradlew"

BUILD.bazel

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ genrule(
1414
"//tools/config:osx": ["@bazel_tools//tools/jdk:jni_md_header-darwin"],
1515
"//tools/config:windows": ["@bazel_tools//tools/jdk:jni_md_header-windows"],
1616
}),
17-
outs = ["cpp/src/jni_md.h"],
17+
outs = ["lib/src/main/cpp/jni_md.h"],
1818
cmd = "cp -f $< $@",
1919
)
2020

2121
genrule(
2222
name = "copy_link_jni_header",
2323
srcs = ["@bazel_tools//tools/jdk:jni_header"],
24-
outs = ["cpp/src/jni.h"],
24+
outs = ["lib/src/main/cpp/jni.h"],
2525
cmd = "cp -f $< $@",
2626
)
2727

2828
proto_library(
2929
name = "jni_proto",
3030
srcs = [
31-
"src/main/protobuf/Av.proto",
32-
"src/main/protobuf/Core.proto",
33-
"src/main/protobuf/ProtoLog.proto",
31+
"lib/src/main/proto/Av.proto",
32+
"lib/src/main/proto/Core.proto",
33+
"lib/src/main/proto/ProtoLog.proto",
3434
],
3535
)
3636

@@ -47,28 +47,28 @@ java_proto_library(
4747
cc_binary(
4848
name = "libtox4j-c.so",
4949
srcs = glob([
50-
"cpp/src/**/*.cpp",
51-
"cpp/src/**/*.h",
50+
"lib/src/main/cpp/**/*.cpp",
51+
"lib/src/main/cpp/**/*.h",
5252
]) + [
53-
":cpp/src/jni.h",
54-
":cpp/src/jni_md.h",
53+
":lib/src/main/cpp/jni.h",
54+
":lib/src/main/cpp/jni_md.h",
5555
],
5656
copts = [
5757
"-DHAVE_TO_STRING",
5858
],
5959
includes = [
60-
"cpp/src",
61-
"src/main/protobuf",
60+
"lib/src/main/cpp",
61+
"lib/src/main/proto",
6262
],
6363
linkopts = select({
64-
"//tools/config:freebsd": ["-Wl,--version-script,$(location cpp/src/libtox4j-c.ld)"],
65-
"//tools/config:linux": ["-Wl,--version-script,$(location cpp/src/libtox4j-c.ld)"],
64+
"//tools/config:freebsd": ["-Wl,--version-script,$(location lib/src/main/cpp/libtox4j-c.ld)"],
65+
"//tools/config:linux": ["-Wl,--version-script,$(location lib/src/main/cpp/libtox4j-c.ld)"],
6666
"//tools/config:osx": [],
6767
"//tools/config:windows": [],
6868
}),
6969
linkshared = True,
7070
deps = [
71-
"cpp/src/libtox4j-c.ld",
71+
"lib/src/main/cpp/libtox4j-c.ld",
7272
":jni_cc_proto",
7373
"//c-toxcore",
7474
],
@@ -77,8 +77,8 @@ cc_binary(
7777
kt_jvm_library(
7878
name = "jvm-toxcore-c",
7979
srcs = glob([
80-
"src/main/java/**/*.java",
81-
"src/main/java/**/*.kt",
80+
"lib/src/main/java/**/*.java",
81+
"lib/src/main/java/**/*.kt",
8282
]),
8383
data = ["libtox4j-c.so"],
8484
deps = [":jni_java_proto"],
@@ -87,7 +87,7 @@ kt_jvm_library(
8787
kt_jvm_test(
8888
name = "ToxCoreTest",
8989
size = "small",
90-
srcs = ["src/test/java/im/tox/tox4j/core/ToxCoreTest.kt"],
90+
srcs = ["lib/src/test/java/im/tox/tox4j/core/ToxCoreTest.kt"],
9191
jvm_flags = ["-Djava.library.path=jvm-toxcore-c"],
9292
test_class = "im.tox.tox4j.core.ToxCoreTest",
9393
deps = [

cpp/src/ToxAv/Av.proto

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp/src/ToxCore/Core.proto

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp/src/main/resources/im/tox/tox4j/impl/jni/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

cpp/src/util/ProtoLog.proto

Lines changed: 0 additions & 1 deletion
This file was deleted.

docker/jvm.Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM ubuntu:22.04
2+
3+
RUN apt-get update \
4+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
5+
autoconf \
6+
automake \
7+
build-essential \
8+
ca-certificates \
9+
cmake \
10+
default-jdk \
11+
git \
12+
libtool \
13+
make \
14+
pkg-config \
15+
yasm \
16+
&& apt-get clean \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
WORKDIR /work/jvm-toxcore-c
20+
COPY scripts/ /work/jvm-toxcore-c/scripts/
21+
RUN scripts/build-host "$PWD/_install/host/protobuf.stamp" "-j$(nproc)"
22+
RUN scripts/build-host "$PWD/_install/host/toxcore.stamp" "-j$(nproc)"
23+
COPY lib/src/main/cpp/ /work/jvm-toxcore-c/lib/src/main/cpp/
24+
COPY lib/src/main/proto/ /work/jvm-toxcore-c/lib/src/main/proto/
25+
RUN scripts/build-host #"-j$(nproc)"

0 commit comments

Comments
 (0)