Move to github actions

This commit is contained in:
Andrea Cavalli 2020-12-29 23:38:50 +01:00
parent b03a632532
commit fe36e6912c
20 changed files with 208 additions and 377 deletions

49
.github/workflows/maven-publish.yml vendored Normal file
View File

@ -0,0 +1,49 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
name: Maven Package
on:
release:
types: [created]
jobs:
build:
strategy:
matrix:
include:
- { os: ubuntu-20.04, arch: "linux/amd64", implementation: "tdlight" }
- { os: ubuntu-20.04, arch: "linux/amd64", implementation: "tdlib" }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- name: Setup variables
shell: bash
run: |
# ====== Variables
export REVISION=${{ github.run_number }}
export IMPLEMENTATION_NAME=${{ matrix.implementation }}
echo "REVISION=$REVISION" >> $GITHUB_ENV
echo "IMPLEMENTATION_NAME=$IMPLEMENTATION_NAME" >> $GITHUB_ENV
- name: Set up JDK 15
if: github.ref == 'refs/heads/master'
uses: actions/setup-java@v1
with:
java-version: 15
server-id: mchv-release-distribution
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Deploy to Maven (Release)
if: github.ref == 'refs/heads/master'
shell: bash
run: |
echo "REVISION: $REVISION"
echo "IMPLEMENTATION_NAME: $IMPLEMENTATION_NAME"
source ./scripts/continuous-integration/github-workflows/deploy-release.sh
env:
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}

4
.gitignore vendored
View File

@ -55,13 +55,15 @@ gradle-app.setting
docs/ docs/
tdlib.iml tdlib.iml
tdlight.iml
tdlight-java.iml
example/example-java.iml
src/main/jni/jnibuild/ src/main/jni/jnibuild/
src/main/jni/jtdlib/jnibuild/ src/main/jni/jtdlib/jnibuild/
src/main/jni/jtdlib/build/ src/main/jni/jtdlib/build/
src/main/jni/bin/ src/main/jni/bin/
tdlight-java.iml
/tdapi-build /tdapi-build
/bin-td /bin-td

6
.gitmodules vendored
View File

@ -1,6 +0,0 @@
[submodule "dependencies/tdlight"]
path = dependencies/tdlight
url = https://git.ignuranza.net/tdlight-team/tdlight.git
[submodule "dependencies/tdlib-serializer"]
path = dependencies/tdlib-serializer
url = https://git.ignuranza.net/windoz/tdlib-serializer.git

130
Jenkinsfile vendored
View File

@ -1,130 +0,0 @@
#!/usr/bin/env groovy
// see https://jenkins.io/doc/book/pipeline/syntax/
pipeline {
environment {
MVN_SET = credentials('maven_settings')
JAVA_TOOL_OPTIONS = '-Duser.home=/var/maven'
}
agent any
options {
timestamps()
ansiColor("xterm")
}
parameters {
booleanParam(name: "RELEASE",
description: "Build a release from current commit.",
defaultValue: false)
}
stages {
stage("Setup workspace") {
agent none
steps {
sh "mkdir -p \"/var/jenkins_cache/.m2\""
sh "chown 1000:1000 -R \"/var/jenkins_cache/.m2\""
sh "mkdir -p \"/var/jenkins_cache/.ccache\""
sh "chown 1000:1000 -R \"/var/jenkins_cache/.ccache\""
//sh "mkdir -p \"${workspace}/tdlight-java/src/main\""
//sh "chown 1000:1000 -R \"${workspace}\""
//sh "chmod 771 -R \"${workspace}\""
}
}
stage("Generate TdApi.java") {
agent {
dockerfile {
dir 'jenkins/docker'
filename 'dockerfile'
additionalBuildArgs '--build-arg version=1.0.0 --build-arg UID=1000 --build-arg GID=1000 --build-arg UNAME=jenkins'
args "-v \"${workspace}/src/main:/home/jenkins/output:rw\" -v \"/var/jenkins_cache/.m2:/home/jenkins/.m2:rw\" -v \"/var/jenkins_cache/.ccache:/home/jenkins/.ccache:rw\" -v \"${workspace}:/home/jenkins/work:rw\""
reuseNode true
}
}
steps {
sh "./jenkins/scripts/generate_tdapi.sh"
}
}
stage("Build & Deploy") {
parallel {
stage("Deploy SNAPSHOT") {
agent {
docker {
image 'maven:3.6.3-openjdk-11'
args '-v $HOME:/var/maven'
reuseNode true
}
}
steps {
sh "cd tdlib; mvn -s $MVN_SET -B -PsnapshotDir deploy"
sh "cd tdlight; mvn -s $MVN_SET -B -PsnapshotDir deploy"
}
}
stage("Release") {
stages {
stage("Deploy Release") {
agent {
docker {
image 'maven:3.6.3-openjdk-11'
args '-v $HOME:/var/maven'
reuseNode true
}
}
when {
expression { params.RELEASE }
}
steps {
sh "git config user.email \"jenkins@mchv.eu\""
sh "git config user.name \"Jenkins\""
sh "cd ${workspace}"
sh "git add --all || true"
sh "git commit -m \"Add generated files\" || true"
sh "cd tdlib; mvn -B -s $MVN_SET -Drevision=${BUILD_NUMBER} -PreleaseDir clean deploy"
sh "cd tdlight; mvn -B -s $MVN_SET -Drevision=${BUILD_NUMBER} -PreleaseDir clean deploy"
}
}
stage("Publish Javadocs") {
agent {
docker {
image 'maven:3.6.3-openjdk-11'
args '-v $HOME:/var/maven'
reuseNode true
}
}
when {
expression { params.RELEASE }
}
steps {
withCredentials([usernamePassword(credentialsId: "gitignuranzapassword", usernameVariable: 'USER', passwordVariable: 'PASS')]) {
script {
env.encodedPass=URLEncoder.encode(PASS, "UTF-8")
}
sh "\
set -e; \
cd tdlight/target-release/apidocs; \
find . -name '*.html' -exec sed -i -r 's/<\\/title>/<\\/title>\\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><style>\\n\\t#memberSummary_tabpanel{overflow-x: auto;}\\n\\tli.blockList{overflow-x: auto;}\\n\\ttd.colLast div{max-width:30vw;}\\n\\t#search{width: 400px;max-width: 65vw;}\\n\\t.title,.subTitle,pre,.inheritance,h1,h2,h3,h4,h5,.memberSummary,.memberSignature,.typeSummary,.blockList,.contentContainer{white-space:normal;word-break:break-word;}\\n\\tul{padding-left:10px}\\n<\\/style>/' {} \\;; \
git init; \
git remote add origin https://${USER}:${encodedPass}@git.ignuranza.net/tdlight-team/tdlight-docs; \
git config user.email \"andrea@warp.ovh\"; \
git config user.name \"Andrea Cavalli\"; \
git add -A; \
git commit -m \"Update javadocs\"; \
git push --set-upstream origin master --force; \
"
}
}
}
}
}
}
}
}
post {
always {
/* clean up directory */
deleteDir()
}
}
}

@ -1 +0,0 @@
Subproject commit 1bbad278e84d2b54c9f78c5dc6a31ac085b1c111

@ -1 +0,0 @@
Subproject commit 5a480a10a65d9512a76402a776206202b6a8c67e

View File

@ -1,62 +0,0 @@
FROM debian:stable-slim
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get upgrade -y
RUN apt-get install wget -y
RUN wget https://cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-linux_amd64.deb -O /tmp/install.deb 2>/dev/null
RUN mkdir -p /usr/share/man/man1
RUN apt-get install /tmp/install.deb -y
RUN rm /tmp/install.deb
RUN apt-get install maven -y
RUN apt-get install gcc gperf cmake ccache -y
RUN apt-get install libssl-dev liblz4-dev libgflags-dev zlib1g-dev -y
RUN apt-get install build-essential -y
RUN apt-get install python3 -y
RUN apt-get install php-cli -y
RUN apt-get install libreadline-dev git -y
#RUN ./build.sh
#ENTRYPOINT [ "/bin/bash" ]
ARG UNAME=debian
ARG UID=1000
ARG GID=1000
RUN groupadd -g $GID -o $UNAME
RUN useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
USER $UNAME
RUN mkdir /home/$UNAME/work
RUN mkdir /home/$UNAME/output
WORKDIR /home/$UNAME/work
ENV CCACHE_DIR=/home/$UNAME/.ccache
ENV JAVA_HOME=/usr/lib/jvm/zulu-15-amd64
ENV JAVA_INCLUDE_PATH=/usr/lib/jvm/zulu-15-amd64/include
ENV TRAVIS_CPU_ARCH=amd64
ENV TRAVIS_OS_NAME=linux
ENV TRAVIS_BUILD_DIR=/home/$UNAME/work
ENV TRAVIS_OUTPUT_DIR=/home/$UNAME/output
CMD ["bash"]

View File

@ -1,30 +0,0 @@
#!/bin/bash -e
# ====== Setup workspace
source ./jenkins/scripts/setup_workspace.sh
# ====== Prepare tools
cd $TD_CROSS_BIN_DIR
nice -n 5 chrt -b 0 cmake \
-DTD_ENABLE_JNI=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX:PATH=${TD_BIN_DIR} \
-DCMAKE_INSTALL_BINDIR:PATH=${TD_BIN_DIR}/bin \
$TD_SRC_DIR
nice -n 5 chrt -b 0 cmake --build . --target prepare_cross_compiling --parallel ${TRAVIS_CPU_CORES}
nice -n 5 chrt -b 0 cmake --build . --target td_generate_java_api --parallel ${TRAVIS_CPU_CORES}
# ====== Build TdApi
cd $TDNATIVES_CPP_BUILD_DIR
nice -n 5 chrt -b 0 cmake -DCMAKE_BUILD_TYPE=Release -DTD_SRC_DIR=${TD_SRC_DIR} -DTD_GENERATED_BINARIES_DIR=${TD_BIN_DIR}/td/generate \
-DTDNATIVES_DOCS_BIN_DIR=${TDNATIVES_DOCS_BIN_DIR} -DJAVA_SRC_DIR=${JAVA_SRC_DIR} $TDNATIVES_CPP_SRC_DIR
nice -n 5 chrt -b 0 cmake --build $TDNATIVES_CPP_BUILD_DIR --target td_generate_java_api --config Release -- -j${TRAVIS_CPU_CORES}
# ====== Patch generated java code
echo "Compilation done. Patching TdApi.java"
python3 $TDLIB_SERIALIZER_DIR $JAVA_SRC_DIR/it/tdlight/jni/TdApi.java $JAVA_SRC_DIR/it/tdlight/jni/new_TdApi.java $TDLIB_SERIALIZER_DIR/headers.txt
rm $JAVA_SRC_DIR/it/tdlight/jni/TdApi.java
unexpand --tabs=2 $JAVA_SRC_DIR/it/tdlight/jni/new_TdApi.java > $JAVA_SRC_DIR/it/tdlight/jni/TdApi.java
rm $JAVA_SRC_DIR/it/tdlight/jni/new_TdApi.java
# ====== Clean unwanted directories
rm -r "${TD_BIN_DIR}"

View File

@ -1,59 +0,0 @@
#!/bin/bash -e
# ====== Variables
export TD_SRC_DIR=$TRAVIS_BUILD_DIR/dependencies/tdlight
export TD_BIN_DIR=$TRAVIS_BUILD_DIR/dependencies/tdlight/bin-td-cross
export TDNATIVES_BIN_DIR=$TRAVIS_BUILD_DIR/bin-tdlight
export TDNATIVES_CPP_SRC_DIR=$TRAVIS_BUILD_DIR/tdapi
export TDNATIVES_DOCS_BIN_DIR=$TRAVIS_BUILD_DIR/bin-docs
export TD_BUILD_DIR=$TRAVIS_BUILD_DIR/build-td
export TD_CROSS_BIN_DIR=$TD_SRC_DIR/bin-td-cross
export TDNATIVES_CPP_BUILD_DIR=$TRAVIS_BUILD_DIR/tdapi-build
export JAVA_SRC_DIR=$TRAVIS_BUILD_DIR/src/main/java
export TDLIB_SERIALIZER_DIR=$TRAVIS_BUILD_DIR/dependencies/tdlib-serializer
export MAVEN_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/javax.crypto=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED"
TRAVIS_CPU_ARCH_STANDARD="$(tr '[:upper:]' '[:lower:]'<<<"${TRAVIS_CPU_ARCH}")"
export TRAVIS_CPU_ARCH_STANDARD;
export TRAVIS_CPU_CORES="2"
TRAVIS_OS_NAME_STANDARD="$(tr '[:upper:]' '[:lower:]'<<<"${TRAVIS_OS_NAME}")"
export TRAVIS_OS_NAME_STANDARD
export TRAVIS_OS_NAME_SHORT=$TRAVIS_OS_NAME_STANDARD
export SRC_TDJNI_LIBNAME="libtdjni.so"
export DEST_TDJNI_LIBNAME="tdjni.so"
# ====== OS Variables
TRAVIS_CPU_ARCH_JAVA="$(tr '[:upper:]' '[:lower:]'<<<"${TRAVIS_CPU_ARCH}")"
export TRAVIS_CPU_ARCH_JAVA
export TDLIB_RESOURCES_OUTPUT_DIR="$TRAVIS_OUTPUT_DIR/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD"
# ====== Print variables
echo "TD_SRC_DIR=${TD_SRC_DIR}"
echo "TD_BIN_DIR=${TD_BIN_DIR}"
echo "TDNATIVES_BIN_DIR=${TDNATIVES_BIN_DIR}"
echo "TDNATIVES_CPP_SRC_DIR=${TDNATIVES_CPP_SRC_DIR}"
echo "TDNATIVES_DOCS_BIN_DIR=${TDNATIVES_DOCS_BIN_DIR}"
echo "TD_BUILD_DIR=${TD_BUILD_DIR}"
echo "TD_CROSS_BIN_DIR=${TD_CROSS_BIN_DIR}"
echo "TDNATIVES_CPP_BUILD_DIR=${TDNATIVES_CPP_BUILD_DIR}"
echo "JAVA_SRC_DIR=${JAVA_SRC_DIR}"
echo "TDLIB_SERIALIZER_DIR=${TDLIB_SERIALIZER_DIR}"
echo "PATH=${PATH}"
echo "JAVA_HOME=${JAVA_HOME}"
echo "JAVA_INCLUDE_PATH=${JAVA_INCLUDE_PATH}"
echo "JAVA_INCLUDE_PATH2=${JAVA_INCLUDE_PATH2}"
echo "JAVA_AWT_INCLUDE_PATH=${JAVA_AWT_INCLUDE_PATH}"
echo "VCPKG_DIR=${VCPKG_DIR}"
echo "MAVEN_OPTS=${MAVEN_OPTS}"
echo "TRAVIS_CPU_ARCH=${TRAVIS_CPU_ARCH}"
echo "TRAVIS_CPU_ARCH_JAVA=${TRAVIS_CPU_ARCH_JAVA}"
echo "TRAVIS_CPU_ARCH_STANDARD=${TRAVIS_CPU_ARCH_STANDARD}"
echo "TRAVIS_OS_NAME=${TRAVIS_OS_NAME}"
echo "TRAVIS_OS_NAME_STANDARD=${TRAVIS_OS_NAME_STANDARD}"
echo "TRAVIS_OS_NAME_SHORT=${TRAVIS_OS_NAME_SHORT}"
echo "SRC_TDJNI_LIBNAME=${SRC_TDJNI_LIBNAME}"
echo "DEST_TDJNI_LIBNAME=${DEST_TDJNI_LIBNAME}"
echo "TDLIB_RESOURCES_OUTPUT_DIR=${TDLIB_RESOURCES_OUTPUT_DIR}"
echo "CURRENT DIRECTORY* ($(pwd)):"
ls -alch "$(pwd)"
echo "WORK DIRECTORY CONTENT* (${TRAVIS_BUILD_DIR}):"
ls -alch "$TRAVIS_BUILD_DIR"

View File

@ -1,13 +0,0 @@
#!/bin/bash -e
# ====== Setup environment variables
source ./jenkins/scripts/setup_variables.sh
# ====== Environment setup
[ -d $TD_BUILD_DIR ] || mkdir -p $TD_BUILD_DIR
[ -d $TD_BIN_DIR ] || mkdir -p $TD_BIN_DIR
[ -d $TD_NATIVE_BIN_DIR ] || mkdir -p $TD_NATIVE_BIN_DIR
[ -d $TD_CROSS_BIN_DIR ] || mkdir -p $TD_CROSS_BIN_DIR
[ -d $TDNATIVES_CPP_BUILD_DIR ] || mkdir -p $TDNATIVES_CPP_BUILD_DIR
echo "CCACHE statistics:"
ccache -s

View File

@ -1,7 +1,4 @@
jdk: jdk:
- openjdk11 - openjdk11
before_install: before_install:
- cd common-utils - cd tdlight
- mvn clean install -DskipTests
- cd ..

View File

@ -0,0 +1,11 @@
#!/bin/bash -e
set -e
# OTHER REQUIRED ENVIRONMENT VARIABLES:
# REVISION = <revision>
# IMPLEMENTATION_NAME = <tdlib | tdlight>
cd ./scripts/core/
./deploy_release.sh
echo "Done."
exit 0

View File

@ -0,0 +1,21 @@
#!/bin/bash -e
# OTHER REQUIRED ENVIRONMENT VARIABLES:
# REVISION = <revision>
# IMPLEMENTATION_NAME = <tdlib | tdlight>
# Check variables correctness
if [ -z "${REVISION}" ]; then
echo "Missing parameter: REVISION"
exit 1
fi
if [ -z "${IMPLEMENTATION_NAME}" ]; then
echo "Missing parameter: IMPLEMENTATION_NAME"
exit 1
fi
cd ../../generated
mvn -B -Drevision=${REVISION} clean deploy --file ${IMPLEMENTATION_NAME}/pom.xml
echo "Done."
exit 0

View File

@ -2,8 +2,12 @@ package it.tdlight.common.utils;
public final class LibraryVersion { public final class LibraryVersion {
public static final String VERSION = "${project.version}"; public static final String VERSION = "${project.version}";
public static final String IMPLEMENTATION_NAME = "tdlib"; public static final String IMPLEMENTATION_NAME = "tdlib";
public static final String LINUX_X86_CLASS = "it.tdlight.jni.tdlib.linux.x86.LoadLibrary";
public static final String LINUX_AMD64_CLASS = "it.tdlight.jni.tdlib.linux.amd64.LoadLibrary"; public static final String LINUX_AMD64_CLASS = "it.tdlight.jni.tdlib.linux.amd64.LoadLibrary";
public static final String LINUX_AARCH64_CLASS = "it.tdlight.jni.tdlib.linux.aarch64.LoadLibrary"; public static final String LINUX_AARCH64_CLASS = "it.tdlight.jni.tdlib.linux.aarch64.LoadLibrary";
public static final String LINUX_ARMV6_CLASS = "it.tdlight.jni.tdlib.linux.armv6.LoadLibrary";
public static final String LINUX_ARMV7_CLASS = "it.tdlight.jni.tdlib.linux.armv7.LoadLibrary";
public static final String LINUX_PPC64LE_CLASS = "it.tdlight.jni.tdlib.linux.ppc64le.LoadLibrary";
public static final String WINDOWS_AMD64_CLASS = "it.tdlight.jni.tdlib.win.amd64.LoadLibrary"; public static final String WINDOWS_AMD64_CLASS = "it.tdlight.jni.tdlib.win.amd64.LoadLibrary";
public static final String OSX_AMD64_CLASS = "it.tdlight.jni.tdlib.osx.amd64.LoadLibrary"; public static final String OSX_AMD64_CLASS = "it.tdlight.jni.tdlib.osx.amd64.LoadLibrary";
} }

View File

@ -2,8 +2,12 @@ package it.tdlight.common.utils;
public final class LibraryVersion { public final class LibraryVersion {
public static final String VERSION = "${project.version}"; public static final String VERSION = "${project.version}";
public static final String IMPLEMENTATION_NAME = "tdlight"; public static final String IMPLEMENTATION_NAME = "tdlight";
public static final String LINUX_X86_CLASS = "it.tdlight.jni.tdlight.linux.x86.LoadLibrary";
public static final String LINUX_AMD64_CLASS = "it.tdlight.jni.tdlight.linux.amd64.LoadLibrary"; public static final String LINUX_AMD64_CLASS = "it.tdlight.jni.tdlight.linux.amd64.LoadLibrary";
public static final String LINUX_AARCH64_CLASS = "it.tdlight.jni.tdlight.linux.aarch64.LoadLibrary"; public static final String LINUX_AARCH64_CLASS = "it.tdlight.jni.tdlight.linux.aarch64.LoadLibrary";
public static final String LINUX_ARMV6_CLASS = "it.tdlight.jni.tdlight.linux.armv6.LoadLibrary";
public static final String LINUX_ARMV7_CLASS = "it.tdlight.jni.tdlight.linux.armv7.LoadLibrary";
public static final String LINUX_PPC64LE_CLASS = "it.tdlight.jni.tdlight.linux.ppc64le.LoadLibrary";
public static final String WINDOWS_AMD64_CLASS = "it.tdlight.jni.tdlight.win.amd64.LoadLibrary"; public static final String WINDOWS_AMD64_CLASS = "it.tdlight.jni.tdlight.win.amd64.LoadLibrary";
public static final String OSX_AMD64_CLASS = "it.tdlight.jni.tdlight.osx.amd64.LoadLibrary"; public static final String OSX_AMD64_CLASS = "it.tdlight.jni.tdlight.osx.amd64.LoadLibrary";
} }

View File

@ -21,10 +21,5 @@ package it.tdlight.common.utils;
* Enumeration with all architectures recognized by this library. * Enumeration with all architectures recognized by this library.
*/ */
public enum Arch { public enum Arch {
amd64, amd64, x86, armv6, armv7, aarch64, ppc64le, unknown
i386,
armhf,
aarch64,
ppc64le,
unknown
} }

View File

@ -112,6 +112,13 @@ public class LoadLibrary {
// not found // not found
} }
break; break;
case x86:
try {
classForResource = Class.forName(LibraryVersion.LINUX_X86_CLASS);
} catch (ClassNotFoundException e) {
// not found
}
break;
case aarch64: case aarch64:
try { try {
classForResource = Class.forName(LibraryVersion.LINUX_AARCH64_CLASS); classForResource = Class.forName(LibraryVersion.LINUX_AARCH64_CLASS);
@ -119,6 +126,27 @@ public class LoadLibrary {
// not found // not found
} }
break; break;
case armv7:
try {
classForResource = Class.forName(LibraryVersion.LINUX_ARMV7_CLASS);
} catch (ClassNotFoundException e) {
// not found
}
break;
case armv6:
try {
classForResource = Class.forName(LibraryVersion.LINUX_ARMV6_CLASS);
} catch (ClassNotFoundException e) {
// not found
}
break;
case ppc64le:
try {
classForResource = Class.forName(LibraryVersion.LINUX_PPC64LE_CLASS);
} catch (ClassNotFoundException e) {
// not found
}
break;
} }
break; break;
case osx: case osx:
@ -131,12 +159,16 @@ public class LoadLibrary {
} }
break; break;
case win: case win:
if (arch == Arch.amd64) { switch (arch) {
case amd64:
try { try {
classForResource = Class.forName(LibraryVersion.WINDOWS_AMD64_CLASS); classForResource = Class.forName(LibraryVersion.WINDOWS_AMD64_CLASS);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
// not found // not found
} }
break;
case x86:
break;
} }
break; break;
} }
@ -165,12 +197,18 @@ public class LoadLibrary {
return Arch.amd64; return Arch.amd64;
case "i386": case "i386":
case "x86": case "x86":
return Arch.i386; return Arch.x86;
case "armv6":
return Arch.armv6;
case "arm": case "arm":
return Arch.armhf; case "aarch32":
case "armv7":
case "armv7l":
return Arch.armv7;
case "arm64": case "arm64":
case "aarch64": case "aarch64":
return Arch.aarch64; return Arch.aarch64;
case "powerpc":
case "ppc64": case "ppc64":
if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) // Java always returns ppc64 for all 64-bit powerpc but if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) // Java always returns ppc64 for all 64-bit powerpc but
return Arch.ppc64le; // powerpc64le (our target) is very different, it uses this condition to accurately identify the architecture return Arch.ppc64le; // powerpc64le (our target) is very different, it uses this condition to accurately identify the architecture

View File

@ -1,54 +0,0 @@
cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR)
project(JTDLib VERSION 1.0 LANGUAGES CXX)
set(CMAKE_BUILD_TYPE Release)
set(TD_ENABLE_JNI ON)
if (POLICY CMP0054)
# do not expand quoted arguments
cmake_policy(SET CMP0054 NEW)
endif()
#find_package(Td REQUIRED)
if (NOT JNI_FOUND)
find_package(JNI REQUIRED)
endif()
message(STATUS "Found JNI: ${JNI_INCLUDE_DIRS} ${JNI_LIBRARIES}")
if (NOT Java_FOUND)
find_package(Java REQUIRED)
endif()
message(STATUS "Found Java: ${Java_JAVAC_EXECUTABLE} ${Java_JAVADOC_EXECUTABLE}")
message(STATUS "Java Source Directory: ${JAVA_SRC_DIR}")
# Generating TdApi.java
find_program(PHP_EXECUTABLE php)
message(STATUS "PHP Executable: ${PHP_EXECUTABLE}")
set(TD_API_JAVA_PACKAGE "it/tdlight/jni")
set(TD_API_JAVA_PATH ${JAVA_SRC_DIR})
set(TD_API_TLO_PATH ${TD_SRC_DIR}/td/generate/scheme/td_api.tlo)
set(TD_API_TL_PATH ${TD_SRC_DIR}/td/generate/scheme/td_api.tl)
set(JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH ${TD_SRC_DIR}/td/generate/JavadocTlDocumentationGenerator.php)
set(GENERATE_JAVA_API_CMD ${TD_GENERATED_BINARIES_DIR}/td_generate_java_api TdApi ${TD_API_TLO_PATH} ${TD_API_JAVA_PATH} ${TD_API_JAVA_PACKAGE})
if (PHP_EXECUTABLE)
set(GENERATE_JAVA_API_CMD ${GENERATE_JAVA_API_CMD} && ${PHP_EXECUTABLE} ${JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH} ${TD_API_TL_PATH} ${TD_API_JAVA_PATH}/${TD_API_JAVA_PACKAGE}/TdApi.java)
endif()
add_custom_target(td_generate_java_api
COMMAND ${GENERATE_JAVA_API_CMD}
COMMENT "Generating Java TDLib API source files"
DEPENDS ${TD_GENERATED_BINARIES_DIR}/td_generate_java_api ${TD_API_TLO_PATH} ${TD_API_TL_PATH} ${JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH}
)
add_custom_target(generate_javadoc
COMMAND ${Java_JAVADOC_EXECUTABLE} -d ${TDNATIVES_DOCS_BIN_DIR} it.tdlight.jni
WORKING_DIRECTORY ${TD_API_JAVA_PATH}
COMMENT "Generating Javadoc documentation"
DEPENDS td_generate_java_api
)
#add_dependencies(td_generate_java_api generate_javadoc)

View File

@ -8,7 +8,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0-SNAPSHOT</revision> <revision>0-SNAPSHOT</revision>
<natives-version>3.1.54</natives-version> <natives-version>3.2.3</natives-version>
</properties> </properties>
<repositories> <repositories>
<repository> <repository>
@ -40,25 +40,58 @@
<tag>HEAD</tag> <tag>HEAD</tag>
</scm> </scm>
<dependencies> <dependencies>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-api</artifactId>
<version>${natives-version}</version>
</dependency>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlib-natives-linux-x86</artifactId>
<version>${natives-version}</version>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>it.tdlight</groupId> <groupId>it.tdlight</groupId>
<artifactId>tdlib-natives-linux-amd64</artifactId> <artifactId>tdlib-natives-linux-amd64</artifactId>
<version>${natives-version}</version> <version>${natives-version}</version>
<optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.tdlight</groupId> <groupId>it.tdlight</groupId>
<artifactId>tdlib-natives-linux-aarch64</artifactId> <artifactId>tdlib-natives-linux-aarch64</artifactId>
<version>${natives-version}</version> <version>${natives-version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlib-natives-linux-ppc64le</artifactId>
<version>${natives-version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlib-natives-linux-armv6</artifactId>
<version>${natives-version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlib-natives-linux-armv7</artifactId>
<version>${natives-version}</version>
<optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.tdlight</groupId> <groupId>it.tdlight</groupId>
<artifactId>tdlib-natives-windows-amd64</artifactId> <artifactId>tdlib-natives-windows-amd64</artifactId>
<version>${natives-version}</version> <version>${natives-version}</version>
<optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.tdlight</groupId> <groupId>it.tdlight</groupId>
<artifactId>tdlib-natives-osx-amd64</artifactId> <artifactId>tdlib-natives-osx-amd64</artifactId>
<version>${natives-version}</version> <version>${natives-version}</version>
<optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.cavallium</groupId> <groupId>it.cavallium</groupId>

View File

@ -8,7 +8,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0-SNAPSHOT</revision> <revision>0-SNAPSHOT</revision>
<natives-version>3.1.54</natives-version> <natives-version>3.2.3</natives-version>
</properties> </properties>
<repositories> <repositories>
<repository> <repository>
@ -40,25 +40,58 @@
<tag>HEAD</tag> <tag>HEAD</tag>
</scm> </scm>
<dependencies> <dependencies>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-api</artifactId>
<version>${natives-version}</version>
</dependency>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-natives-linux-x86</artifactId>
<version>${natives-version}</version>
<optional>true</optional>
</dependency>
<dependency> <dependency>
<groupId>it.tdlight</groupId> <groupId>it.tdlight</groupId>
<artifactId>tdlight-natives-linux-amd64</artifactId> <artifactId>tdlight-natives-linux-amd64</artifactId>
<version>${natives-version}</version> <version>${natives-version}</version>
<optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.tdlight</groupId> <groupId>it.tdlight</groupId>
<artifactId>tdlight-natives-linux-aarch64</artifactId> <artifactId>tdlight-natives-linux-aarch64</artifactId>
<version>${natives-version}</version> <version>${natives-version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-natives-linux-ppc64le</artifactId>
<version>${natives-version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-natives-linux-armv6</artifactId>
<version>${natives-version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>it.tdlight</groupId>
<artifactId>tdlight-natives-linux-armv7</artifactId>
<version>${natives-version}</version>
<optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.tdlight</groupId> <groupId>it.tdlight</groupId>
<artifactId>tdlight-natives-windows-amd64</artifactId> <artifactId>tdlight-natives-windows-amd64</artifactId>
<version>${natives-version}</version> <version>${natives-version}</version>
<optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.tdlight</groupId> <groupId>it.tdlight</groupId>
<artifactId>tdlight-natives-osx-amd64</artifactId> <artifactId>tdlight-natives-osx-amd64</artifactId>
<version>${natives-version}</version> <version>${natives-version}</version>
<optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.cavallium</groupId> <groupId>it.cavallium</groupId>