From 1b95dcc64c1e92a12b5dba8b40a3c33295bf9135 Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Fri, 14 Feb 2025 19:16:29 +0000 Subject: [PATCH] HPCC-33490 Add vcpkg support for antlr3 dependency Signed-off-by Gordon Smith --- .gitmodules | 3 -- cmake_modules/FindANTLR.cmake | 18 +++++--- cmake_modules/plugins.cmake | 5 ++ esp/services/ws_sql/CMakeLists.txt | 10 ++-- esp/services/ws_sql/antlr3c.cmake | 68 ---------------------------- esp/services/ws_sql/libantlr3c | 1 - vcpkg.json.in | 4 ++ vcpkg_overlays/antlr3/portfile.cmake | 35 ++++++++++++++ vcpkg_overlays/antlr3/vcpkg.json | 10 ++++ 9 files changed, 70 insertions(+), 84 deletions(-) delete mode 100644 esp/services/ws_sql/antlr3c.cmake delete mode 160000 esp/services/ws_sql/libantlr3c create mode 100644 vcpkg_overlays/antlr3/portfile.cmake create mode 100644 vcpkg_overlays/antlr3/vcpkg.json diff --git a/.gitmodules b/.gitmodules index 7a1feb78615..8b499020641 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "esp/src/dgrid"] path = esp/src/dgrid url = https://github.com/hpcc-systems/dgrid.git -[submodule "esp/services/ws_sql/libantlr3c"] - path = esp/services/ws_sql/libantlr3c - url = https://github.com/hpcc-systems/libantlr3c.git [submodule "vcpkg"] path = vcpkg url = https://github.com/hpcc-systems/vcpkg.git diff --git a/cmake_modules/FindANTLR.cmake b/cmake_modules/FindANTLR.cmake index 09dad328820..97e632f783b 100644 --- a/cmake_modules/FindANTLR.cmake +++ b/cmake_modules/FindANTLR.cmake @@ -19,18 +19,24 @@ # ANTLR_FOUND - ANTLR found in local system # ANTLR_BUILDTIME_JAR - The jar needed to build/generate ANTLR Lexers and Parsers # ANTLR_RUNTIME_JAR - The jar needed to build/generate ANTLR Lexers and Parsers +# ANTLR_LIB - The runtime library needed by the generated ANTLR Lexers and Parsers ################################################################################ include(UseJava) -set(ANTLR_BUILDTIME_DEP "antlr-3.4-complete" CACHE STRING "ANTLR buildtime jar file name.") -set(ANTLR_RUNTIME_DEP "antlr-runtime-3.4" CACHE STRING "ANTLR runtime jar file name.") -set(ANTLR_PATH "${HPCC_SOURCE_DIR}/esp/services/ws_sql/libantlr3c" CACHE PATH "Location of ANTLR jar files.") -set(ANTLR_PKG_FIND_ERROR_MSG "Could not locate jars.\nPlease run `git submodule update --init --recursive`\n") +set(ANTLR_PKG_FIND_ERROR_MSG "Could not locate jars.\nPlease check vcpkg configure completed without issue.\n") +find_library(ANTLR_LIB NAMES antlr3c + PATHS ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET} +) -find_jar(ANTLR_BUILDTIME_JAR ${ANTLR_BUILDTIME_DEP} PATHS ${ANTLR_PATH}) -find_jar(ANTLR_RUNTIME_JAR ${ANTLR_RUNTIME_DEP} PATHS ${ANTLR_PATH}) +find_file(ANTLR_BUILDTIME_JAR "share/antlr3/antlr-3.4-complete.jar" + PATHS ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET} +) + +find_file(ANTLR_RUNTIME_JAR "share/antlr3/antlr-runtime-3.4.jar" + PATHS ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET} +) include(FindPackageHandleStandardArgs) find_package_handle_standard_args( diff --git a/cmake_modules/plugins.cmake b/cmake_modules/plugins.cmake index 1892188c756..d78e7264fb2 100644 --- a/cmake_modules/plugins.cmake +++ b/cmake_modules/plugins.cmake @@ -85,6 +85,11 @@ if (USE_PARQUET) endif() # vcpkg.json options --- +set(VCPKG_ANTLR3 "${VCPKG_SUPPRESS}") +if (WSSQL_SERVICE) + set(VCPKG_ANTLR3 "${VCPKG_INCLUDE}") +endif() + set(VCPKG_APR "${VCPKG_SUPPRESS}") if (USE_APR) set(VCPKG_APR "${VCPKG_INCLUDE}") diff --git a/esp/services/ws_sql/CMakeLists.txt b/esp/services/ws_sql/CMakeLists.txt index 4fbe42b5b8e..14944593166 100644 --- a/esp/services/ws_sql/CMakeLists.txt +++ b/esp/services/ws_sql/CMakeLists.txt @@ -30,13 +30,11 @@ if(WSSQL_SERVICE) include(${HPCC_SOURCE_DIR}/esp/scm/smcscm.cmake) include(${HPCC_SOURCE_DIR}/esp/scm/espscm.cmake) - include(antlr3c.cmake) - antlr_target(sql2ecl GRAMMAR_PREFIX HPCCSQL DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" GRAMMAR_FILES "${CMAKE_CURRENT_SOURCE_DIR}/SQL2ECL/ANTLR3c/HPCCSQL.g" - ) + ) set(SRCS ${CMAKE_CURRENT_SOURCE_DIR}/ws_sqlPlugin.cpp @@ -95,7 +93,6 @@ if(WSSQL_SERVICE) ${HPCC_SOURCE_DIR}/common/dllserver ${HPCC_SOURCE_DIR}/common/deftype ${HPCC_SOURCE_DIR}/ecl/hql - ${libantlr3c_includes} ${ESPSCM_GENERATED_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/SQL2ECL ${HPCC_SOURCE_DIR}/common/thorhelper @@ -120,7 +117,7 @@ if(WSSQL_SERVICE) xmllib esphttp dalibase - libantlr3c + ${ANTLR_LIB} wuwebview ${COMMON_ESP_SERVICE_LIBS} ) @@ -137,5 +134,6 @@ ENDIF() RUNTIME DESTINATION ${EXEC_DIR} LIBRARY DESTINATION ${LIB_DIR} COMPONENT Runtime - ) + CALC_DEPS + ) endif() diff --git a/esp/services/ws_sql/antlr3c.cmake b/esp/services/ws_sql/antlr3c.cmake deleted file mode 100644 index c2c14c57c30..00000000000 --- a/esp/services/ws_sql/antlr3c.cmake +++ /dev/null @@ -1,68 +0,0 @@ -################################################################################ -# HPCC SYSTEMS software Copyright(C) 2017 HPCC Systems. -# -# Licensed under the Apache License, Version 2.0(the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -################################################################################ - -# generate third party library for inclusion in wssql project - -set(ANTLRcCONFIGURE_COMMAND_PARAMS "--silent" "--disable-antlrdebug") -if(WIN32) - set(ANTLR3c_lib "antlr3c.lib") -elseif(APPLE) - set(ANTLR3c_lib "libantlr3c.dylib") -else() - set(ANTLR3c_lib "libantlr3c.so") -endif() - -if(UNIX) - if(${ARCH64BIT} EQUAL 1) - set(ANTLRcCONFIGURE_COMMAND_PARAMS ${ANTLRcCONFIGURE_COMMAND_PARAMS} "--enable-64bit") - set(osdir "x86_64-linux-gnu") - else() - set(osdir "i386-linux-gnu") - endif() -elseif(WIN32) - set(osdir "lib") -else() - set(osdir "unknown") -endif() - -include(ExternalProject) -ExternalProject_Add( - antlr3c - DOWNLOAD_COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/libantlr3c ${CMAKE_CURRENT_BINARY_DIR}/antlr3c/src - SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/antlr3c/src/libantlr3c - CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/antlr3c/src/libantlr3c/configure ${ANTLRcCONFIGURE_COMMAND_PARAMS} --prefix=${CMAKE_CURRENT_BINARY_DIR}/antlr3c 2> antlr.cfg.err - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/antlr3c - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/antlr3c/lib/${ANTLR3c_lib} - BUILD_IN_SOURCE 1 - ) - -set(libantlr3c_includes - ${CMAKE_CURRENT_BINARY_DIR}/antlr3c/include - ) - -add_library(libantlr3c SHARED IMPORTED GLOBAL) -set_property(TARGET libantlr3c PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/antlr3c/lib/${ANTLR3c_lib}) -add_dependencies(libantlr3c antlr3c) - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/antlr3c/lib/${ANTLR3c_lib} - DESTINATION ${LIB_DIR}/external - COMPONENT Runtime - ) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/antlr3c/src/libantlr3c/COPYING - DESTINATION ${LIB_DIR}/external - COMPONENT Runtime - RENAME antlr3c-bsd-license.txt - ) diff --git a/esp/services/ws_sql/libantlr3c b/esp/services/ws_sql/libantlr3c deleted file mode 160000 index bfd2e5eb58f..00000000000 --- a/esp/services/ws_sql/libantlr3c +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bfd2e5eb58fafc55fb069b55c970b4132c670bdb diff --git a/vcpkg.json.in b/vcpkg.json.in index c26c8d0a390..f15dc96436d 100644 --- a/vcpkg.json.in +++ b/vcpkg.json.in @@ -3,6 +3,10 @@ "name": "hpcc-platform", "version": "9.10.0", "dependencies": [ + { + "name": "antlr3", + "platform": "@VCPKG_ANTLR3@" + }, { "name": "apr", "platform": "@VCPKG_APR@" diff --git a/vcpkg_overlays/antlr3/portfile.cmake b/vcpkg_overlays/antlr3/portfile.cmake new file mode 100644 index 00000000000..78725799f7f --- /dev/null +++ b/vcpkg_overlays/antlr3/portfile.cmake @@ -0,0 +1,35 @@ +vcpkg_download_distfile(LIB_C + URLS "https://github.com/antlr/website-antlr3/raw/refs/heads/gh-pages/download/C/libantlr3c-${VERSION}.tar.gz" + FILENAME "libantlr3c-${VERSION}.tar.gz" + SHA512 8edb243d745ff5bf3b15940f124d1255a9ca965cb656a73a558aed7fa07effcd7620f23dc692e5d5169a03200254836dd57af3ce444ba225281a5b721497e211 +) +vcpkg_extract_source_archive(SOURCE_PATH + ARCHIVE "${LIB_C}" +) +vcpkg_configure_make( + SOURCE_PATH "${SOURCE_PATH}" + COPY_SOURCE + OPTIONS + --enable-64bit +) +vcpkg_install_make() +vcpkg_fixup_pkgconfig() +vcpkg_copy_pdbs() + +vcpkg_download_distfile(COMPLETE_JAR + URLS "https://github.com/antlr/website-antlr3/raw/refs/heads/gh-pages/download/antlr-${VERSION}-complete.jar" + FILENAME "antlr-${VERSION}-complete.jar" + SHA512 04be4dfba3a21f3ab9d9e439a64958bd8e844a9f151b798383bd9e0dd6ebc416783ae7cb1d1dbb27fb7288ab9756b13b8338cdb8ceb41a10949c852ad45ab1f2 +) +vcpkg_download_distfile(RUNTIME_JAR + URLS "https://github.com/antlr/website-antlr3/raw/refs/heads/gh-pages/download/antlr-runtime-${VERSION}.jar" + FILENAME "antlr-runtime-${VERSION}.jar" + SHA512 1786aff2df4664483adcb319e64be7b69b643ac9508c3f11796b5aa45b9072b46f53f0a21b2ff7291162afe81506de16161746273e4532ebad75adbd81203f0d +) +file(INSTALL + DESTINATION "${CURRENT_PACKAGES_DIR}/share/antlr3" + TYPE FILE + FILES ${COMPLETE_JAR} ${RUNTIME_JAR} +) + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") diff --git a/vcpkg_overlays/antlr3/vcpkg.json b/vcpkg_overlays/antlr3/vcpkg.json new file mode 100644 index 00000000000..ad6c11862a6 --- /dev/null +++ b/vcpkg_overlays/antlr3/vcpkg.json @@ -0,0 +1,10 @@ +{ + "name": "antlr3", + "version": "3.4", + "port-version": 0, + "description": "ANother Tool for Language Recognition", + "homepage": "https://www.antlr.org", + "license": "BSD-3-Clause", + "supports": "!uwp", + "dependencies": [] +} \ No newline at end of file