2020-12-29 19:33:21 +01:00
|
|
|
#!/bin/bash -e
|
|
|
|
# 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-29 19:33:21 +01:00
|
|
|
# IMPLEMENTATION_NAME = <tdlib | tdlight>
|
2021-12-08 00:00:21 +01:00
|
|
|
# API_TYPE = <legacy | sealed>
|
2020-12-29 19:33:21 +01: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
|
2021-12-08 00:00:21 +01:00
|
|
|
if [ -z "${API_TYPE}" ]; then
|
|
|
|
echo "Missing parameter: API_TYPE"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-12-29 19:33:21 +01:00
|
|
|
|
2021-09-11 12:27:22 +02:00
|
|
|
source ./setup-variables.sh
|
|
|
|
|
2020-12-29 19:33:21 +01:00
|
|
|
cd ../../
|
|
|
|
|
|
|
|
# Print details
|
|
|
|
echo "Generating maven project..."
|
|
|
|
echo "Current directory: $(pwd)"
|
|
|
|
echo "Operating system: ${OPERATING_SYSTEM_NAME}"
|
|
|
|
echo "Architecture: ${CPU_ARCHITECTURE_NAME}"
|
|
|
|
echo "Td implementation: ${IMPLEMENTATION_NAME}"
|
2021-12-08 00:00:21 +01:00
|
|
|
echo "API type: ${API_TYPE}"
|
2020-12-29 19:33:21 +01:00
|
|
|
|
|
|
|
# Delete old data
|
|
|
|
echo "Deleting old data..."
|
2021-12-08 00:48:27 +01:00
|
|
|
[ -d "./generated-${API_TYPE}" ] && rm -r "./generated-${API_TYPE}"
|
2020-12-29 19:33:21 +01:00
|
|
|
|
|
|
|
# Create missing folders
|
|
|
|
echo "Creating missing folders..."
|
2021-12-08 00:48:27 +01:00
|
|
|
[ -d "./generated-${API_TYPE}" ] || mkdir "./generated-${API_TYPE}"
|
|
|
|
[ -d "./generated-${API_TYPE}/src/main" ] || mkdir -p "./generated-${API_TYPE}/src/main"
|
2020-12-29 19:33:21 +01:00
|
|
|
|
|
|
|
# Generate pom.xml
|
|
|
|
echo "Generating pom.xml..."
|
2021-12-08 00:48:27 +01:00
|
|
|
sed -f "src/main/replacements/replace-${OPERATING_SYSTEM_NAME}-${CPU_ARCHITECTURE_NAME}-${IMPLEMENTATION_NAME}-${API_TYPE}.sed" src/main/tdapi-project-src/pom.template.xml > "./generated-${API_TYPE}/pom.xml"
|
2020-12-29 19:33:21 +01:00
|
|
|
|
|
|
|
# Copy source files
|
|
|
|
echo "Copying source files..."
|
2021-12-08 00:48:27 +01:00
|
|
|
[ -d ./src/main/tdapi-java ] && cp -r ./src/main/tdapi-java "./generated-${API_TYPE}/src/main/java"
|
|
|
|
[ -d ./src/main/tdapi-resources ] && cp -r ./src/main/tdapi-resources "./generated-${API_TYPE}/src/main/resources"
|
2020-12-29 19:33:21 +01:00
|
|
|
|
|
|
|
echo "Done."
|
|
|
|
exit 0
|