From 16ab948f60692f60b89085b63a62c2ab6c125e4f Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Sun, 7 May 2023 17:32:20 +0200 Subject: [PATCH] Use env vars --- .../scripts/build-linux-amd64-ssl1.sh | 22 ++++++++++++++----- .../scripts/build-linux-amd64-ssl3.sh | 22 ++++++++++++++----- .../scripts/build-linux-arm64-ssl1.sh | 12 +++++++--- .../cmake-includes-ubuntu2004.cmake | 20 ----------------- .../cmake-includes-ubuntu2204.cmake | 20 ----------------- 5 files changed, 43 insertions(+), 53 deletions(-) delete mode 100644 .github/workflows/toolchains/cmake-includes-ubuntu2004.cmake delete mode 100644 .github/workflows/toolchains/cmake-includes-ubuntu2204.cmake diff --git a/.github/workflows/scripts/build-linux-amd64-ssl1.sh b/.github/workflows/scripts/build-linux-amd64-ssl1.sh index e9d0d73..94e7234 100755 --- a/.github/workflows/scripts/build-linux-amd64-ssl1.sh +++ b/.github/workflows/scripts/build-linux-amd64-ssl1.sh @@ -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 .. diff --git a/.github/workflows/scripts/build-linux-amd64-ssl3.sh b/.github/workflows/scripts/build-linux-amd64-ssl3.sh index 030e0de..3e6c57f 100755 --- a/.github/workflows/scripts/build-linux-amd64-ssl3.sh +++ b/.github/workflows/scripts/build-linux-amd64-ssl3.sh @@ -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 .. diff --git a/.github/workflows/scripts/build-linux-arm64-ssl1.sh b/.github/workflows/scripts/build-linux-arm64-ssl1.sh index 96801b0..3cd466c 100755 --- a/.github/workflows/scripts/build-linux-arm64-ssl1.sh +++ b/.github/workflows/scripts/build-linux-arm64-ssl1.sh @@ -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" diff --git a/.github/workflows/toolchains/cmake-includes-ubuntu2004.cmake b/.github/workflows/toolchains/cmake-includes-ubuntu2004.cmake deleted file mode 100644 index 5dc718d..0000000 --- a/.github/workflows/toolchains/cmake-includes-ubuntu2004.cmake +++ /dev/null @@ -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) diff --git a/.github/workflows/toolchains/cmake-includes-ubuntu2204.cmake b/.github/workflows/toolchains/cmake-includes-ubuntu2204.cmake deleted file mode 100644 index 24d25ba..0000000 --- a/.github/workflows/toolchains/cmake-includes-ubuntu2204.cmake +++ /dev/null @@ -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)