Use env vars

This commit is contained in:
Andrea Cavalli 2023-05-07 17:32:20 +02:00
parent a79f4565a9
commit 16ab948f60
5 changed files with 43 additions and 53 deletions

View File

@ -1,25 +1,30 @@
#!/bin/bash -ex
# Ubuntu 20.04
REVISION="${REVISION:-1.0.0.0-SNAPSHOT}"
HOST_CMAKE_INCLUDES_FILE="$(readlink -e ./.github/workflows/toolchains/cmake-includes-ubuntu2004.cmake)"
# Create missing dirs
rm -rf implementations/tdlight/td_tools_build implementations/tdlight/build api/target-legacy api/target api/.ci-friendly-pom.xml implementations/tdlight/td/generate/auto natives/src/main/java/it/tdlight/jni natives/build natives/tdjni_bin natives/tdjni_docs
mkdir -p implementations/tdlight/build implementations/tdlight/build/td_bin/bin implementations/tdlight/td_tools_build/java/it/tdlight/jni api/src/main/java-legacy/it/tdlight/jni api/src/main/java-sealed/it/tdlight/jni natives/src/main/java/it/tdlight/jni natives/build natives/tdjni_bin natives/tdjni_docs
# Default compiler
# machine-specific flags
export CMAKE_C_COMPILER="/usr/bin/clang-10"
export CMAKE_CXX_COMPILER="/usr/bin/clang++-10"
export HOST_CMAKE_C_FLAGS="-Wno-psabi --specs=nosys.specs -fdata-sections -ffunction-sections -Wl,--gc-sections"
export HOST_CMAKE_CXX_FLAGS="${HOST_CMAKE_C_FLAGS} -stdlib=libc++ -fno-exceptions"
export HOST_CMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++ -lc++abi"
# Build tdlib tools
cd implementations/tdlight/td_tools_build
cmake \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} ${HOST_CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} ${HOST_CMAKE_CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} ${HOST_CMAKE_EXE_LINKER_FLAGS}" \
\
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS_RELEASE="" \
-DCMAKE_CXX_FLAGS_RELEASE="-O0 -DNDEBUG" \
-DTD_ENABLE_LTO=OFF \
-DTD_ENABLE_JNI=ON \
-DCMAKE_TOOLCHAIN_FILE="${HOST_CMAKE_INCLUDES_FILE}" \
..
cmake --build . --target prepare_cross_compiling "-j$(nproc)"
cmake --build . --target td_generate_java_api "-j$(nproc)"
@ -31,6 +36,7 @@ cd ../../../
# Optimization flags
export CMAKE_C_FLAGS="${CMAKE_C_FLAGS}"
export CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -std=c++14 -fno-omit-frame-pointer -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti"
export CMAKE_SHARED_LINKER_FLAGS="${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL"
export CMAKE_CXX_FLAGS_MINSIZEREL="${CMAKE_CXX_FLAGS_MINSIZEREL} -flto=thin -Oz"
@ -40,19 +46,26 @@ cd implementations/tdlight/build
INSTALL_PREFIX="$(readlink -e ./td_bin/)"
INSTALL_BINDIR="$(readlink -e ./td_bin/bin)"
cmake \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} ${HOST_CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} ${HOST_CMAKE_CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} ${HOST_CMAKE_EXE_LINKER_FLAGS}" \
\
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DTD_SKIP_BENCHMARK=ON -DTD_SKIP_TEST=ON -DTD_SKIP_TG_CLI=ON \
-DTD_ENABLE_LTO=ON \
-DTD_ENABLE_JNI=ON \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_PREFIX" \
-DCMAKE_INSTALL_BINDIR:PATH="$INSTALL_BINDIR" \
-DCMAKE_TOOLCHAIN_FILE="${HOST_CMAKE_INCLUDES_FILE}" \
..
cmake --build . --target install --config Release "-j$(nproc)"
cd ../../../
cd natives/build
cmake \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} ${HOST_CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} ${HOST_CMAKE_CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} ${HOST_CMAKE_EXE_LINKER_FLAGS}" \
\
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DTD_GENERATED_BINARIES_DIR=../../implementations/tdlight/build/td/generate \
-DTD_SRC_DIR=../../implementations/tdlight \
@ -63,7 +76,6 @@ cmake \
-DJAVA_SRC_DIR="../src/main/java" \
-DJava_JAVADOC_EXECUTABLE="/bin/true" \
-DTDNATIVES_CPP_SRC_DIR="../src/main/cpp" \
-DCMAKE_TOOLCHAIN_FILE="${HOST_CMAKE_INCLUDES_FILE}" \
../src/main/cpp
cmake --build . --target install --config Release "-j$(nproc)"
cd ..

View File

@ -1,25 +1,30 @@
#!/bin/bash -ex
# Ubuntu 22.04
REVISION="${REVISION:-1.0.0.0-SNAPSHOT}"
HOST_CMAKE_INCLUDES_FILE="$(readlink -e ./.github/workflows/toolchains/cmake-includes-ubuntu2204.cmake)"
# Create missing dirs
rm -rf implementations/tdlight/td_tools_build implementations/tdlight/build api/target-legacy api/target api/.ci-friendly-pom.xml implementations/tdlight/td/generate/auto natives/src/main/java/it/tdlight/jni natives/build natives/tdjni_bin natives/tdjni_docs
mkdir -p implementations/tdlight/build implementations/tdlight/build/td_bin/bin implementations/tdlight/td_tools_build/java/it/tdlight/jni api/src/main/java-legacy/it/tdlight/jni api/src/main/java-sealed/it/tdlight/jni natives/src/main/java/it/tdlight/jni natives/build natives/tdjni_bin natives/tdjni_docs
# Default compiler
# machine-specific flags
export CMAKE_C_COMPILER="/usr/bin/clang-14"
export CMAKE_CXX_COMPILER="/usr/bin/clang++-14"
export HOST_CMAKE_C_FLAGS="-Wno-psabi --specs=nosys.specs -fdata-sections -ffunction-sections -Wl,--gc-sections"
export HOST_CMAKE_CXX_FLAGS="${HOST_CMAKE_C_FLAGS} -stdlib=libc++ -fno-exceptions"
export HOST_CMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++ -lc++abi"
# Build tdlib tools
cd implementations/tdlight/td_tools_build
cmake \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} ${HOST_CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} ${HOST_CMAKE_CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} ${HOST_CMAKE_EXE_LINKER_FLAGS}" \
\
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS_RELEASE="" \
-DCMAKE_CXX_FLAGS_RELEASE="-O0 -DNDEBUG" \
-DTD_ENABLE_LTO=OFF \
-DTD_ENABLE_JNI=ON \
-DCMAKE_TOOLCHAIN_FILE="${HOST_CMAKE_INCLUDES_FILE}" \
..
cmake --build . --target prepare_cross_compiling "-j$(nproc)"
cmake --build . --target td_generate_java_api "-j$(nproc)"
@ -31,6 +36,7 @@ cd ../../../
# Optimization flags
export CMAKE_C_FLAGS="${CMAKE_C_FLAGS}"
export CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -std=c++14 -fno-omit-frame-pointer -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti"
export CMAKE_SHARED_LINKER_FLAGS="${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL"
export CMAKE_CXX_FLAGS_MINSIZEREL="${CMAKE_CXX_FLAGS_MINSIZEREL} -flto=thin -Oz"
@ -40,19 +46,26 @@ cd implementations/tdlight/build
INSTALL_PREFIX="$(readlink -e ./td_bin/)"
INSTALL_BINDIR="$(readlink -e ./td_bin/bin)"
cmake \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} ${HOST_CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} ${HOST_CMAKE_CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} ${HOST_CMAKE_EXE_LINKER_FLAGS}" \
\
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DTD_SKIP_BENCHMARK=ON -DTD_SKIP_TEST=ON -DTD_SKIP_TG_CLI=ON \
-DTD_ENABLE_LTO=ON \
-DTD_ENABLE_JNI=ON \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_PREFIX" \
-DCMAKE_INSTALL_BINDIR:PATH="$INSTALL_BINDIR" \
-DCMAKE_TOOLCHAIN_FILE="${HOST_CMAKE_INCLUDES_FILE}" \
..
cmake --build . --target install --config Release "-j$(nproc)"
cd ../../../
cd natives/build
cmake \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} ${HOST_CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} ${HOST_CMAKE_CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} ${HOST_CMAKE_EXE_LINKER_FLAGS}" \
\
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DTD_GENERATED_BINARIES_DIR=../../implementations/tdlight/build/td/generate \
-DTD_SRC_DIR=../../implementations/tdlight \
@ -63,7 +76,6 @@ cmake \
-DJAVA_SRC_DIR="../src/main/java" \
-DJava_JAVADOC_EXECUTABLE="/bin/true" \
-DTDNATIVES_CPP_SRC_DIR="../src/main/cpp" \
-DCMAKE_TOOLCHAIN_FILE="${HOST_CMAKE_INCLUDES_FILE}" \
../src/main/cpp
cmake --build . --target install --config Release "-j$(nproc)"
cd ..

View File

@ -1,26 +1,31 @@
#!/bin/bash -ex
# Ubuntu 20.04
REVISION="${REVISION:-1.0.0.0-SNAPSHOT}"
HOST_CMAKE_INCLUDES_FILE="$(readlink -e ./.github/workflows/toolchains/cmake-includes-ubuntu2004.cmake)"
TOOLCHAIN_FILE="$(readlink -e ./.github/workflows/toolchains/toolchain-arm64.cmake)"
# Create missing dirs
rm -rf implementations/tdlight/td_tools_build implementations/tdlight/build api/target-legacy api/target api/.ci-friendly-pom.xml implementations/tdlight/td/generate/auto natives/src/main/java/it/tdlight/jni natives/build natives/tdjni_bin natives/tdjni_docs
mkdir -p implementations/tdlight/build implementations/tdlight/build/td_bin/bin implementations/tdlight/td_tools_build/java/it/tdlight/jni api/src/main/java-legacy/it/tdlight/jni api/src/main/java-sealed/it/tdlight/jni natives/src/main/java/it/tdlight/jni natives/build natives/tdjni_bin natives/tdjni_docs
# Default compiler
# machine-specific flags
export CMAKE_C_COMPILER="/usr/bin/clang-10"
export CMAKE_CXX_COMPILER="/usr/bin/clang++-10"
export HOST_CMAKE_C_FLAGS="-Wno-psabi --specs=nosys.specs -fdata-sections -ffunction-sections -Wl,--gc-sections"
export HOST_CMAKE_CXX_FLAGS="${HOST_CMAKE_C_FLAGS} -stdlib=libc++ -fno-exceptions"
export HOST_CMAKE_EXE_LINKER_FLAGS="-stdlib=libc++ -lc++ -lc++abi"
# Build tdlib tools
cd implementations/tdlight/td_tools_build
cmake \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} ${HOST_CMAKE_C_FLAGS}" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} ${HOST_CMAKE_CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} ${HOST_CMAKE_EXE_LINKER_FLAGS}" \
\
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS_RELEASE="" \
-DCMAKE_CXX_FLAGS_RELEASE="-O0 -DNDEBUG" \
-DTD_ENABLE_LTO=OFF \
-DTD_ENABLE_JNI=ON \
-DCMAKE_TOOLCHAIN_FILE="${HOST_CMAKE_INCLUDES_FILE}" \
..
cmake --build . --target prepare_cross_compiling "-j$(nproc)"
cmake --build . --target td_generate_java_api "-j$(nproc)"
@ -31,6 +36,7 @@ cd ../../../
# Optimization flags
export CMAKE_C_FLAGS="${CMAKE_C_FLAGS}"
export CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -std=c++14 -fno-omit-frame-pointer -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti"
export CMAKE_SHARED_LINKER_FLAGS="${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL"
export CMAKE_CXX_FLAGS_MINSIZEREL="${CMAKE_CXX_FLAGS_MINSIZEREL} -flto=thin -Oz"

View File

@ -1,20 +0,0 @@
SET(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER "/usr/bin/clang-10")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++-10")
set(CMAKE_AR /usr/bin/llvm-ar-10)
# Set various compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-psabi --specs=nosys.specs -fdata-sections -ffunction-sections -Wl,--gc-sections")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} -stdlib=libc++ -fno-exceptions")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++ -lc++abi")
# Use LLD on linux
add_link_options("-fuse-ld=lld")
# ccache
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) # Less useful to do it for linking, see edit2
endif(CCACHE_FOUND)

View File

@ -1,20 +0,0 @@
SET(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER "/usr/bin/clang-14")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++-14")
set(CMAKE_AR /usr/bin/llvm-ar-14)
# Set various compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-psabi --specs=nosys.specs -fdata-sections -ffunction-sections -Wl,--gc-sections")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} -stdlib=libc++ -fno-exceptions")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++ -lc++abi")
# Use LLD on linux
add_link_options("-fuse-ld=lld")
# ccache
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) # Less useful to do it for linking, see edit2
endif(CCACHE_FOUND)