Add support for java 8, 9. Add support for ppc64, s390x, armhf
This commit is contained in:
parent
229694ec51
commit
fb7042d44f
4
.github/workflows/maven-publish.yml
vendored
4
.github/workflows/maven-publish.yml
vendored
@ -34,11 +34,11 @@ jobs:
|
||||
|
||||
echo "REVISION=$REVISION" >> $GITHUB_ENV
|
||||
echo "IMPLEMENTATION_NAME=$IMPLEMENTATION_NAME" >> $GITHUB_ENV
|
||||
- name: Set up JDK 15
|
||||
- name: Set up JDK 11
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 15
|
||||
java-version: 11
|
||||
server-id: mchv-release-distribution
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_PASSWORD
|
||||
|
@ -1,14 +1,14 @@
|
||||
package it.tdlight.common.utils;
|
||||
public final class LibraryVersion {
|
||||
public static final String VERSION = "${project.version}";
|
||||
public static final String NATIVES_VERSION = "${natives-version}";
|
||||
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_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 OSX_AMD64_CLASS = "it.tdlight.jni.tdlib.osx.amd64.LoadLibrary";
|
||||
public static final String VERSION = "${project.version}";
|
||||
public static final String NATIVES_VERSION = "${natives-version}";
|
||||
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_AARCH64_CLASS = "it.tdlight.jni.tdlib.linux.aarch64.LoadLibrary";
|
||||
public static final String LINUX_ARMHF_CLASS = "it.tdlight.jni.tdlib.linux.armhf.LoadLibrary";
|
||||
public static final String LINUX_S390X_CLASS = "it.tdlight.jni.tdlib.linux.s390x.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 OSX_AMD64_CLASS = "it.tdlight.jni.tdlib.osx.amd64.LoadLibrary";
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
package it.tdlight.common.utils;
|
||||
public final class LibraryVersion {
|
||||
public static final String VERSION = "${project.version}";
|
||||
public static final String NATIVES_VERSION = "${natives-version}";
|
||||
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_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 OSX_AMD64_CLASS = "it.tdlight.jni.tdlight.osx.amd64.LoadLibrary";
|
||||
public static final String VERSION = "${project.version}";
|
||||
public static final String NATIVES_VERSION = "${natives-version}";
|
||||
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_AARCH64_CLASS = "it.tdlight.jni.tdlight.linux.aarch64.LoadLibrary";
|
||||
public static final String LINUX_ARMHF_CLASS = "it.tdlight.jni.tdlight.linux.armhf.LoadLibrary";
|
||||
public static final String LINUX_S390X_CLASS = "it.tdlight.jni.tdlight.linux.s390x.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 OSX_AMD64_CLASS = "it.tdlight.jni.tdlight.osx.amd64.LoadLibrary";
|
||||
}
|
@ -37,7 +37,7 @@ public class Init {
|
||||
if (!started) {
|
||||
Os os = LoadLibrary.getOs();
|
||||
|
||||
if (os == Os.win) {
|
||||
if (os == Os.WINDOWS) {
|
||||
// Since 3.0.0, libraries for windows are statically compiled into tdjni.dll
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,11 @@ package it.tdlight.common.utils;
|
||||
* Enumeration with all architectures recognized by this library.
|
||||
*/
|
||||
public enum Arch {
|
||||
amd64, x86, armv6, armv7, aarch64, ppc64le, unknown
|
||||
UNKNOWN,
|
||||
AMD64,
|
||||
I386,
|
||||
ARMHF,
|
||||
AARCH64,
|
||||
PPC64LE,
|
||||
S390X
|
||||
}
|
||||
|
@ -71,11 +71,11 @@ public class LoadLibrary {
|
||||
Arch arch = getCpuArch();
|
||||
Os os = getOs();
|
||||
|
||||
if (arch == Arch.unknown) {
|
||||
if (arch == Arch.UNKNOWN) {
|
||||
throw (CantLoadLibrary) new CantLoadLibrary().initCause(new IllegalStateException("Arch: \"" + System.getProperty("os.arch") + "\" is unknown"));
|
||||
}
|
||||
|
||||
if (os == Os.unknown) {
|
||||
if (os == Os.UNKNOWN) {
|
||||
throw (CantLoadLibrary) new CantLoadLibrary().initCause(new IllegalStateException("Os: \"" + System.getProperty("os.name") + "\" is unknown"));
|
||||
}
|
||||
|
||||
@ -104,44 +104,44 @@ public class LoadLibrary {
|
||||
Path tempFile = Paths.get(tempPath.toString(), libname + getExt(os));
|
||||
Class<?> classForResource = null;
|
||||
switch (os) {
|
||||
case linux:
|
||||
case LINUX:
|
||||
switch (arch) {
|
||||
case amd64:
|
||||
case AMD64:
|
||||
try {
|
||||
classForResource = Class.forName(LibraryVersion.LINUX_AMD64_CLASS);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// not found
|
||||
}
|
||||
break;
|
||||
case x86:
|
||||
case I386:
|
||||
try {
|
||||
classForResource = Class.forName(LibraryVersion.LINUX_X86_CLASS);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// not found
|
||||
}
|
||||
break;
|
||||
case aarch64:
|
||||
case AARCH64:
|
||||
try {
|
||||
classForResource = Class.forName(LibraryVersion.LINUX_AARCH64_CLASS);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// not found
|
||||
}
|
||||
break;
|
||||
case armv7:
|
||||
case ARMHF:
|
||||
try {
|
||||
classForResource = Class.forName(LibraryVersion.LINUX_ARMV7_CLASS);
|
||||
classForResource = Class.forName(LibraryVersion.LINUX_ARMHF_CLASS);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// not found
|
||||
}
|
||||
break;
|
||||
case armv6:
|
||||
case S390X:
|
||||
try {
|
||||
classForResource = Class.forName(LibraryVersion.LINUX_ARMV6_CLASS);
|
||||
classForResource = Class.forName(LibraryVersion.LINUX_S390X_CLASS);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// not found
|
||||
}
|
||||
break;
|
||||
case ppc64le:
|
||||
case PPC64LE:
|
||||
try {
|
||||
classForResource = Class.forName(LibraryVersion.LINUX_PPC64LE_CLASS);
|
||||
} catch (ClassNotFoundException e) {
|
||||
@ -150,8 +150,8 @@ public class LoadLibrary {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case osx:
|
||||
if (arch == Arch.amd64) {
|
||||
case OSX:
|
||||
if (arch == Arch.AMD64) {
|
||||
try {
|
||||
classForResource = Class.forName(LibraryVersion.OSX_AMD64_CLASS);
|
||||
} catch (ClassNotFoundException e) {
|
||||
@ -159,16 +159,16 @@ public class LoadLibrary {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case win:
|
||||
case WINDOWS:
|
||||
switch (arch) {
|
||||
case amd64:
|
||||
case AMD64:
|
||||
try {
|
||||
classForResource = Class.forName(LibraryVersion.WINDOWS_AMD64_CLASS);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// not found
|
||||
}
|
||||
break;
|
||||
case x86:
|
||||
case I386:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -195,52 +195,63 @@ public class LoadLibrary {
|
||||
switch (architecture) {
|
||||
case "amd64":
|
||||
case "x86_64":
|
||||
return Arch.amd64;
|
||||
return Arch.AMD64;
|
||||
case "i386":
|
||||
case "x86":
|
||||
return Arch.x86;
|
||||
case "386":
|
||||
case "i686":
|
||||
case "686":
|
||||
return Arch.I386;
|
||||
case "armv6":
|
||||
return Arch.armv6;
|
||||
case "arm":
|
||||
case "armhf":
|
||||
case "aarch32":
|
||||
case "armv7":
|
||||
case "armv7l":
|
||||
return Arch.armv7;
|
||||
return Arch.ARMHF;
|
||||
case "arm64":
|
||||
case "aarch64":
|
||||
return Arch.aarch64;
|
||||
case "armv8":
|
||||
case "armv8l":
|
||||
return Arch.AARCH64;
|
||||
case "powerpc":
|
||||
case "powerpc64":
|
||||
case "powerpc64le":
|
||||
case "powerpc64el":
|
||||
case "ppc":
|
||||
case "ppc64":
|
||||
case "ppc64le":
|
||||
case "ppc64el":
|
||||
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
|
||||
else
|
||||
return Arch.unknown;
|
||||
return Arch.UNKNOWN;
|
||||
default:
|
||||
return Arch.unknown;
|
||||
return Arch.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public static Os getOs() {
|
||||
String os = System.getProperty("os.name").toLowerCase().trim();
|
||||
if (os.contains("linux"))
|
||||
return Os.linux;
|
||||
return Os.LINUX;
|
||||
if (os.contains("windows"))
|
||||
return Os.win;
|
||||
return Os.WINDOWS;
|
||||
if (os.contains("mac"))
|
||||
return Os.osx;
|
||||
return Os.OSX;
|
||||
if (os.contains("darwin"))
|
||||
return Os.osx;
|
||||
return Os.unknown;
|
||||
return Os.OSX;
|
||||
return Os.UNKNOWN;
|
||||
}
|
||||
|
||||
private static String getExt(Os os) {
|
||||
switch (os) {
|
||||
case win:
|
||||
case WINDOWS:
|
||||
return ".dll";
|
||||
case osx:
|
||||
case OSX:
|
||||
return ".dylib";
|
||||
case linux:
|
||||
case unknown:
|
||||
case LINUX:
|
||||
case UNKNOWN:
|
||||
default:
|
||||
return ".so";
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ package it.tdlight.common.utils;
|
||||
/**
|
||||
* Enumeration with all operating systems recognized by this library.
|
||||
*/
|
||||
public enum Os {
|
||||
linux,
|
||||
win,
|
||||
osx,
|
||||
unknown
|
||||
public enum Os {
|
||||
LINUX,
|
||||
WINDOWS,
|
||||
OSX,
|
||||
UNKNOWN
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<revision>1.0.0-SNAPSHOT</revision>
|
||||
<api-version>3.3.72</api-version>
|
||||
<natives-version>3.3.74</natives-version>
|
||||
<api-version>3.3.125</api-version>
|
||||
<natives-version>3.3.127</natives-version>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
@ -66,15 +66,15 @@
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>it.unimi.dsi</groupId>
|
||||
<artifactId>fastutil</artifactId>
|
||||
<version>8.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>it.unimi.dsi</groupId>
|
||||
<artifactId>fastutil</artifactId>
|
||||
<version>8.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>releaseDir</id>
|
||||
@ -156,7 +156,8 @@
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<release>8</release>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<useIncrementalCompilation>false</useIncrementalCompilation>
|
||||
<excludes>
|
||||
<exclude>it/tdlight/tdlight/ClientManager.java</exclude>
|
||||
@ -190,10 +191,11 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- specify JDK 9+ release flag to ensure no classes/methods later than Java 8 are used accidentally -->
|
||||
<release>8</release>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<!-- exclude module-info.java from the compilation, as it is unsupported by Java 8 -->
|
||||
<excludes>
|
||||
<exclude>it/tdlight/tdlight/ClientManager.java</exclude>
|
||||
<exclude>it/tdlight/tdlight/ClientManager.java</exclude>
|
||||
<exclude>module-info.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<revision>1.0.0-SNAPSHOT</revision>
|
||||
<api-version>3.3.72</api-version>
|
||||
<natives-version>3.3.74</natives-version>
|
||||
<api-version>3.3.125</api-version>
|
||||
<natives-version>3.3.127</natives-version>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
@ -66,15 +66,15 @@
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>it.unimi.dsi</groupId>
|
||||
<artifactId>fastutil</artifactId>
|
||||
<version>8.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>it.unimi.dsi</groupId>
|
||||
<artifactId>fastutil</artifactId>
|
||||
<version>8.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>releaseDir</id>
|
||||
@ -156,7 +156,8 @@
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<release>8</release>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<useIncrementalCompilation>false</useIncrementalCompilation>
|
||||
<excludes>
|
||||
<exclude>it/tdlight/tdlib/ClientManager.java</exclude>
|
||||
@ -190,10 +191,11 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- specify JDK 9+ release flag to ensure no classes/methods later than Java 8 are used accidentally -->
|
||||
<release>8</release>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<!-- exclude module-info.java from the compilation, as it is unsupported by Java 8 -->
|
||||
<excludes>
|
||||
<exclude>it/tdlight/tdlib/ClientManager.java</exclude>
|
||||
<exclude>it/tdlight/tdlib/ClientManager.java</exclude>
|
||||
<exclude>module-info.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
|
Loading…
x
Reference in New Issue
Block a user