2020-10-10 03:26:24 +02:00
|
|
|
#!/bin/bash -e
|
|
|
|
# REQUIRED PARAMETERS:
|
|
|
|
# OPERATING_SYSTEM_NAME = <windows | linux | osx>
|
|
|
|
# CPU_ARCHITECTURE_NAME = <amd64 | aarch64>
|
|
|
|
# IMPLEMENTATION_NAME = <tdlib | tdlight>
|
|
|
|
# CPU_CORES = <cores>
|
2020-10-10 15:08:26 +02:00
|
|
|
# CMAKE_EXTRA_ARGUMENTS = <args>
|
2020-10-10 03:26:24 +02:00
|
|
|
|
|
|
|
# Check variables correctness
|
|
|
|
if [ -z "${OPERATING_SYSTEM_NAME}" ]; then
|
|
|
|
echo "Missing parameter: OPERATING_SYSTEM_NAME"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "${CPU_ARCHITECTURE_NAME}" ]; then
|
|
|
|
echo "Missing parameter: CPU_ARCHITECTURE_NAME"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "${IMPLEMENTATION_NAME}" ]; then
|
|
|
|
echo "Missing parameter: IMPLEMENTATION_NAME"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "${CPU_CORES}" ]; then
|
|
|
|
echo "Missing parameter: CPU_CORES"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd ../
|
|
|
|
|
|
|
|
# Print details
|
|
|
|
echo "Generating TdApi.java..."
|
|
|
|
echo "Current directory: $(pwd)"
|
|
|
|
echo "Operating system: ${OPERATING_SYSTEM_NAME}"
|
|
|
|
echo "Architecture: ${CPU_ARCHITECTURE_NAME}"
|
|
|
|
echo "Td implementation: ${IMPLEMENTATION_NAME}"
|
2020-10-10 15:08:26 +02:00
|
|
|
echo "CPU cores count: ${CPU_CORES}"
|
|
|
|
echo "CMake extra arguments: '${CMAKE_EXTRA_ARGUMENTS}'"
|
2020-10-10 03:26:24 +02:00
|
|
|
|
2020-10-11 10:21:29 +02:00
|
|
|
# Setup constants
|
|
|
|
if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
|
|
|
|
export PYTHON_EXECUTABLE="python"
|
|
|
|
else
|
|
|
|
export PYTHON_EXECUTABLE="python3"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-10-10 03:26:24 +02:00
|
|
|
# Delete old data
|
|
|
|
echo "Deleting old data..."
|
|
|
|
[ -d ./generated/tdapi_java_build/ ] && rm -r ./generated/tdapi_java_build/
|
|
|
|
[ -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/
|
|
|
|
[ -d ./generated/src/main/jni-cpp-src/ ] && rm -r ./generated/src/main/jni-cpp-src/
|
|
|
|
[ -d ./generated/src/main/jni-java-src/ ] && rm -r ./generated/src/main/jni-java-src/
|
|
|
|
[ -f ./generated/src/main/java/it/tdlight/jni/TdApi.java ] && rm ./generated/src/main/java/it/tdlight/jni/TdApi.java
|
|
|
|
|
|
|
|
# Create missing folders
|
|
|
|
echo "Creating missing folders..."
|
|
|
|
[ -d ./generated/tdapi_java_build/ ] || mkdir ./generated/tdapi_java_build/
|
|
|
|
[ -d ./generated/tdjni_build/ ] || mkdir ./generated/tdjni_build/
|
|
|
|
[ -d ./generated/tdjni_bin/ ] || mkdir ./generated/tdjni_bin/
|
|
|
|
[ -d ./generated/tdjni_docs/ ] || mkdir ./generated/tdjni_docs/
|
|
|
|
|
|
|
|
# Copy source files
|
|
|
|
echo "Copying source files..."
|
2020-10-10 03:36:01 +02:00
|
|
|
cp -r ./src/main/jni-cpp-src/common/. ./generated/src/main/jni-cpp-src
|
|
|
|
cp -r ./src/main/jni-cpp-src/${IMPLEMENTATION_NAME}/. ./generated/src/main/jni-cpp-src
|
2020-10-10 03:26:24 +02:00
|
|
|
cp -r ./src/main/jni-java-src ./generated/src/main/jni-java-src
|
|
|
|
|
2020-10-10 23:53:21 +02:00
|
|
|
# Copy executables
|
|
|
|
echo "Copying executables..."
|
|
|
|
if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
|
2020-10-11 03:20:34 +02:00
|
|
|
export TD_GENERATED_BINARIES_DIR=$(realpath -m ./generated/td_tools/td/generate/Release)
|
2020-10-10 23:53:21 +02:00
|
|
|
else
|
2020-10-11 00:24:07 +02:00
|
|
|
export TD_GENERATED_BINARIES_DIR=$(realpath -m ./generated/td_tools/td/generate)
|
2020-10-10 23:53:21 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-10-10 03:26:24 +02:00
|
|
|
# Configure cmake
|
|
|
|
echo "Configuring CMake..."
|
|
|
|
cd ./generated/tdapi_java_build/
|
2020-10-10 16:50:46 +02:00
|
|
|
echo "Telegram source path: '$(realpath -m ../implementation/)'"
|
2020-10-10 18:42:05 +02:00
|
|
|
echo "Td bin path: '$(realpath -m ../td_bin/)'"
|
|
|
|
echo "Td bin files: $(ls $(realpath -m ../td_bin/))"
|
|
|
|
echo "Td bin/lib path: '$(realpath -m ../td_bin/lib/)'"
|
|
|
|
echo "Td bin/lib files: $(ls $(realpath -m ../td_bin/lib/))"
|
|
|
|
echo "Td CMake path: '$(realpath -m ../td_bin/lib/cmake/)'"
|
|
|
|
echo "Td CMake files: $(ls $(realpath -m ../td_bin/lib/cmake/))"
|
|
|
|
echo "Td CMake/td path: '$(realpath -m ../td_bin/lib/cmake/Td/)'"
|
|
|
|
echo "Td CMake/td files: $(ls $(realpath -m ../td_bin/lib/cmake/Td/))"
|
2020-10-10 03:26:24 +02:00
|
|
|
cmake -DCMAKE_BUILD_TYPE=Release \
|
2020-10-10 16:50:46 +02:00
|
|
|
-DTD_SRC_DIR=$(realpath -m ../implementation/) \
|
2020-10-10 23:53:21 +02:00
|
|
|
-DTD_GENERATED_BINARIES_DIR=${TD_GENERATED_BINARIES_DIR} \
|
2020-10-10 16:50:46 +02:00
|
|
|
-DTd_DIR=$(realpath -m ../td_bin/lib/cmake/Td/) \
|
|
|
|
-DTDNATIVES_BIN_DIR=$(realpath -m ../tdjni_bin/) \
|
|
|
|
-DTDNATIVES_DOCS_BIN_DIR=$(realpath -m ../tdjni_docs/) \
|
|
|
|
-DJAVA_SRC_DIR=$(realpath -m ../src/main/jni-java-src/) \
|
2020-10-10 15:32:45 +02:00
|
|
|
${CMAKE_EXTRA_ARGUMENTS} \
|
2020-10-10 16:50:46 +02:00
|
|
|
$(realpath -m ../src/main/jni-cpp-src/)
|
2020-10-10 03:26:24 +02:00
|
|
|
|
|
|
|
# Run cmake to generate TdApi.java
|
|
|
|
echo "Generating TdApi.java..."
|
2020-10-10 15:32:45 +02:00
|
|
|
cmake --build . --target td_generate_java_api --config Release ${CPU_CORES}
|
2020-10-10 03:26:24 +02:00
|
|
|
cd ..
|
|
|
|
|
|
|
|
echo "Patching TdApi.java..."
|
2020-10-11 10:21:29 +02:00
|
|
|
${PYTHON_EXECUTABLE} ../tdlib-serializer/ $(realpath -m ./src/main/jni-java-src/it/tdlight/jni/TdApi.java) $(realpath -m ./src/main/jni-java-src/it/tdlight/jni/new_TdApi.java) $(realpath -m ../tdlib-serializer/headers.txt)
|
2020-10-10 03:26:24 +02:00
|
|
|
rm ./src/main/jni-java-src/it/tdlight/jni/TdApi.java
|
2020-10-11 13:26:12 +02:00
|
|
|
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
|
|
|
unexpand --tabs=2 ./src/main/jni-java-src/it/tdlight/jni/new_TdApi.java > ./src/main/jni-java-src/it/tdlight/jni/TdApi.java
|
|
|
|
else
|
|
|
|
unexpand -t 2 ./src/main/jni-java-src/it/tdlight/jni/new_TdApi.java > ./src/main/jni-java-src/it/tdlight/jni/TdApi.java
|
|
|
|
fi
|
2020-10-10 03:26:24 +02:00
|
|
|
rm ./src/main/jni-java-src/it/tdlight/jni/new_TdApi.java
|
|
|
|
cp ./src/main/jni-java-src/it/tdlight/jni/TdApi.java ./src/main/java/it/tdlight/jni/TdApi.java
|
|
|
|
|
2020-10-10 16:50:46 +02:00
|
|
|
echo "Generated '$(realpath -m ./src/main/java/it/tdlight/jni/TdApi.java)'"
|
2020-10-10 03:26:24 +02:00
|
|
|
|
|
|
|
echo "Done."
|
|
|
|
exit 0
|