Refactor internal natives package name

This commit is contained in:
Andrea Cavalli 2021-04-07 20:41:23 +02:00
parent 6793be157b
commit 3cac607219
7 changed files with 35 additions and 26 deletions

View File

@ -26,7 +26,8 @@ if [ -z "${CPU_CORES}" ]; then
fi
cd ../../
JAVA_PACKAGE_PATH="it/tdlight/jni"
JAVA_API_PACKAGE_PATH="it/tdlight/jni"
JAVA_LIB_PACKAGE_PATH="it/tdlight/tdnative"
# Print details
echo "Generating TdApi.java..."
@ -36,7 +37,8 @@ echo "Architecture: ${CPU_ARCHITECTURE_NAME}"
echo "Td implementation: ${IMPLEMENTATION_NAME}"
echo "CPU cores count: ${CPU_CORES}"
echo "CMake extra arguments: '${CMAKE_EXTRA_ARGUMENTS}'"
echo "JAVA_PACKAGE_PATH: '${JAVA_PACKAGE_PATH}'"
echo "JAVA_API_PACKAGE_PATH: '${JAVA_API_PACKAGE_PATH}'"
echo "JAVA_LIB_PACKAGE_PATH: '${JAVA_LIB_PACKAGE_PATH}'"
# Setup constants
if [[ "$OPERATING_SYSTEM_NAME" == "windows" ]]; then
@ -50,11 +52,12 @@ echo "Deleting old data..."
[ -d ./generated/tdjni_build/ ] && rm -r ./generated/tdjni_build/
[ -d ./generated/tdjni_bin/ ] && rm -r ./generated/tdjni_bin/
[ -d ./generated/tdjni_docs/ ] && rm -r ./generated/tdjni_docs/
[ -f ./generated/src/main/java/${JAVA_PACKAGE_PATH}/TdApi.java ] && rm ./generated/src/main/java/${JAVA_PACKAGE_PATH}/TdApi.java
[ -f ./generated/src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java ] && rm ./generated/src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java
# Create missing folders
echo "Creating missing folders..."
[ -d "./generated/src/main/java/${JAVA_PACKAGE_PATH}/" ] || mkdir -p "./generated/src/main/java/${JAVA_PACKAGE_PATH}/"
[ -d "./generated/src/main/java/${JAVA_API_PACKAGE_PATH}/" ] || mkdir -p "./generated/src/main/java/${JAVA_API_PACKAGE_PATH}/"
[ -d "./generated/src/main/java/${JAVA_LIB_PACKAGE_PATH}/" ] || mkdir -p "./generated/src/main/java/${JAVA_LIB_PACKAGE_PATH}/"
[ -d ./generated/tdjni_build/ ] || mkdir ./generated/tdjni_build/
[ -d ./generated/tdjni_bin/ ] || mkdir ./generated/tdjni_bin/
[ -d ./generated/tdjni_docs/ ] || mkdir ./generated/tdjni_docs/
@ -74,20 +77,20 @@ echo "Telegram source path: '$(realpath -m ./implementation/)'"
# Run cmake to generate TdApi.java
echo "Generating TdApi.java..."
./td_tools/td/generate/td_generate_java_api TdApi "./implementation/td/generate/scheme/td_api.tlo" "./src/main/java" "$JAVA_PACKAGE_PATH"
php ./implementation/td/generate/JavadocTlDocumentationGenerator.php "./implementation/td/generate/scheme/td_api.tl" "./src/main/java/${JAVA_PACKAGE_PATH}/TdApi.java"
./td_tools/td/generate/td_generate_java_api TdApi "./implementation/td/generate/scheme/td_api.tlo" "./src/main/java" "$JAVA_API_PACKAGE_PATH"
php ./implementation/td/generate/JavadocTlDocumentationGenerator.php "./implementation/td/generate/scheme/td_api.tl" "./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java"
echo "Patching TdApi.java..."
${PYTHON_EXECUTABLE} ../scripts/core/tdlib-serializer "$(realpath -m ./src/main/java/${JAVA_PACKAGE_PATH}/TdApi.java)" "$(realpath -m ./src/main/java/${JAVA_PACKAGE_PATH}/new_TdApi.java)" "$(realpath -m ../scripts/core/tdlib-serializer/headers.txt)"
rm ./src/main/java/${JAVA_PACKAGE_PATH}/TdApi.java
${PYTHON_EXECUTABLE} ../scripts/core/tdlib-serializer "$(realpath -m ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java)" "$(realpath -m ./src/main/java/${JAVA_API_PACKAGE_PATH}/new_TdApi.java)" "$(realpath -m ../scripts/core/tdlib-serializer/headers.txt)"
rm ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java
if [[ "$OPERATING_SYSTEM_NAME" == "osx" ]]; then
unexpand --tabs=2 ./src/main/java/${JAVA_PACKAGE_PATH}/new_TdApi.java > ./src/main/java/${JAVA_PACKAGE_PATH}/TdApi.java
unexpand --tabs=2 ./src/main/java/${JAVA_API_PACKAGE_PATH}/new_TdApi.java > ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java
else
unexpand -t 2 ./src/main/java/${JAVA_PACKAGE_PATH}/new_TdApi.java > ./src/main/java/${JAVA_PACKAGE_PATH}/TdApi.java
unexpand -t 2 ./src/main/java/${JAVA_API_PACKAGE_PATH}/new_TdApi.java > ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java
fi
rm ./src/main/java/${JAVA_PACKAGE_PATH}/new_TdApi.java
rm ./src/main/java/${JAVA_API_PACKAGE_PATH}/new_TdApi.java
echo "Generated '$(realpath -m ./src/main/java/${JAVA_PACKAGE_PATH}/TdApi.java)'"
echo "Generated '$(realpath -m ./src/main/java/${JAVA_API_PACKAGE_PATH}/TdApi.java)'"
echo "Done."
exit 0

View File

@ -28,14 +28,15 @@ find_program(PHP_EXECUTABLE php)
message(STATUS "PHP Executable: ${PHP_EXECUTABLE}")
set(TD_API_JAVA_PACKAGE "it/tdlight/jni")
set(TD_API_JAVA_PACKAGE "it/tdlight/tdnative")
set(TD_API_SPEC_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})
set(GENERATE_JAVA_API_CMD ${TD_GENERATED_BINARIES_DIR}/td_generate_java_api TdApi ${TD_API_TLO_PATH} ${TD_API_JAVA_PATH} ${TD_API_SPEC_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)
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_SPEC_JAVA_PACKAGE}/TdApi.java)
endif()
add_custom_target(td_generate_java_api
@ -65,7 +66,7 @@ add_library(tdjni SHARED
)
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}")
target_compile_definitions(tdjni PRIVATE PACKAGE_NAME="${TD_API_JAVA_PACKAGE}" API_PACKAGE_NAME="${TD_API_SPEC_JAVA_PACKAGE}")
set_property(TARGET tdjni PROPERTY CXX_STANDARD 14)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

View File

@ -1,4 +1,4 @@
../src/main/jni-java-src/it/tdlight/jni/NativeClient.java
../src/main/jni-java-src/it/tdlight/jni/NativeLog.java
../src/main/jni-java-src/it/tdlight/tdnative/NativeClient.java
../src/main/jni-java-src/it/tdlight/tdnative/NativeLog.java
../src/main/jni-java-src/it/tdlight/jni/TdApi.java
../src/main/jni-java-src/it/tdlight/jni/ObjectsUtils.java
../src/main/jni-java-src/it/tdlight/tdnative/ObjectsUtils.java

View File

@ -129,11 +129,11 @@ static jint register_native(JavaVM *vm) {
auto client_class = td::jni::get_jclass(env, PACKAGE_NAME "/NativeClient");
log_class = td::jni::get_jclass(env, PACKAGE_NAME "/NativeLog");
auto object_class = td::jni::get_jclass(env, PACKAGE_NAME "/TdApi$Object");
auto function_class = td::jni::get_jclass(env, PACKAGE_NAME "/TdApi$Function");
auto object_class = td::jni::get_jclass(env, API_PACKAGE_NAME "/TdApi$Object");
auto function_class = td::jni::get_jclass(env, API_PACKAGE_NAME "/TdApi$Function");
#define TD_OBJECT "L" PACKAGE_NAME "/TdApi$Object;"
#define TD_FUNCTION "L" PACKAGE_NAME "/TdApi$Function;"
#define TD_OBJECT "L" API_PACKAGE_NAME "/TdApi$Object;"
#define TD_FUNCTION "L" API_PACKAGE_NAME "/TdApi$Function;"
register_method(client_class, "createNativeClient", "()I", Client_createNativeClient);
register_method(client_class, "nativeClientSend", "(IJ" TD_FUNCTION ")V", Client_nativeClientSend);
register_method(client_class, "nativeClientReceive", "([I[J[" TD_OBJECT "D)I", Client_nativeClientReceive);

View File

@ -1,4 +1,7 @@
package it.tdlight.jni;
package it.tdlight.tdnative;
import it.tdlight.jni.TdApi.Function;
import it.tdlight.jni.TdApi.Object;
public class NativeClient {

View File

@ -1,5 +1,7 @@
package it.tdlight.jni;
package it.tdlight.tdnative;
import it.tdlight.jni.TdApi.SetLogStream;
import it.tdlight.jni.TdApi.SetLogVerbosityLevel;
import java.util.function.Consumer;
/**

View File

@ -1,4 +1,4 @@
package it.tdlight.jni;
package it.tdlight.tdnative;
public class ObjectsUtils {
/**