Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[antlr4] Update antlr4 to v4.11.1 #27720

Merged
merged 10 commits into from
Nov 16, 2022
50 changes: 0 additions & 50 deletions ports/antlr4/fix_LNK2001.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index baf46ca..80fa49a 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -23,10 +23,13 @@ file(GLOB libantlrcpp_SRC
diff --git a/runtime/Cpp/runtime/CMakeLists.txt b/runtime/Cpp/runtime/CMakeLists.txt
index a4e4d1c..19cc21c 100644
--- a/runtime/Cpp/runtime/CMakeLists.txt
+++ b/runtime/Cpp/runtime/CMakeLists.txt
@@ -25,15 +25,21 @@ file(GLOB libantlrcpp_SRC
"${PROJECT_SOURCE_DIR}/runtime/src/tree/xpath/*.cpp"
)

Expand All @@ -12,33 +12,22 @@ index baf46ca..80fa49a 100644
add_library(antlr4_static STATIC ${libantlrcpp_SRC})
+endif()

-set(LIB_OUTPUT_DIR "${CMAKE_HOME_DIRECTORY}/dist") # put generated libraries here.
+#set(LIB_OUTPUT_DIR "${CMAKE_HOME_DIRECTORY}/dist") # put generated libraries here.
message(STATUS "Output libraries to ${LIB_OUTPUT_DIR}")

# make sure 'make' works fine even if ${LIB_OUTPUT_DIR} is deleted.
@@ -34,8 +37,11 @@ add_custom_target(make_lib_output_dir ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIB_OUTPUT_DIR}
)

# Make sure to link against threads (pthreads) library in order to be able to
# make use of std::call_once in the code without producing runtime errors
# (see also https://github.com/antlr/antlr4/issues/3708 and/or https://stackoverflow.com/q/51584960).
find_package(Threads REQUIRED)
+if(BUILD_SHARED_LIBS)
add_dependencies(antlr4_shared make_lib_output_dir)
target_link_libraries(antlr4_shared Threads::Threads)
+else()
add_dependencies(antlr4_static make_lib_output_dir)
target_link_libraries(antlr4_static Threads::Threads)
+endif()

if (ANTLR_BUILD_CPP_TESTS)
include(FetchContent)
@@ -70,11 +76,17 @@ if (ANTLR_BUILD_CPP_TESTS)
@@ -70,8 +76,11 @@ if (ANTLR_BUILD_CPP_TESTS)
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ if(BUILD_SHARED_LIBS)
target_link_libraries(antlr4_shared ${UUID_LIBRARIES})
+ else()
target_link_libraries(antlr4_static ${UUID_LIBRARIES})
+ endif()
elseif(APPLE)
if(APPLE)
+ if(BUILD_SHARED_LIBS)
target_link_libraries(antlr4_shared ${COREFOUNDATION_LIBRARY})
+ else()
Expand All @@ -47,51 +36,58 @@ index baf46ca..80fa49a 100644
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
@@ -96,7 +108,7 @@ if(WIN32)
set(extra_share_compile_flags "-DANTLR4CPP_EXPORTS")
set(extra_static_compile_flags "-DANTLR4CPP_STATIC")
endif(WIN32)
-if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+if(0)
if(WITH_STATIC_CRT)
target_compile_options(antlr4_shared PRIVATE "/MT$<$<CONFIG:Debug>:d>")
target_compile_options(antlr4_static PRIVATE "/MT$<$<CONFIG:Debug>:d>")
@@ -116,6 +128,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(extra_static_compile_flags "-DANTLR4CPP_STATIC -MP")
@@ -93,26 +102,32 @@ set(static_lib_suffix "")

if (WIN32)
set(static_lib_suffix "-static")
+ if(BUILD_SHARED_LIBS)
target_compile_definitions(antlr4_shared PUBLIC ANTLR4CPP_EXPORTS)
+ else()
target_compile_definitions(antlr4_static PUBLIC ANTLR4CPP_STATIC)
+ endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(extra_share_compile_flags "-MP /wd4251")
set(extra_static_compile_flags "-MP")
endif()
endif()

+if(BUILD_SHARED_LIBS)
set_target_properties(antlr4_shared
PROPERTIES VERSION ${ANTLR_VERSION}
SOVERSION ${ANTLR_VERSION}
@@ -126,25 +139,27 @@ set_target_properties(antlr4_shared
RUNTIME_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
OUTPUT_NAME antlr4-runtime
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_share_compile_flags}")
-
+else()
set_target_properties(antlr4_static
PROPERTIES VERSION ${ANTLR_VERSION}
SOVERSION ${ANTLR_VERSION}
OUTPUT_NAME "antlr4-runtime${static_lib_suffix}"
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
COMPILE_PDB_NAME "antlr4-runtime${static_lib_suffix}"
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_static_compile_flags}")
-
+endif()

if (ANTLR_BUILD_CPP_TESTS)
# Copy the generated binaries to dist folder (required by test suite)
@@ -130,18 +145,21 @@ if (ANTLR_BUILD_CPP_TESTS)
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:antlr4_static> ${CMAKE_HOME_DIRECTORY}/dist)
endif()

+if(BUILD_SHARED_LIBS)
install(TARGETS antlr4_shared
EXPORT antlr4-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-
+else()
install(TARGETS antlr4_static
EXPORT antlr4-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+endif()

+endif()
install(DIRECTORY "${PROJECT_SOURCE_DIR}/runtime/src/"
DESTINATION "include/antlr4-runtime"
COMPONENT dev
42 changes: 17 additions & 25 deletions ports/antlr4/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
set(VERSION 4.10.1)
vcpkg_minimum_required(VERSION 2022-10-12)

vcpkg_download_distfile(ARCHIVE
URLS "https://www.antlr.org/download/antlr4-cpp-runtime-${VERSION}-source.zip"
FILENAME "antlr4-cpp-runtime-${VERSION}-source.zip"
SHA512 f4926987946d17bf51b2d8a31ac06cf16eea7fb49ce535abb2d4759c9e6113d173c4504ffe4c8d2f9a58d845507dfdedaaba3dde70cc09c03c6bd6a2afe892a6
)

# license not exist in antlr folder.
vcpkg_download_distfile(LICENSE
URLS https://raw.githubusercontent.com/antlr/antlr4/${VERSION}/LICENSE.txt
FILENAME "antlr4-copyright-${VERSION}"
SHA512 1e8414de5fdc211e3188a8ec3276c6b3c55235f5edaf48522045ae18fa79fd9049719cb8924d25145016f223ac9a178defada1eeb983ccff598a08b0c0f67a3b
)

vcpkg_extract_source_archive_ex(
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
NO_REMOVE_ONE_LEVEL
REF ${VERSION}
REPO antlr/antlr4
HEAD_REF master
REF "v${VERSION}"
SHA512 a52356410c95ec6d7128b856dcf4c20a17cdd041270d2c4d700ef02ea715c87a00a87c2ad560277424b300435c6e9b196c8bc9c9f50ae5b6804d8214b4d397d0
PATCHES
fixed_build.patch
uuid_discovery_fix.patch
fix_LNK2001.patch #The related upstream issue https://github.com/antlr/antlr4/issues/3674
fix_build_4.11.1.patch
)

set(RUNTIME_PATH "${SOURCE_PATH}/runtime/Cpp")

message(INFO "Configure at '${RUNTIME_PATH}'")

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
SOURCE_PATH "${RUNTIME_PATH}"
OPTIONS
-DANTLR4_INSTALL=ON
-DANTLR_BUILD_CPP_TESTS=OFF
OPTIONS_DEBUG -DLIB_OUTPUT_DIR=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/dist
OPTIONS_RELEASE -DLIB_OUTPUT_DIR=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/dist
OPTIONS_DEBUG
"-DLIB_OUTPUT_DIR=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/dist"
OPTIONS_RELEASE
"-DLIB_OUTPUT_DIR=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/dist"
)

vcpkg_cmake_install()
Expand All @@ -41,4 +33,4 @@ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_

vcpkg_copy_pdbs()

file(INSTALL "${LICENSE}" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
16 changes: 0 additions & 16 deletions ports/antlr4/uuid_discovery_fix.patch

This file was deleted.

2 changes: 1 addition & 1 deletion ports/antlr4/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "antlr4",
"version": "4.10.1",
"version": "4.11.1",
"description": "ANother Tool for Language Recognition",
"homepage": "https://www.antlr.org",
"license": "BSD-3-Clause",
Expand Down
5 changes: 5 additions & 0 deletions versions/a-/antlr4.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "adff4448fb67cdc7d7a478d5f5f3e973ad65a386",
"version": "4.11.1",
"port-version": 0
},
{
"git-tree": "77ce1d5e7b1ea96943b3917086e1b75d50ae903c",
"version": "4.10.1",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"port-version": 6
},
"antlr4": {
"baseline": "4.10.1",
"baseline": "4.11.1",
"port-version": 0
},
"any-lite": {
Expand Down