From 12b486d88fc1db8e3bcb4ad92bb4e5b0b257de63 Mon Sep 17 00:00:00 2001 From: shouren Date: Mon, 16 Dec 2024 17:40:25 +0800 Subject: [PATCH] feat: Avoid downloading precompiled third-party and zetasql package in CMakeList.txt in third-party dir when envs are set. Signed-off-by: shouren --- third-party/CMakeLists.txt | 35 +++++++++++++++------------- third-party/cmake/FetchZetasql.cmake | 31 +++++++++++++----------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 5d8b4b4b2cd..aec99bd8200 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -117,23 +117,26 @@ endif() # Fetch hybridsql asserts if(NOT BUILD_BUNDLED) - init_hybridsql_thirdparty_urls() - - message(STATUS "Download pre-compiled hybridsql assert from ${HYBRIDSQL_ASSERTS_URL}") - if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64)|(ARM64)|(aarch64)|(AARCH64)") - message(WARNING pre-compiled hybridsql aseerts for arm64 may out-of-date, consider build from source by '-DBUILD_BUNDLED=ON') + if (DEFINED ENV{THIRDPARTY_VERSION} AND "$ENV{THIRDPARTY_VERSION}" STREQUAL "${HYBRIDSQL_ASSERTS_VERSION}") + message(STATUS "THIRDPARTY_VERSION matches HYBRIDSQL_ASSERTS_VERSION, skipping download.") + else() + init_hybridsql_thirdparty_urls() + message(STATUS "Download pre-compiled hybridsql assert from ${HYBRIDSQL_ASSERTS_URL}") + if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64)|(ARM64)|(aarch64)|(AARCH64)") + message(WARNING pre-compiled hybridsql aseerts for arm64 may out-of-date, consider build from source by '-DBUILD_BUNDLED=ON') + endif() + ExternalProject_Add( + hybridsql-asserts + URL ${HYBRIDSQL_ASSERTS_URL} + URL_HASH SHA256=${HYBRIDSQL_ASSERTS_HASH} + PREFIX ${DEPS_BUILD_DIR} + DOWNLOAD_DIR "${DEPS_DOWNLOAD_DIR}/hybridsql-asserts" + DOWNLOAD_NO_EXTRACT True + INSTALL_DIR ${DEPS_INSTALL_DIR} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND bash -c "tar xzf -C ${DEPS_INSTALL_DIR} --strip-components=1") endif() - ExternalProject_Add( - hybridsql-asserts - URL ${HYBRIDSQL_ASSERTS_URL} - URL_HASH SHA256=${HYBRIDSQL_ASSERTS_HASH} - PREFIX ${DEPS_BUILD_DIR} - DOWNLOAD_DIR "${DEPS_DOWNLOAD_DIR}/hybridsql-asserts" - DOWNLOAD_NO_EXTRACT True - INSTALL_DIR ${DEPS_INSTALL_DIR} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND bash -c "tar xzf -C ${DEPS_INSTALL_DIR} --strip-components=1") endif() if (BUILD_BUNDLED_GTEST) diff --git a/third-party/cmake/FetchZetasql.cmake b/third-party/cmake/FetchZetasql.cmake index 4e27b9aac6b..c876bc23e53 100644 --- a/third-party/cmake/FetchZetasql.cmake +++ b/third-party/cmake/FetchZetasql.cmake @@ -46,20 +46,23 @@ endfunction() if (NOT BUILD_BUNDLED_ZETASQL) - init_zetasql_urls() - - message(STATUS "Download pre-compiled zetasql from ${ZETASQL_URL}") - # download pre-compiled zetasql from GitHub Release - ExternalProject_Add(zetasql - URL ${ZETASQL_URL} - URL_HASH SHA256=${ZETASQL_HASH} - PREFIX ${DEPS_BUILD_DIR} - DOWNLOAD_DIR "${DEPS_DOWNLOAD_DIR}/zetasql" - DOWNLOAD_NO_EXTRACT True - INSTALL_DIR ${DEPS_INSTALL_DIR} - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND bash -c "tar xzf -C ${DEPS_INSTALL_DIR} --strip-components=1") + if (DEFINED ENV{ZETASQL_VERSION} AND "$ENV{ZETASQL_VERSION}" STREQUAL "${ZETASQL_VERSION}") + message(STATUS "ZETASQL_VERSION from env matches ZETASQL_VERSION, skipping download.") + else() + init_zetasql_urls() + message(STATUS "Download pre-compiled zetasql from ${ZETASQL_URL}") + # download pre-compiled zetasql from GitHub Release + ExternalProject_Add(zetasql + URL ${ZETASQL_URL} + URL_HASH SHA256=${ZETASQL_HASH} + PREFIX ${DEPS_BUILD_DIR} + DOWNLOAD_DIR "${DEPS_DOWNLOAD_DIR}/zetasql" + DOWNLOAD_NO_EXTRACT True + INSTALL_DIR ${DEPS_INSTALL_DIR} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND bash -c "tar xzf -C ${DEPS_INSTALL_DIR} --strip-components=1") + endif() else() find_program(BAZEL_EXE NAMES bazel REQUIRED DOC "Compile zetasql require bazel or bazelisk") find_program(PYTHON_EXE NAMES python REQUIRED DOC "Compile zetasql require python")