Cross compilation
This commit is contained in:
parent
ad010dd48f
commit
2449e393c3
42
.github/workflows/platform_natives.yaml
vendored
42
.github/workflows/platform_natives.yaml
vendored
@ -12,18 +12,18 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- {os: ubuntu-18.04, usedocker: "true", arch: "linux/386", implementation: "tdlight"}
|
||||
- {os: ubuntu-18.04, usedocker: "true", arch: "linux/386", implementation: "tdlib"}
|
||||
- {os: ubuntu-18.04, usedocker: "false", arch: "linux/386", implementation: "tdlight"}
|
||||
- {os: ubuntu-18.04, usedocker: "false", arch: "linux/386", implementation: "tdlib"}
|
||||
- {os: ubuntu-18.04, usedocker: "false", arch: "linux/amd64", implementation: "tdlight"}
|
||||
- {os: ubuntu-18.04, usedocker: "false", arch: "linux/amd64", implementation: "tdlib"}
|
||||
- {os: ubuntu-18.04, usedocker: "true", arch: "linux/arm/v6", implementation: "tdlight"}
|
||||
- {os: ubuntu-18.04, usedocker: "true", arch: "linux/arm/v6", implementation: "tdlib"}
|
||||
- {os: ubuntu-18.04, usedocker: "true", arch: "linux/arm/v7", implementation: "tdlight"}
|
||||
- {os: ubuntu-18.04, usedocker: "true", arch: "linux/arm/v7", implementation: "tdlib"}
|
||||
- {os: ubuntu-18.04, usedocker: "true", arch: "linux/arm64", implementation: "tdlight"}
|
||||
- {os: ubuntu-18.04, usedocker: "true", arch: "linux/arm64", implementation: "tdlib"}
|
||||
- {os: windows-2019, usedocker: "false", arch: "amd64", implementation: "tdlight"}
|
||||
- {os: windows-2019, usedocker: "false", arch: "amd64", implementation: "tdlib"}
|
||||
- {os: ubuntu-18.04, usedocker: "false", arch: "linux/arm/v6", implementation: "tdlight"}
|
||||
- {os: ubuntu-18.04, usedocker: "false", arch: "linux/arm/v6", implementation: "tdlib"}
|
||||
- {os: ubuntu-18.04, usedocker: "false", arch: "linux/arm/v7", implementation: "tdlight"}
|
||||
- {os: ubuntu-18.04, usedocker: "false", arch: "linux/arm/v7", implementation: "tdlib"}
|
||||
- {os: ubuntu-18.04, usedocker: "false", arch: "linux/arm64", implementation: "tdlight"}
|
||||
- {os: ubuntu-18.04, usedocker: "false", arch: "linux/arm64", implementation: "tdlib"}
|
||||
- {os: windows-2019, usedocker: "false", arch: "amd64", implementation: "tdlight", triplet: "x64-windows-static"}
|
||||
- {os: windows-2019, usedocker: "false", arch: "amd64", implementation: "tdlib", triplet: "x64-windows-static"}
|
||||
- {os: macos-10.15, usedocker: "false", arch: "amd64", implementation: "tdlight"}
|
||||
- {os: macos-10.15, usedocker: "false", arch: "amd64", implementation: "tdlib"}
|
||||
steps:
|
||||
@ -162,6 +162,28 @@ jobs:
|
||||
echo "OPERATING_SYSTEM_NAME_SHORT=$OPERATING_SYSTEM_NAME_SHORT" >> $GITHUB_ENV
|
||||
echo "SRC_TDJNI_LIBNAME=$SRC_TDJNI_LIBNAME" >> $GITHUB_ENV
|
||||
echo "DEST_TDJNI_LIBNAME=$DEST_TDJNI_LIBNAME" >> $GITHUB_ENV
|
||||
- name: Install latest CMake
|
||||
if: matrix.os == 'windows-2019'
|
||||
uses: lukka/get-cmake@latest
|
||||
- name: Restore artifacts, or setup vcpkg (do not install any package)
|
||||
if: matrix.os == 'windows-2019'
|
||||
uses: lukka/run-vcpkg@v7
|
||||
with:
|
||||
# Just install vcpkg for now, do not install any ports in this step yet.
|
||||
setupOnly: true
|
||||
# Location of the vcpkg submodule in the Git repository.
|
||||
vcpkgDirectory: '${{ env.VCPKG_DIR }}'
|
||||
# Since the cache must be invalidated when content of the vcpkg.json file changes, let's
|
||||
# compute its hash and append this to the computed cache's key.
|
||||
appendedCacheKey: ${{ hashFiles( '**/vcpkg_manifest/vcpkg.json' ) }}
|
||||
vcpkgTriplet: ${{ matrix.triplet }}
|
||||
# Ensure the vcpkg artifacts are cached, they are generated in the 'CMAKE_BINARY_DIR/vcpkg_installed' directory.
|
||||
- name: Install vcpkg deps
|
||||
if: matrix.os == 'windows-2019'
|
||||
run: |
|
||||
$VCPKG_DIR/vcpkg install gperf openssl:x64-windows-static zlib:x64-windows-static
|
||||
shell: bash
|
||||
|
||||
- name: Install dependencies
|
||||
if: matrix.usedocker == 'false'
|
||||
shell: bash
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -59,3 +59,4 @@ linux-deploy-snapshot.sh
|
||||
linux-generate-tdapi.sh
|
||||
win-build.sh
|
||||
win-deps.sh
|
||||
/.cache/
|
||||
|
@ -4,9 +4,10 @@ set -e
|
||||
if [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then
|
||||
echo "==Linux===="
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y make git zlib1g-dev libssl-dev gperf cmake \
|
||||
sudo apt-get install -y make git gperf cmake \
|
||||
ccache maven python3 python3-pip php-cli \
|
||||
clang libc++-dev libc++abi-dev
|
||||
build-essential gcc-multilib g++-multilib
|
||||
mkdir -p ""
|
||||
|
||||
elif [[ "$OPERATING_SYSTEM_NAME" == "osx" ]]; then
|
||||
echo "==OSX======"
|
||||
@ -40,26 +41,26 @@ elif [[ "$OPERATING_SYSTEM_NAME" == "osx" ]]; then
|
||||
#echo "Done .tlo"
|
||||
elif [[ "$OPERATING_SYSTEM_NAME" == "windows" ]]; then
|
||||
echo "==Windows=="
|
||||
choco install ccache
|
||||
choco install make
|
||||
#choco install ccache
|
||||
#choco install make
|
||||
#choco install windows-sdk-10.1
|
||||
choco install visualstudio2019buildtools --version=16.10.4.0 --allow-downgrade --package-parameters "--passive"
|
||||
choco install visualstudio2019-workload-vctools
|
||||
#choco install visualstudio2019buildtools --version=16.10.4.0 --allow-downgrade --package-parameters "--passive"
|
||||
#choco install visualstudio2019-workload-vctools
|
||||
#choco install openjdk11 --version=11.0.8.10
|
||||
choco install maven --version=3.8.2 --allow-downgrade
|
||||
choco install base64
|
||||
choco install gperf
|
||||
#choco install gperf
|
||||
choco install strawberryperl
|
||||
choco install nasm
|
||||
#choco install php --version=7.4.9 --package-parameters='"/ThreadSafe ""/InstallDir:C:\PHP"""'
|
||||
#choco install python3 --params "/InstallDir:C:\Python3"
|
||||
|
||||
[ -d ./windowsenv/ ] && $(yes | rm -rf ./windowsenv/)
|
||||
[ -d $VCPKG_DIR ] && $(yes | rm -rf $VCPKG_DIR)
|
||||
git clone --depth=1 https://github.com/tdlight-team/windows-amd64-prebuilt-libraries.git windowsenv
|
||||
mv windowsenv/vcpkg $VCPKG_DIR
|
||||
cd $VCPKG_DIR
|
||||
./vcpkg integrate install
|
||||
#[ -d $VCPKG_DIR ] && $(yes | rm -rf $VCPKG_DIR)
|
||||
#git clone --depth=1 https://github.com/tdlight-team/windows-amd64-prebuilt-libraries.git windowsenv
|
||||
#mv windowsenv/vcpkg $VCPKG_DIR
|
||||
#cd $VCPKG_DIR
|
||||
#./vcpkg integrate install
|
||||
else
|
||||
echo "Unrecognized os: $OPERATING_SYSTEM_NAME"
|
||||
exit 1
|
||||
|
@ -5,6 +5,8 @@ export MAVEN_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.
|
||||
echo "MATRIX_OS: $GH_MATRIX_OS"
|
||||
echo "MATRIX_ARCH: $GH_MATRIX_ARCH"
|
||||
|
||||
source ../../core/setup-variables.sh
|
||||
|
||||
if [ "$GH_MATRIX_OS" == "macos-10.15" ]; then
|
||||
export PCRE="E"
|
||||
else
|
||||
@ -20,27 +22,21 @@ fi
|
||||
|
||||
if [[ "$GH_CPU_ARCH" == "arm64" ]]; then
|
||||
export CPU_ARCHITECTURE_NAME="aarch64"
|
||||
export CPU_ARCH_JAVA="arm64"
|
||||
export CPU_CORES_NUM="2"
|
||||
elif [[ "$GH_CPU_ARCH" == "armv6" ]]; then
|
||||
export CPU_ARCHITECTURE_NAME="armv6"
|
||||
export CPU_ARCH_JAVA="armv6"
|
||||
export CPU_CORES_NUM="2"
|
||||
elif [[ "$GH_CPU_ARCH" == "armv7" ]]; then
|
||||
export CPU_ARCHITECTURE_NAME="armv7"
|
||||
export CPU_ARCH_JAVA="armv7"
|
||||
export CPU_CORES_NUM="2"
|
||||
elif [[ "$GH_CPU_ARCH" == "386" ]]; then
|
||||
export CPU_ARCHITECTURE_NAME="386"
|
||||
export CPU_ARCH_JAVA="386"
|
||||
export CPU_CORES_NUM="2"
|
||||
elif [[ "$GH_CPU_ARCH" == "amd64" ]]; then
|
||||
export CPU_ARCHITECTURE_NAME="amd64"
|
||||
export CPU_ARCH_JAVA="amd64"
|
||||
export CPU_CORES_NUM="2"
|
||||
elif [[ "$GH_CPU_ARCH" == "ppc64le" ]]; then
|
||||
export CPU_ARCHITECTURE_NAME="ppc64le"
|
||||
export CPU_ARCH_JAVA="ppc64le"
|
||||
export CPU_CORES_NUM="2"
|
||||
else
|
||||
echo "Unrecognized cpu arch: $GH_CPU_ARCH"
|
||||
@ -63,7 +59,7 @@ fi
|
||||
|
||||
echo "====== Setup variables ======"
|
||||
echo "Current root directory:"
|
||||
echo "$(realpath .)"
|
||||
realpath .
|
||||
echo "============================="
|
||||
|
||||
# ====== OS Variables
|
||||
@ -80,21 +76,6 @@ elif [[ "$OPERATING_SYSTEM_NAME" == "osx" ]]; then
|
||||
export CPU_CORES=" -- -j${CPU_CORES_NUM}"
|
||||
elif [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then
|
||||
export BUILD_TYPE=MinSizeRel
|
||||
if [[ "$CPU_ARCHITECTURE_NAME" == "aarch64" ]]; then
|
||||
export CMAKE_EXTRA_ARGUMENTS=""
|
||||
else
|
||||
export CMAKE_EXTRA_ARGUMENTS="-DOPENSSL_USE_STATIC_LIBS=ON -DCMAKE_FIND_LIBRARY_SUFFIXES=\".a\""
|
||||
fi
|
||||
|
||||
if [[ "$CPU_ARCHITECTURE_NAME" == "386" ]] || [[ "$CPU_ARCHITECTURE_NAME" == "armv6" ]] || [[ "$CPU_ARCHITECTURE_NAME" == "armv7" ]]; then
|
||||
export CMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS -latomic"
|
||||
export LDFLAGS="$LDFLAGS -latomic"
|
||||
export CXXFLAGS="$CXXFLAGS -latomic"
|
||||
fi
|
||||
|
||||
export CXXFLAGS="$CXXFLAGS -static-libgcc -static-libstdc++"
|
||||
export CC="/usr/bin/clang"
|
||||
export CXX="/usr/bin/clang++"
|
||||
|
||||
export CPU_CORES=" -- -j${CPU_CORES_NUM}"
|
||||
fi
|
||||
@ -118,7 +99,6 @@ echo "CMAKE_EXTRA_ARGUMENTS=${CMAKE_EXTRA_ARGUMENTS}"
|
||||
echo "VCPKG_DIR=${VCPKG_DIR}"
|
||||
echo "MAVEN_OPTS=${MAVEN_OPTS}"
|
||||
echo "GH_CPU_ARCH=${GH_CPU_ARCH}"
|
||||
echo "CPU_ARCH_JAVA=${CPU_ARCH_JAVA}"
|
||||
echo "CPU_ARCHITECTURE_NAME=${CPU_ARCHITECTURE_NAME}"
|
||||
echo "CPU_CORES_NUM=${CPU_CORES_NUM}"
|
||||
echo "CPU_CORES=${CPU_CORES}"
|
||||
|
@ -30,6 +30,8 @@ if [ -z "${CPU_CORES}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ./setup-variables.sh
|
||||
|
||||
cd ../../
|
||||
|
||||
# Print details
|
||||
|
@ -35,6 +35,8 @@ if [ -z "${CPU_CORES}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ./setup-variables.sh
|
||||
|
||||
cd ../../
|
||||
JAVA_API_PACKAGE_PATH="it/tdlight/jni"
|
||||
JAVA_LIB_PACKAGE_PATH="it/tdlight/tdnative"
|
||||
@ -83,6 +85,31 @@ else
|
||||
export TD_GENERATED_BINARIES_DIR=$(realpath -m ./generated/td_tools/td/generate)
|
||||
fi
|
||||
|
||||
# Create toolchain
|
||||
echo "Creating toolchain file..."
|
||||
{
|
||||
echo "set(CMAKE_SYSTEM_PROCESSOR ${CPU_ARCH_CMAKE})";
|
||||
echo "set(CMAKE_C_COMPILER ${CPU_ARCH_CMAKE}-linux-gnu-gcc)";
|
||||
echo "set(CMAKE_C_COMPILER_TARGET ${CLANG_TRIPLE})";
|
||||
echo "set(CMAKE_CXX_COMPILER ${CPU_ARCH_CMAKE}-linux-gnu-g++)";
|
||||
echo "set(CMAKE_CXX_COMPILER_TARGET ${CLANG_TRIPLE})";
|
||||
echo "set(CMAKE_ASM_COMPILER ${CPU_ARCH_CMAKE}-linux-gnu-g++)";
|
||||
echo "set(CMAKE_ASM_COMPILER_TARGET ${CLANG_TRIPLE})";
|
||||
echo "set(CMAKE_LIBRARY_PATH /usr/${CPU_ARCH_CMAKE}-linux-gnu/include)";
|
||||
cat <<EOF
|
||||
SET(CMAKE_SYSTEM_NAME Linux)
|
||||
EOF
|
||||
if [[ ${CPU_ARCHITECTURE_NAME} == "aarch64" || ${CPU_ARCHITECTURE_NAME} == "armv6" || ${CPU_ARCHITECTURE_NAME} == "armv7" ]]; then
|
||||
cat <<EOF
|
||||
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
||||
set(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||
set(CMAKE_USE_WIN32_THREADS_INIT 0)
|
||||
set(CMAKE_USE_PTHREADS_INIT 1)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
EOF
|
||||
fi
|
||||
} > ./generated/tdjni_build/toolchain.cmake
|
||||
|
||||
# Configure cmake
|
||||
echo "Configuring CMake..."
|
||||
cd ./generated/tdjni_build/
|
||||
@ -96,6 +123,7 @@ cmake \
|
||||
-DJAVA_SRC_DIR=$(realpath -m ../src/main/jni-java-src/) \
|
||||
-DTDNATIVES_CPP_SRC_DIR:PATH=$(realpath -m ../src/main/jni-cpp-src/) \
|
||||
-DOPENSSL_USE_STATIC_LIBS=True \
|
||||
"-DCMAKE_TOOLCHAIN_FILE=$CROSS_BUILD_DEPS_DIR/toolchain.cmake" \
|
||||
${CMAKE_EXTRA_ARGUMENTS} \
|
||||
$(realpath -m ../src/main/jni-cpp-src/)
|
||||
|
||||
|
@ -30,6 +30,8 @@ if [ -z "${CPU_CORES}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ./setup-variables.sh
|
||||
|
||||
cd ../../
|
||||
|
||||
# Print details
|
||||
@ -63,10 +65,12 @@ INSTALL_PREFIX="$(realpath -m ../td_bin/)"
|
||||
INSTALL_BINDIR="$(realpath -m ../td_bin/bin)"
|
||||
echo "Install prefix: $INSTALL_PREFIX"
|
||||
echo "Install bindir: $INSTALL_BINDIR"
|
||||
# shellcheck disable=SC2086
|
||||
cmake "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_PREFIX" \
|
||||
-DCMAKE_INSTALL_BINDIR:PATH="$INSTALL_BINDIR" \
|
||||
-DTD_ENABLE_JNI=ON \
|
||||
"-DCMAKE_TOOLCHAIN_FILE=$CROSS_BUILD_DEPS_DIR/toolchain.cmake" \
|
||||
${CMAKE_EXTRA_ARGUMENTS_TD} \
|
||||
${CMAKE_EXTRA_ARGUMENTS} \
|
||||
../implementation
|
||||
|
@ -8,6 +8,8 @@ if [ -z "${REVISION}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ./setup-variables.sh
|
||||
|
||||
cd ../../generated
|
||||
|
||||
mvn -B -q -Drevision=${REVISION} clean deploy
|
||||
|
@ -18,6 +18,8 @@ if [ -z "${IMPLEMENTATION_NAME}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ./setup-variables.sh
|
||||
|
||||
cd ../../
|
||||
|
||||
# Print details
|
||||
|
@ -25,6 +25,8 @@ if [ -z "${CPU_CORES}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ./setup-variables.sh
|
||||
|
||||
cd ../../
|
||||
|
||||
# Print details
|
||||
|
@ -25,6 +25,8 @@ if [ -z "${CPU_CORES}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ./setup-variables.sh
|
||||
|
||||
cd ../../
|
||||
JAVA_API_PACKAGE_PATH="it/tdlight/jni"
|
||||
JAVA_LIB_PACKAGE_PATH="it/tdlight/tdnative"
|
||||
|
@ -18,6 +18,8 @@ if [ -z "${IMPLEMENTATION_NAME}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ./setup-variables.sh
|
||||
|
||||
cd ../../
|
||||
|
||||
# Print details
|
||||
|
187
scripts/core/install-dependencies.sh
Executable file
187
scripts/core/install-dependencies.sh
Executable file
@ -0,0 +1,187 @@
|
||||
#!/bin/bash -e
|
||||
# MAIN REQUIRED ENVIRONMENT VARIABLES:
|
||||
# OPERATING_SYSTEM_NAME = <windows | linux | osx>
|
||||
# CPU_ARCHITECTURE_NAME = <amd64 | aarch64 | 386 | armv6 | armv7 | ppc64le>
|
||||
# IMPLEMENTATION_NAME = <tdlib | tdlight>
|
||||
# BUILD_TYPE = <Debug | Release | RelWithDebInfo | MinSizeRel>
|
||||
# CPU_CORES = "-- -j<cores>" or "-m" on Windows
|
||||
# OTHER REQUIRED ENVIRONMENT VARIABLES:
|
||||
# CMAKE_EXTRA_ARGUMENTS = <args>
|
||||
|
||||
# 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 "${BUILD_TYPE}" ]; then
|
||||
echo "Missing parameter: BUILD_TYPE"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${CPU_CORES}" ]; then
|
||||
echo "Missing parameter: CPU_CORES"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ./setup-variables.sh
|
||||
|
||||
cd ../../
|
||||
ROOT_DIR="$(pwd)"
|
||||
|
||||
# Print details
|
||||
echo "Installing dependencies..."
|
||||
echo "Current directory: $ROOT_DIR"
|
||||
echo "Operating system: ${OPERATING_SYSTEM_NAME}"
|
||||
echo "Architecture: ${CPU_ARCHITECTURE_NAME}"
|
||||
echo "Td implementation: ${IMPLEMENTATION_NAME}"
|
||||
echo "Build type: ${BUILD_TYPE}"
|
||||
echo "CPU cores count: ${CPU_CORES}"
|
||||
echo "CMake extra arguments: '${CMAKE_EXTRA_ARGUMENTS}'"
|
||||
|
||||
CROSS_OPENJDK_PATH=""
|
||||
fix_jdk_path() {
|
||||
# Setup OpenJDK path
|
||||
CROSS_OPENJDK_PATH="$(find "$CROSS_BUILD_DEPS_DIR/usr/lib/jvm/" -maxdepth 1 -type d -iname "java*jdk*" | head -n 1)"
|
||||
}
|
||||
|
||||
check_jdk_existance() {
|
||||
if [[ ! -d "$CROSS_OPENJDK_PATH" ]]; then
|
||||
echo "Can't find cross OpenJDK at location $CROSS_OPENJDK_PATH"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then
|
||||
fix_jdk_path
|
||||
if [[ ! -f "$CROSS_BUILD_DEPS_DIR/ok-012" ]]; then
|
||||
rm -rf "$CROSS_BUILD_DEPS_DIR" || true
|
||||
mkdir -p "$CROSS_BUILD_DEPS_DIR"
|
||||
sudo dpkg --add-architecture "${CPU_ARCH_DPKG}"
|
||||
sudo apt-get update || true
|
||||
sudo apt-get install -y "libstdc++-11-dev-${CPU_ARCH_DPKG}-cross" \
|
||||
"crossbuild-essential-${CPU_ARCH_DPKG}" "libstdc++-11-pic-${CPU_ARCH_DPKG}-cross"
|
||||
cd "$CROSS_BUILD_DEPS_DIR"
|
||||
# LibZ-Dev
|
||||
apt-get download "zlib1g-dev:${CPU_ARCH_DPKG}"
|
||||
ZLIB1G_DEV_DEB="$(find "$CROSS_BUILD_DEPS_DIR" -maxdepth 1 -type f -iname "zlib1g-dev*.deb" | head -n 1)"
|
||||
dpkg -x "$ZLIB1G_DEV_DEB" "$CROSS_BUILD_DEPS_DIR"
|
||||
rm "$ZLIB1G_DEV_DEB"
|
||||
# LibZ
|
||||
apt-get download "zlib1g:${CPU_ARCH_DPKG}"
|
||||
ZLIB1G_DEB="$(find "$CROSS_BUILD_DEPS_DIR" -maxdepth 1 -type f -iname "zlib1g*.deb" | head -n 1)"
|
||||
dpkg -x "$ZLIB1G_DEB" "$CROSS_BUILD_DEPS_DIR"
|
||||
rm "$ZLIB1G_DEB"
|
||||
# LibSSL-Dev
|
||||
apt-get download "libssl-dev:${CPU_ARCH_DPKG}"
|
||||
LIBSSL_DEV_DEB="$(find "$CROSS_BUILD_DEPS_DIR" -maxdepth 1 -type f -iname "libssl-dev*.deb" | head -n 1)"
|
||||
dpkg -x "$LIBSSL_DEV_DEB" "$CROSS_BUILD_DEPS_DIR"
|
||||
rm "$LIBSSL_DEV_DEB"
|
||||
# LibSSL
|
||||
apt-get download "libssl1.1:${CPU_ARCH_DPKG}"
|
||||
LIBSSL_DEB="$(find "$CROSS_BUILD_DEPS_DIR" -maxdepth 1 -type f -iname "libssl1.1*.deb" | head -n 1)"
|
||||
dpkg -x "$LIBSSL_DEB" "$CROSS_BUILD_DEPS_DIR"
|
||||
rm "$LIBSSL_DEB"
|
||||
# Java Common
|
||||
apt-get download "java-common"
|
||||
JC_DEB="$(find "$CROSS_BUILD_DEPS_DIR" -maxdepth 1 -type f -iname "java-common*.deb" | head -n 1)"
|
||||
dpkg -x "$JC_DEB" "$CROSS_BUILD_DEPS_DIR"
|
||||
rm "$JC_DEB"
|
||||
# OpenJDK-JRE-Headless
|
||||
apt-get download "openjdk-11-jre-headless:${CPU_ARCH_DPKG}"
|
||||
OJDKRH_DEB="$(find "$CROSS_BUILD_DEPS_DIR" -maxdepth 1 -type f -iname "openjdk-11-jre-headless*.deb" | head -n 1)"
|
||||
dpkg -x "$OJDKRH_DEB" "$CROSS_BUILD_DEPS_DIR"
|
||||
rm "$OJDKRH_DEB"
|
||||
# OpenJDK-JRE
|
||||
apt-get download "openjdk-11-jre:${CPU_ARCH_DPKG}"
|
||||
OJDKR_DEB="$(find "$CROSS_BUILD_DEPS_DIR" -maxdepth 1 -type f -iname "openjdk-11-jre*.deb" | head -n 1)"
|
||||
dpkg -x "$OJDKR_DEB" "$CROSS_BUILD_DEPS_DIR"
|
||||
rm "$OJDKR_DEB"
|
||||
# OpenJDK-JDK
|
||||
apt-get download "openjdk-11-jdk-headless:${CPU_ARCH_DPKG}"
|
||||
OJDKJ_DEB="$(find "$CROSS_BUILD_DEPS_DIR" -maxdepth 1 -type f -iname "openjdk-11-jdk-headless*.deb" | head -n 1)"
|
||||
dpkg -x "$OJDKJ_DEB" "$CROSS_BUILD_DEPS_DIR"
|
||||
rm "$OJDKJ_DEB"
|
||||
# OpenJDK-GUI
|
||||
apt-get download "openjdk-11-jdk:${CPU_ARCH_DPKG}"
|
||||
OJDKG_DEB="$(find "$CROSS_BUILD_DEPS_DIR" -maxdepth 1 -type f -iname "openjdk-11-jdk*.deb" | head -n 1)"
|
||||
dpkg -x "$OJDKG_DEB" "$CROSS_BUILD_DEPS_DIR"
|
||||
rm "$OJDKG_DEB"
|
||||
|
||||
# Fix symlinks
|
||||
find "$CROSS_BUILD_DEPS_DIR" -lname "/*" \
|
||||
-exec sh -c "ln -sf \"\`echo \"$CROSS_BUILD_DEPS_DIR\$(readlink \$0)\"\`\" \"\$0\"" {} \;
|
||||
|
||||
# Check if openjdk is found
|
||||
fix_jdk_path
|
||||
check_jdk_existance
|
||||
|
||||
touch "$CROSS_BUILD_DEPS_DIR/ok-012"
|
||||
fi
|
||||
|
||||
check_jdk_existance
|
||||
|
||||
# Create toolchain
|
||||
echo "Creating toolchain file..."
|
||||
cd "$ROOT_DIR"
|
||||
{
|
||||
echo "set(CMAKE_SYSTEM_PROCESSOR ${CPU_ARCH_CMAKE})";
|
||||
echo "set(CMAKE_C_COMPILER ${CPU_ARCH_CMAKE}-linux-gnu-gcc)";
|
||||
echo "set(CMAKE_C_COMPILER_TARGET ${CLANG_TRIPLE})";
|
||||
echo "set(CMAKE_CXX_COMPILER ${CPU_ARCH_CMAKE}-linux-gnu-g++)";
|
||||
echo "set(CMAKE_CXX_COMPILER_TARGET ${CLANG_TRIPLE})";
|
||||
echo "set(CMAKE_ASM_COMPILER ${CPU_ARCH_CMAKE}-linux-gnu-g++)";
|
||||
echo "set(CMAKE_ASM_COMPILER_TARGET ${CLANG_TRIPLE})";
|
||||
echo "set(CMAKE_LIBRARY_PATH \"$CROSS_BUILD_DEPS_DIR/\")";
|
||||
#echo "include_directories(\"${CROSS_BUILD_DEPS_DIR}\")";
|
||||
#echo "include_directories(\"${CROSS_BUILD_DEPS_DIR}/usr/include/\")";
|
||||
echo "include_directories(\"${CROSS_BUILD_DEPS_DIR}/usr/include/${CPU_ARCH_CMAKE}-linux-gnu/\")";
|
||||
echo "include_directories(\"${CROSS_OPENJDK_PATH}/include\")";
|
||||
echo "include_directories(\"${CROSS_OPENJDK_PATH}/include/linux\")";
|
||||
#echo "set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES \"$CROSS_BUILD_DEPS_DIR/usr/include/\" \"${CROSS_BUILD_DEPS_DIR}/usr/include/${CPU_ARCH_CMAKE}-linux-gnu/\")";
|
||||
|
||||
echo "SET(CMAKE_FIND_ROOT_PATH \"$CROSS_BUILD_DEPS_DIR\" \"$JAVA_HOME\")";
|
||||
#echo "SET(JAVA_HOME \"$CROSS_OPENJDK_PATH\")";
|
||||
echo "SET(JAVA_INCLUDE_PATH \"$CROSS_OPENJDK_PATH/include\")";
|
||||
echo "SET(JAVA_INCLUDE_PATH2 \"$CROSS_OPENJDK_PATH/include/linux\")";
|
||||
echo "SET(JAVA_JVM_LIBRARY \"$CROSS_OPENJDK_PATH/lib/server/libjvm.so\")";
|
||||
echo "SET(JAVA_AWT_LIBRARY \"$CROSS_OPENJDK_PATH/lib/libawt.so\")";
|
||||
echo "SET(JNI_INCLUDE_DIRS \"$CROSS_OPENJDK_PATH/include\" \"$CROSS_OPENJDK_PATH/include/linux\")";
|
||||
echo "SET(JNI_LIBRARIES \"$CROSS_OPENJDK_PATH/lib/server/libjvm.so\" \"$CROSS_OPENJDK_PATH/lib/libawt.so\")";
|
||||
echo "SET(JNI_FOUND True)";
|
||||
echo "MESSAGE(STATUS \"JNI INCLUDE DIRS: \${JNI_INCLUDE_DIRS}\")";
|
||||
echo "MESSAGE(STATUS \"JNI LIBS: \${JNI_LIBRARIES}\")";
|
||||
#echo "SET(JAVA_AWT_LIBRARY \"$CROSS_OPENJDK_PATH\")";
|
||||
#echo "SET(JAVA_JVM_LIBRARY \"$CROSS_OPENJDK_PATH\")";
|
||||
#echo "SET(JAVA_AWT_INCLUDE_PATH \"$CROSS_OPENJDK_PATH\")";
|
||||
cat <<EOF
|
||||
SET(CMAKE_SYSTEM_NAME Linux)
|
||||
|
||||
# Use our definitions for compiler tools
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
# Search for libraries and headers in the target directories only
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
EOF
|
||||
if [[ ${CPU_ARCHITECTURE_NAME} == "aarch64" || ${CPU_ARCHITECTURE_NAME} == "armv6" || ${CPU_ARCHITECTURE_NAME} == "armv7" ]]; then
|
||||
cat <<EOF
|
||||
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
||||
set(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||
set(CMAKE_USE_WIN32_THREADS_INIT 0)
|
||||
set(CMAKE_USE_PTHREADS_INIT 1)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
EOF
|
||||
fi
|
||||
} > "$CROSS_BUILD_DEPS_DIR/toolchain.cmake"
|
||||
|
||||
fi;
|
||||
|
||||
echo "Done."
|
||||
exit 0
|
89
scripts/core/setup-variables.sh
Executable file
89
scripts/core/setup-variables.sh
Executable file
@ -0,0 +1,89 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
echo "====== Setup variables ======"
|
||||
echo "Current root directory:"
|
||||
realpath .
|
||||
echo "============================="
|
||||
|
||||
# ====== CPU Architecture Variables
|
||||
if [[ "$CPU_ARCHITECTURE_NAME" == "aarch64" ]]; then
|
||||
export CPU_ARCH_JAVA="arm64"
|
||||
export CPU_ARCH_DPKG="arm64"
|
||||
export CPU_ARCH_CMAKE="aarch64"
|
||||
export CLANG_TRIPLE="aarch64-linux-gnu"
|
||||
export CPU_CORES_NUM="2"
|
||||
elif [[ "$CPU_ARCHITECTURE_NAME" == "armv6" ]]; then
|
||||
export CPU_ARCH_JAVA="armv6"
|
||||
export CPU_ARCH_DPKG="armhf"
|
||||
export CPU_ARCH_CMAKE="arm"
|
||||
export CLANG_TRIPLE="arm-linux-gnu"
|
||||
export CPU_CORES_NUM="2"
|
||||
elif [[ "$CPU_ARCHITECTURE_NAME" == "armv7" ]]; then
|
||||
export CPU_ARCH_JAVA="armv7"
|
||||
export CPU_ARCH_DPKG="armhf"
|
||||
export CPU_ARCH_CMAKE="arm"
|
||||
export CLANG_TRIPLE="arm-linux-gnueabihf"
|
||||
export CPU_CORES_NUM="2"
|
||||
elif [[ "$CPU_ARCHITECTURE_NAME" == "386" ]]; then
|
||||
export CPU_ARCH_JAVA="386"
|
||||
export CPU_ARCH_DPKG="i386"
|
||||
export CPU_ARCH_CMAKE="i386"
|
||||
export CLANG_TRIPLE="i386-linux-gnu"
|
||||
export CPU_CORES_NUM="2"
|
||||
elif [[ "$CPU_ARCHITECTURE_NAME" == "amd64" ]]; then
|
||||
export CPU_ARCH_JAVA="amd64"
|
||||
export CPU_ARCH_DPKG="amd64"
|
||||
export CPU_ARCH_CMAKE="x86_64"
|
||||
export CLANG_TRIPLE="x86_64-linux-gnu"
|
||||
export CPU_CORES_NUM="2"
|
||||
elif [[ "$CPU_ARCHITECTURE_NAME" == "ppc64le" ]]; then
|
||||
export CPU_ARCH_JAVA="ppc64le"
|
||||
export CPU_ARCH_DPKG="ppc64el"
|
||||
export CPU_ARCH_CMAKE="ppc64el"
|
||||
export CLANG_TRIPLE="powerpc64-linux-gnu"
|
||||
export CPU_CORES_NUM="2"
|
||||
else
|
||||
echo "Unrecognized cpu arch: $CPU_ARCHITECTURE_NAME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unset CROSS_BUILD_DEPS_DIR
|
||||
export CROSS_BUILD_DEPS_DIR
|
||||
if [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then
|
||||
if [[ "$CPU_ARCHITECTURE_NAME" == "aarch64" ]]; then
|
||||
export CMAKE_EXTRA_ARGUMENTS="$CMAKE_EXTRA_ARGUMENTS"
|
||||
else
|
||||
export CMAKE_EXTRA_ARGUMENTS="$CMAKE_EXTRA_ARGUMENTS -DOPENSSL_USE_STATIC_LIBS=ON -DCMAKE_FIND_LIBRARY_SUFFIXES=\".a\""
|
||||
fi
|
||||
|
||||
if [[ "$CPU_ARCHITECTURE_NAME" == "386" ]] || [[ "$CPU_ARCHITECTURE_NAME" == "armv6" ]] || [[ "$CPU_ARCHITECTURE_NAME" == "armv7" ]]; then
|
||||
export CMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS -latomic"
|
||||
export LDFLAGS="$LDFLAGS -latomic"
|
||||
export CXXFLAGS="$CXXFLAGS -latomic"
|
||||
fi
|
||||
|
||||
export CXXFLAGS="$CXXFLAGS -static-libgcc -static-libstdc++"
|
||||
export CC="gcc"
|
||||
export CXX="g++"
|
||||
|
||||
export CROSS_CXXFLAGS="$CXXFLAGS -static-libgcc -static-libstdc++"
|
||||
export CROSS_CC="${CPU_ARCH_CMAKE}-linux-gnu-gcc"
|
||||
export CROSS_CXX="${CPU_ARCH_CMAKE}-linux-gnu-g++"
|
||||
|
||||
CROSS_BUILD_DEPS_DIR="$(realpath ../../)/.cache/tdlib-build-cross-${CPU_ARCH_DPKG}/"
|
||||
fi
|
||||
|
||||
# ====== Print variables
|
||||
echo "========= Variables ========="
|
||||
echo "Variables"
|
||||
echo "CPU_ARCH_JAVA=${CPU_ARCH_JAVA}"
|
||||
echo "CPU_ARCH_DPKG=${CPU_ARCH_DPKG}"
|
||||
echo "CPU_ARCH_CMAKE=${CPU_ARCH_CMAKE}"
|
||||
echo "CLANG_TRIPLE=${CLANG_TRIPLE}"
|
||||
echo "CC=${CC}"
|
||||
echo "CXX=${CXX}"
|
||||
echo "CXXFLAGS=${CXXFLAGS}"
|
||||
echo "CMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}"
|
||||
echo "CMAKE_EXTRA_ARGUMENTS=${CMAKE_EXTRA_ARGUMENTS}"
|
||||
echo "CROSS_BUILD_DEPS_DIR=${CROSS_BUILD_DEPS_DIR}"
|
||||
echo "============================="
|
@ -13,6 +13,8 @@
|
||||
|
||||
cd ../core
|
||||
|
||||
source ./setup-variables.sh
|
||||
./install-dependencies.sh
|
||||
./generate_maven_project.sh
|
||||
./generate_td_tools.sh
|
||||
./configure_td.sh
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
cd ../core
|
||||
|
||||
source ./setup-variables.sh
|
||||
./install-dependencies.sh
|
||||
./generate_tdapi_maven_project.sh
|
||||
./generate_td_tools.sh
|
||||
./configure_td.sh
|
||||
|
Loading…
Reference in New Issue
Block a user