Removed resources

This commit is contained in:
Andrea Cavalli 2020-08-19 01:01:36 +02:00
parent 034aaa46d9
commit 4e24c7d159
6 changed files with 0 additions and 343 deletions

View File

@ -1,62 +0,0 @@
#!/bin/bash -e
#rm -r jtdlib/jnibuild
#rm -r jtdlib/build
rm ../java/it/tdlight/tdlight/natives/TdApi.java || true
rm ../java/it/tdlight/tdlight/natives/new_TdApi.java || true
export TD_SRC_DIR=${PWD}/td
export TD_BIN_DIR=${PWD}/jtdlib/td
export JAVA_SRC_DIR=$(dirname `pwd`)/java
cd jtdlib
mkdir jnibuild || true
mkdir build || true
echo "TD_SRC_DIR=${TD_SRC_DIR}"
echo "TD_BIN_DIR=${TD_BIN_DIR}"
echo "JAVA_SRC_DIR=${JAVA_SRC_DIR}"
cd jnibuild
#export OPENSSL_ROOT_DIR=/snap/gitkraken/143/lib/x86_64-linux-gnu
#export JAVA_HOME=/usr/lib/jvm/java-1.13.0-openjdk-amd64
#export JAVA_INCLUDE_PATH=/usr/lib/jvm/java-1.13.0-openjdk-amd64/include/
cmake -DCMAKE_BUILD_TYPE=Release -DTD_ENABLE_JNI=ON -DCMAKE_INSTALL_PREFIX:PATH=${TD_BIN_DIR} ${TD_SRC_DIR}
cmake --build . --target install -- -j1
cd ../../../../../
#mvn install -X
cd src/main/jni/jtdlib/build
cmake -DCMAKE_BUILD_TYPE=Release -DTd_DIR=${TD_BIN_DIR}/lib/cmake/Td -DJAVA_SRC_DIR=${JAVA_SRC_DIR} -DCMAKE_INSTALL_PREFIX:PATH=.. ..
cmake --build . --target install -- -j1
cd ..
#rm -r jnibuild
#rm -r build
rm -r td
[ -e ../bin ] && rm -r ../bin
mkdir ../bin
mv docs ../bin
mv bin/libtdjni.so ../bin/tdjni.so
[ -e bin ] && rm -r bin
cd ../
cp bin/tdjni.so ../resources/libs/linux/amd64/tdjni.so
echo "Compilation done. Patching TdApi.java"
python3 tdlib-serializer ../java/it/ernytech/tdlib/TdApi.java ../java/it/ernytech/tdlib/new_TdApi.java tdlib-serializer/headers.txt
rm ../java/it/ernytech/tdlib/TdApi.java
unexpand --tabs=2 ../java/it/ernytech/tdlib/new_TdApi.java > ../java/it/ernytech/tdlib/TdApi.java
rm ../java/it/ernytech/tdlib/new_TdApi.java
cd ../../../
echo "Installing jar utils"
cd common-utils/
mvn clean install -X
cd ../
echo "Installing jar"
mvn clean install -X

View File

@ -1,110 +0,0 @@
cmake_minimum_required(VERSION 3.0.2 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)
set(JAVA_AWT_LIBRARY NotNeeded)
set(JAVA_AWT_INCLUDE_PATH NotNeeded)
find_package(JNI REQUIRED)
endif()
message(STATUS "Found JNI: ${JNI_INCLUDE_DIRS} ${JNI_LIBRARIES}")
if (NOT Java_FOUND)
find_package(Java 1.6 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)
set(TD_API_JAVA_PACKAGE "it/tdlight/tdnatives")
set(TD_API_JAVA_PATH ${JAVA_SRC_DIR})
set(TD_API_TLO_PATH ${CMAKE_CURRENT_SOURCE_DIR}/td/bin/td/generate/scheme/td_api.tlo)
set(TD_API_TL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/td/bin/td/generate/scheme/td_api.tl)
set(JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/td/bin/td/generate/JavadocTlDocumentationGenerator.php)
set(GENERATE_JAVA_API_CMD ${CMAKE_CURRENT_SOURCE_DIR}/td/bin/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 ${CMAKE_CURRENT_SOURCE_DIR}/td/bin/td_generate_java_api ${TD_API_TLO_PATH} ${TD_API_TL_PATH} ${JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH}
)
get_filename_component(JAVA_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin REALPATH BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
file(MAKE_DIRECTORY ${JAVA_OUTPUT_DIRECTORY})
add_custom_target(build_java
COMMAND ${Java_JAVAC_EXECUTABLE} -d ${JAVA_OUTPUT_DIRECTORY} @../sources.txt
COMMENT "Building Java code"
DEPENDS td_generate_java_api
)
add_custom_target(generate_javadoc
COMMAND ${Java_JAVADOC_EXECUTABLE} -d ${JAVA_OUTPUT_DIRECTORY}/../docs it.tdlight.tdnatives
WORKING_DIRECTORY ${TD_API_JAVA_PATH}
COMMENT "Generating Javadoc documentation"
DEPENDS td_generate_java_api
)
# Building shared library
add_library(tdjni SHARED
td_jni.cpp
)
target_include_directories(tdjni PRIVATE ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
target_link_libraries(tdjni PRIVATE Td::TdStatic ${JAVA_JVM_LIBRARY})
target_compile_definitions(tdjni PRIVATE PACKAGE_NAME="${TD_API_JAVA_PACKAGE}")
set_property(TARGET tdjni PROPERTY CXX_STANDARD 14)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(GCC 1)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CLANG 1)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(INTEL 1)
elseif (NOT MSVC)
message(FATAL_ERROR "Compiler isn't supported")
endif()
include(CheckCXXCompilerFlag)
if (GCC OR CLANG OR INTEL)
if (WIN32 AND INTEL)
set(STD14_FLAG /Qstd=c++14)
else()
set(STD14_FLAG -std=c++14)
endif()
check_cxx_compiler_flag(${STD14_FLAG} HAVE_STD14)
if (NOT HAVE_STD14)
string(REPLACE "c++14" "c++1y" STD14_FLAG "${STD14_FLAG}")
check_cxx_compiler_flag(${STD14_FLAG} HAVE_STD1Y)
set(HAVE_STD14 ${HAVE_STD1Y})
endif()
target_compile_options(tdjni PRIVATE "${STD14_FLAG}")
elseif (MSVC)
set(HAVE_STD14 MSVC_VERSION>=1900)
endif()
if (NOT HAVE_STD14)
message(FATAL_ERROR "No C++14 support in the compiler. Please upgrade the compiler.")
endif()
add_dependencies(tdjni td_generate_java_api build_java generate_javadoc)
install(TARGETS tdjni
LIBRARY DESTINATION bin
RUNTIME DESTINATION bin
)

View File

@ -1,3 +0,0 @@
../../../java/it/tdlight/tdnatives/NativeClient.java
../../../java/it/tdlight/tdnatives/NativeLog.java
../../../java/it/tdlight/tdnatives/TdApi.java

View File

@ -1,166 +0,0 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <td/telegram/Client.h>
#include <td/telegram/Log.h>
#include <td/telegram/td_api.h>
#include <td/tl/tl_jni_object.h>
#include <cstdint>
#include <cstdlib>
#include <string>
#include <utility>
namespace td_jni {
static td::td_api::object_ptr<td::td_api::Function> fetch_function(JNIEnv *env, jobject function) {
td::jni::reset_parse_error();
auto result = td::td_api::Function::fetch(env, function);
if (td::jni::have_parse_error()) {
std::abort();
}
return result;
}
static td::Client *get_client(jlong client_id) {
return reinterpret_cast<td::Client *>(static_cast<std::uintptr_t>(client_id));
}
static jlong Client_createNativeClient(JNIEnv *env, jclass clazz) {
return static_cast<jlong>(reinterpret_cast<std::uintptr_t>(new td::Client()));
}
static void Client_nativeClientSend(JNIEnv *env, jclass clazz, jlong client_id, jlong id, jobject function) {
get_client(client_id)->send({static_cast<std::uint64_t>(id), fetch_function(env, function)});
}
static jint Client_nativeClientReceive(JNIEnv *env, jclass clazz, jlong client_id, jlongArray ids, jobjectArray events,
jdouble timeout) {
auto client = get_client(client_id);
jsize events_size = env->GetArrayLength(ids); // ids and events size must be of equal size
if (events_size == 0) {
return 0;
}
jsize result_size = 0;
auto response = client->receive(timeout);
while (response.object) {
jlong result_id = static_cast<jlong>(response.id);
env->SetLongArrayRegion(ids, result_size, 1, &result_id);
jobject object;
response.object->store(env, object);
env->SetObjectArrayElement(events, result_size, object);
env->DeleteLocalRef(object);
result_size++;
if (result_size == events_size) {
break;
}
response = client->receive(0);
}
return result_size;
}
static jobject Client_nativeClientExecute(JNIEnv *env, jclass clazz, jobject function) {
jobject result;
td::Client::execute({0, fetch_function(env, function)}).object->store(env, result);
return result;
}
static void Client_destroyNativeClient(JNIEnv *env, jclass clazz, jlong client_id) {
delete get_client(client_id);
}
static void Log_setVerbosityLevel(JNIEnv *env, jclass clazz, jint new_log_verbosity_level) {
td::Log::set_verbosity_level(static_cast<int>(new_log_verbosity_level));
}
static jboolean Log_setFilePath(JNIEnv *env, jclass clazz, jstring file_path) {
return td::Log::set_file_path(td::jni::from_jstring(env, file_path)) ? JNI_TRUE : JNI_FALSE;
}
static void Log_setMaxFileSize(JNIEnv *env, jclass clazz, jlong max_file_size) {
td::Log::set_max_file_size(max_file_size);
}
static jstring Object_toString(JNIEnv *env, jobject object) {
return td::jni::to_jstring(env, to_string(td::td_api::Object::fetch(env, object)));
}
static jstring Function_toString(JNIEnv *env, jobject object) {
return td::jni::to_jstring(env, to_string(td::td_api::Function::fetch(env, object)));
}
static constexpr jint JAVA_VERSION = JNI_VERSION_1_6;
static JavaVM *java_vm;
static jclass log_class;
static void on_fatal_error(const char *error_message) {
auto env = td::jni::get_jni_env(java_vm, JAVA_VERSION);
jmethodID on_fatal_error_method = env->GetStaticMethodID(log_class, "onFatalError", "(Ljava/lang/String;)V");
if (env && on_fatal_error_method) {
jstring error_str = td::jni::to_jstring(env.get(), error_message);
env->CallStaticVoidMethod(log_class, on_fatal_error_method, error_str);
if (error_str) {
env->DeleteLocalRef(error_str);
}
}
}
static jint register_native(JavaVM *vm) {
JNIEnv *env;
if (vm->GetEnv(reinterpret_cast<void **>(&env), JAVA_VERSION) != JNI_OK) {
return -1;
}
java_vm = vm;
auto register_method = [env](jclass clazz, std::string name, std::string signature, auto function_ptr) {
td::jni::register_native_method(env, clazz, std::move(name), std::move(signature),
reinterpret_cast<void *>(function_ptr));
};
auto client_class = td::jni::get_jclass(env, PACKAGE_NAME "/Client");
log_class = td::jni::get_jclass(env, PACKAGE_NAME "/Log");
auto object_class = td::jni::get_jclass(env, PACKAGE_NAME "/TdApi$Object");
auto function_class = td::jni::get_jclass(env, PACKAGE_NAME "/TdApi$Function");
#define TD_OBJECT "L" PACKAGE_NAME "/TdApi$Object;"
#define TD_FUNCTION "L" PACKAGE_NAME "/TdApi$Function;"
register_method(client_class, "createNativeClient", "()J", Client_createNativeClient);
register_method(client_class, "nativeClientSend", "(JJ" TD_FUNCTION ")V", Client_nativeClientSend);
register_method(client_class, "nativeClientReceive", "(J[J[" TD_OBJECT "D)I", Client_nativeClientReceive);
register_method(client_class, "nativeClientExecute", "(" TD_FUNCTION ")" TD_OBJECT, Client_nativeClientExecute);
register_method(client_class, "destroyNativeClient", "(J)V", Client_destroyNativeClient);
register_method(log_class, "setVerbosityLevel", "(I)V", Log_setVerbosityLevel);
register_method(log_class, "setFilePath", "(Ljava/lang/String;)Z", Log_setFilePath);
register_method(log_class, "setMaxFileSize", "(J)V", Log_setMaxFileSize);
register_method(object_class, "toString", "()Ljava/lang/String;", Object_toString);
register_method(function_class, "toString", "()Ljava/lang/String;", Function_toString);
#undef TD_FUNCTION
#undef TD_OBJECT
td::jni::init_vars(env, PACKAGE_NAME);
td::td_api::Object::init_jni_vars(env, PACKAGE_NAME);
td::td_api::Function::init_jni_vars(env, PACKAGE_NAME);
td::Log::set_fatal_error_callback(on_fatal_error);
return JAVA_VERSION;
}
} // namespace td_jni
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
static jint jni_version = td_jni::register_native(vm); // call_once
return jni_version;
}

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

@ -1 +0,0 @@
Subproject commit 57bf30757952daafcd28352e38fda21e260ce664