2020-10-10 03:26:24 +02:00
|
|
|
#!/bin/bash -e
|
2020-12-28 19:52:17 +01:00
|
|
|
# MAIN REQUIRED ENVIRONMENT VARIABLES:
|
|
|
|
# OPERATING_SYSTEM_NAME = <windows | linux | osx>
|
2021-09-14 13:32:20 +02:00
|
|
|
# CPU_ARCHITECTURE_NAME = <amd64 | aarch64 | 386 | s390x | armhf | ppc64le>
|
2020-12-28 19:52:17 +01:00
|
|
|
# IMPLEMENTATION_NAME = <tdlib | tdlight>
|
|
|
|
# CPU_CORES = "-- -j<cores>" or "-m" on Windows
|
|
|
|
# OTHER REQUIRED ENVIRONMENT VARIABLES:
|
|
|
|
# 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
|
|
|
|
|
2021-09-11 12:27:22 +02:00
|
|
|
source ./setup-variables.sh
|
|
|
|
|
2020-12-28 19:52:17 +01:00
|
|
|
cd ../../
|
2020-10-10 03:26:24 +02:00
|
|
|
|
|
|
|
# Print details
|
|
|
|
echo "Generating td tools..."
|
|
|
|
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
|
|
|
|
|
|
|
# Delete old data
|
|
|
|
echo "Deleting old data..."
|
|
|
|
[ -d ./generated/implementation/ ] && rm -r ./generated/implementation/
|
|
|
|
[ -d ./generated/td_tools/ ] && rm -r ./generated/td_tools/
|
|
|
|
|
2021-12-08 00:48:27 +01:00
|
|
|
# Create missing folders
|
|
|
|
echo "Creating missing folders..."
|
|
|
|
[ -d "./generated" ] || mkdir "./generated"
|
|
|
|
|
2020-10-10 03:26:24 +02:00
|
|
|
# Copy implementation files
|
|
|
|
echo "Copying implementation files..."
|
|
|
|
cp -r implementations/${IMPLEMENTATION_NAME} ./generated/implementation
|
|
|
|
|
2021-07-02 18:52:43 +02:00
|
|
|
# Patch implementation files (sed replacements)
|
|
|
|
echo "Patching implementation files using sed replacements..."
|
2020-10-11 12:15:37 +02:00
|
|
|
#Fix bug: https://github.com/tdlib/td/issues/1238
|
|
|
|
if [[ "$IMPLEMENTATION_NAME" = "tdlib" ]]; then
|
2020-10-11 13:09:47 +02:00
|
|
|
if [[ "$OPERATING_SYSTEM_NAME" = "osx" ]]; then
|
|
|
|
sed -f "src/main/replacements/fix-tdlib-tdutils-windows-cmake.sed" -i "" ./generated/implementation/tdutils/CMakeLists.txt
|
|
|
|
else
|
|
|
|
sed -f "src/main/replacements/fix-tdlib-tdutils-windows-cmake.sed" -i"" ./generated/implementation/tdutils/CMakeLists.txt
|
|
|
|
fi
|
2020-10-11 12:15:37 +02:00
|
|
|
fi
|
|
|
|
|
2021-07-02 18:52:43 +02:00
|
|
|
# Patch implementation files (git patches)
|
|
|
|
echo "Patching implementation files using git patches..."
|
|
|
|
if [[ "$IMPLEMENTATION_NAME" = "tdlib" ]]; then
|
|
|
|
if [[ -d "src/main/patches/tdlib" && "$(ls -A src/main/patches/tdlib)" ]]; then
|
2021-07-02 18:56:08 +02:00
|
|
|
git apply --directory="generated/implementation" src/main/patches/tdlib/*.patch
|
2021-07-02 18:52:43 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ "$IMPLEMENTATION_NAME" = "tdlight" ]]; then
|
|
|
|
if [[ -d "src/main/patches/tdlight" && "$(ls -A src/main/patches/tdlight)" ]]; then
|
2021-07-02 18:56:08 +02:00
|
|
|
git apply --directory="generated/implementation" src/main/patches/tdlight/*.patch
|
2021-07-02 18:52:43 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2020-10-10 03:26:24 +02:00
|
|
|
# Configure cmake
|
|
|
|
echo "Configuring CMake..."
|
|
|
|
mkdir ./generated/td_tools/
|
|
|
|
cd ./generated/td_tools/
|
2022-03-15 19:30:08 +01:00
|
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DTD_ENABLE_JNI=ON ${CMAKE_EXTRA_ARGUMENTS} ../implementation/
|
2020-10-10 03:26:24 +02:00
|
|
|
|
|
|
|
# Run cmake to generate common tools
|
|
|
|
echo "Generating cross compilation tools..."
|
2020-10-11 03:20:34 +02:00
|
|
|
cmake --build . --target prepare_cross_compiling --config Release ${CPU_CORES}
|
2020-10-10 03:26:24 +02:00
|
|
|
|
|
|
|
# Run cmake to generate java tools
|
|
|
|
echo "Generating java tools..."
|
2020-10-11 03:20:34 +02:00
|
|
|
cmake --build . --target td_generate_java_api --config Release ${CPU_CORES}
|
2020-10-10 03:26:24 +02:00
|
|
|
|
2021-03-12 14:57:56 +01:00
|
|
|
# Copy tlo files
|
|
|
|
echo "Copying *.tlo files..."
|
|
|
|
cp -r ../implementation/td/generate/auto/tlo/. ../implementation/td/generate/scheme/.
|
|
|
|
|
|
|
|
|
2020-10-10 16:50:46 +02:00
|
|
|
echo "Generated executable '$(realpath -m ./td/generate/generate_common)'"
|
|
|
|
echo "Generated executable '$(realpath -m ./td/generate/td_generate_java_api)'"
|
|
|
|
echo "Generated executable '$(realpath -m ./td/generate/td_generate_json)'"
|
|
|
|
echo "Generated executable '$(realpath -m ../implementation/td/generate/JavadocTlDocumentationGenerator.php)'"
|
|
|
|
echo "Generated executable '$(realpath -m ../implementation/td/generate/TlDocumentationGenerator.php)'"
|
|
|
|
echo "Generated executable '$(realpath -m ../implementation/td/generate/scheme/td_api.tl)'"
|
|
|
|
echo "Generated executable '$(realpath -m ../implementation/td/generate/scheme/td_api.tlo)'"
|
2020-10-10 03:26:24 +02:00
|
|
|
|
|
|
|
echo "Done."
|
|
|
|
exit 0
|