mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 18:31:15 +08:00
[antlr4] Support build on Linux and MacOS (#5606)
* Patch VS project file with CRT linkage * [antlr4] Support build on Linux and MacOS
This commit is contained in:
parent
45fadafed0
commit
a14e462ef9
@ -1,3 +1,4 @@
|
||||
Source: antlr4
|
||||
Version: 4.7.1-2
|
||||
Description: ANother Tool for Language Recognition
|
||||
Version: 4.7.1-3
|
||||
Description: ANother Tool for Language Recognition
|
||||
Build-Depends: libuuid (!uwp&!windows&!osx)
|
@ -1,36 +0,0 @@
|
||||
diff --git a/runtime/antlr4cpp-vs2015.vcxproj b/runtime/antlr4cpp-vs2015.vcxproj
|
||||
index 85fa3da..540f031 100644
|
||||
--- a/runtime/antlr4cpp-vs2015.vcxproj
|
||||
+++ b/runtime/antlr4cpp-vs2015.vcxproj
|
||||
@@ -201,6 +201,7 @@
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -239,6 +240,7 @@
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -281,6 +283,7 @@
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -325,6 +328,7 @@
|
||||
</ForcedIncludeFiles>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
22
ports/antlr4/export_guid.patch
Normal file
22
ports/antlr4/export_guid.patch
Normal file
@ -0,0 +1,22 @@
|
||||
diff -urN c/runtime/src/support/guid.h d/runtime/src/support/guid.h
|
||||
--- c/runtime/src/support/guid.h 2017-07-01 09:51:22.000000000 +0800
|
||||
+++ d/runtime/src/support/guid.h 2018-09-05 10:16:23.847717700 +0800
|
||||
@@ -38,7 +38,7 @@
|
||||
// 16 byte value that can be passed around by value. It also supports
|
||||
// conversion to string (via the stream operator <<) and conversion from a
|
||||
// string via constructor.
|
||||
-class Guid
|
||||
+class ANTLR4CPP_PUBLIC Guid
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
// function would no longer be cross-platform if we parameterized the android
|
||||
// version. Instead, construction of the GuidGenerator may be different on
|
||||
// each platform, but the use of newGuid is uniform.
|
||||
-class GuidGenerator
|
||||
+class ANTLR4CPP_PUBLIC GuidGenerator
|
||||
{
|
||||
public:
|
||||
#ifdef GUID_ANDROID
|
||||
|
28
ports/antlr4/fixed_build.patch
Normal file
28
ports/antlr4/fixed_build.patch
Normal file
@ -0,0 +1,28 @@
|
||||
diff -urN a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
|
||||
--- a/runtime/CMakeLists.txt 2017-11-29 09:51:54.000000000 +0800
|
||||
+++ b/runtime/CMakeLists.txt 2018-08-30 19:06:03.718401800 +0800
|
||||
@@ -25,7 +25,7 @@
|
||||
add_library(antlr4_shared SHARED ${libantlrcpp_SRC})
|
||||
add_library(antlr4_static STATIC ${libantlrcpp_SRC})
|
||||
|
||||
-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.
|
||||
@@ -63,10 +63,10 @@
|
||||
set(extra_share_compile_flags "-DANTLR4CPP_EXPORTS")
|
||||
set(extra_static_compile_flags "-DANTLR4CPP_STATIC")
|
||||
endif(WIN32)
|
||||
-if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
- target_compile_options(antlr4_shared PRIVATE "/MD$<$<CONFIG:Debug>:d>")
|
||||
- target_compile_options(antlr4_static PRIVATE "/MT$<$<CONFIG:Debug>:d>")
|
||||
-endif()
|
||||
+# if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
+# target_compile_options(antlr4_shared PRIVATE "/MD$<$<CONFIG:Debug>:d>")
|
||||
+# target_compile_options(antlr4_static PRIVATE "/MT$<$<CONFIG:Debug>:d>")
|
||||
+# endif()
|
||||
|
||||
set(static_lib_suffix "")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
|
104
ports/antlr4/portfile.cmake
Normal file → Executable file
104
ports/antlr4/portfile.cmake
Normal file → Executable file
@ -7,7 +7,7 @@ include(vcpkg_common_functions)
|
||||
set(VERSION 4.7.1)
|
||||
|
||||
vcpkg_download_distfile(ARCHIVE
|
||||
URLS "http://www.antlr.org/download/antlr4-cpp-runtime-4.7.1-source.zip"
|
||||
URLS "http://www.antlr.org/download/antlr4-cpp-runtime-${VERSION}-source.zip"
|
||||
FILENAME "antlr4-cpp-runtime-${VERSION}-source.zip"
|
||||
SHA512 24d53278db56b199e6787242f22339f74e07d2cd3ed56f851ad905b110c2ba3cb001e1e2fcbc8624f0e93e00ba1fe1b23630dd1a736558c694655aeb1c3129da
|
||||
)
|
||||
@ -15,7 +15,7 @@ vcpkg_download_distfile(ARCHIVE
|
||||
# license not exist in antlr folder.
|
||||
vcpkg_download_distfile(LICENSE
|
||||
URLS https://raw.githubusercontent.com/antlr/antlr4/${VERSION}/LICENSE.txt
|
||||
FILENAME "antlr4-copyright_${VERSION}"
|
||||
FILENAME "antlr4-copyright-${VERSION}"
|
||||
SHA512 1e8414de5fdc211e3188a8ec3276c6b3c55235f5edaf48522045ae18fa79fd9049719cb8924d25145016f223ac9a178defada1eeb983ccff598a08b0c0f67a3b
|
||||
)
|
||||
|
||||
@ -23,59 +23,71 @@ vcpkg_extract_source_archive_ex(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
ARCHIVE ${ARCHIVE}
|
||||
NO_REMOVE_ONE_LEVEL
|
||||
PATCHES ${CMAKE_CURRENT_LIST_DIR}/crt_mt.patch
|
||||
REF ${VERSION}
|
||||
PATCHES fixed_build.patch
|
||||
uuid_discovery_fix.patch
|
||||
export_guid.patch
|
||||
)
|
||||
|
||||
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||
set(DEBUG_CONFIG "Debug Static")
|
||||
set(RELEASE_CONFIG "Release Static")
|
||||
else()
|
||||
set(DEBUG_CONFIG "Debug DLL")
|
||||
set(RELEASE_CONFIG "Release DLL")
|
||||
endif()
|
||||
|
||||
vcpkg_build_msbuild(
|
||||
PROJECT_PATH ${SOURCE_PATH}/runtime/antlr4cpp-vs2015.vcxproj
|
||||
DEBUG_CONFIGURATION ${DEBUG_CONFIG}
|
||||
RELEASE_CONFIGURATION ${RELEASE_CONFIG}
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS_DEBUG -DLIB_OUTPUT_DIR=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/dist
|
||||
OPTIONS_RELEASE -DLIB_OUTPUT_DIR=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/dist
|
||||
)
|
||||
|
||||
file (MAKE_DIRECTORY
|
||||
${CURRENT_PACKAGES_DIR}/include)
|
||||
FILE(COPY ${SOURCE_PATH}/runtime/src/
|
||||
DESTINATION ${CURRENT_PACKAGES_DIR}/include
|
||||
FILES_MATCHING PATTERN "*.h")
|
||||
vcpkg_install_cmake()
|
||||
|
||||
file (MAKE_DIRECTORY
|
||||
${CURRENT_PACKAGES_DIR}/lib
|
||||
${CURRENT_PACKAGES_DIR}/debug/lib)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/share/doc
|
||||
${CURRENT_PACKAGES_DIR}/debug/share
|
||||
${CURRENT_PACKAGES_DIR}/debug/include
|
||||
)
|
||||
|
||||
file(COPY ${SOURCE_PATH}/runtime/bin/vs-2015/${TRIPLET_SYSTEM_ARCH}/${DEBUG_CONFIG}/antlr4-runtime.lib
|
||||
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
|
||||
file(COPY ${SOURCE_PATH}/runtime/bin/vs-2015/${TRIPLET_SYSTEM_ARCH}/${RELEASE_CONFIG}/antlr4-runtime.lib
|
||||
DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
|
||||
if (NOT VCPKG_CMAKE_SYSTEM_NAME)
|
||||
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
|
||||
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime-static.lib
|
||||
${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime-static.lib
|
||||
)
|
||||
|
||||
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||
vcpkg_apply_patches(
|
||||
SOURCE_PATH ${CURRENT_PACKAGES_DIR}/include
|
||||
PATCHES ${CMAKE_CURRENT_LIST_DIR}/static.patch
|
||||
)
|
||||
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime.dll ${CURRENT_PACKAGES_DIR}/bin/antlr4-runtime.dll)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime.dll ${CURRENT_PACKAGES_DIR}/debug/bin/antlr4-runtime.dll)
|
||||
else()
|
||||
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime.lib
|
||||
${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime.dll
|
||||
${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime.lib
|
||||
${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime.dll
|
||||
)
|
||||
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime-static.lib ${CURRENT_PACKAGES_DIR}/lib/antlr4-runtime.lib)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime-static.lib ${CURRENT_PACKAGES_DIR}/debug/lib/antlr4-runtime.lib)
|
||||
endif()
|
||||
else()
|
||||
file (MAKE_DIRECTORY
|
||||
${CURRENT_PACKAGES_DIR}/bin
|
||||
${CURRENT_PACKAGES_DIR}/debug/bin)
|
||||
|
||||
file(COPY
|
||||
${SOURCE_PATH}/runtime/bin/vs-2015/${TRIPLET_SYSTEM_ARCH}/${DEBUG_CONFIG}/antlr4-runtime.dll
|
||||
${SOURCE_PATH}/runtime/bin/vs-2015/${TRIPLET_SYSTEM_ARCH}/${DEBUG_CONFIG}/antlr4-runtime.pdb
|
||||
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
|
||||
file(COPY
|
||||
${SOURCE_PATH}/runtime/bin/vs-2015/${TRIPLET_SYSTEM_ARCH}/${RELEASE_CONFIG}/antlr4-runtime.dll
|
||||
${SOURCE_PATH}/runtime/bin/vs-2015/${TRIPLET_SYSTEM_ARCH}/${RELEASE_CONFIG}/antlr4-runtime.pdb
|
||||
DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
|
||||
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
|
||||
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/libantlr4-runtime.a
|
||||
${CURRENT_PACKAGES_DIR}/debug/lib/libantlr4-runtime.a
|
||||
)
|
||||
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/libantlr4-runtime.so
|
||||
${CURRENT_PACKAGES_DIR}/lib/libantlr4-runtime.so.${VERSION}
|
||||
${CURRENT_PACKAGES_DIR}/debug/lib/libantlr4-runtime.so
|
||||
${CURRENT_PACKAGES_DIR}/debug/lib/libantlr4-runtime.so.${VERSION}
|
||||
)
|
||||
else()
|
||||
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/libantlr4-runtime.dylib
|
||||
${CURRENT_PACKAGES_DIR}/lib/libantlr4-runtime.${VERSION}.dylib
|
||||
${CURRENT_PACKAGES_DIR}/debug/lib/libantlr4-runtime.dylib
|
||||
${CURRENT_PACKAGES_DIR}/debug/lib/libantlr4-runtime.${VERSION}.dylib
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(GLOB HDRS LIST_DIRECTORIES true ${CURRENT_PACKAGES_DIR}/include/antlr4-runtime/*)
|
||||
file(COPY ${HDRS} DESTINATION ${CURRENT_PACKAGES_DIR}/include)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/antlr4-runtime)
|
||||
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
file(INSTALL ${LICENSE} DESTINATION ${CURRENT_PACKAGES_DIR}/share/antlr4 RENAME copyright)
|
||||
|
||||
message(STATUS "Installing done")
|
||||
#
|
||||
message(STATUS "Installing done")
|
@ -1,12 +0,0 @@
|
||||
diff --git a/antlr4-common.h b/antlr4-common.h
|
||||
index ce45e9e..3162795 100644
|
||||
--- a/antlr4-common.h
|
||||
+++ b/antlr4-common.h
|
||||
@@ -48,6 +48,7 @@
|
||||
#endif
|
||||
|
||||
#define GUID_WINDOWS
|
||||
+ #define ANTLR4CPP_STATIC
|
||||
|
||||
#ifdef _WIN64
|
||||
typedef __int64 ssize_t;
|
53
ports/antlr4/uuid_discovery_fix.patch
Normal file
53
ports/antlr4/uuid_discovery_fix.patch
Normal file
@ -0,0 +1,53 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index f4940c0..978b6ea 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -38,8 +38,10 @@ if(CMAKE_VERSION VERSION_EQUAL "3.3.0" OR
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
- find_package(PkgConfig REQUIRED)
|
||||
- pkg_check_modules(UUID REQUIRED uuid)
|
||||
+ find_path(UUID_INCLUDE_DIR uuid/uuid.h)
|
||||
+ find_library(UUID_LIBRARY NAMES uuid)
|
||||
+ include_directories(${UUID_INCLUDE_DIR})
|
||||
+ link_libraries(${UUID_LIBRARY})
|
||||
endif()
|
||||
if(APPLE)
|
||||
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
|
||||
@@ -115,7 +117,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_SYSTEM_NAME MATCHES
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
elseif ( MSVC_VERSION GREATER 1800 OR MSVC_VERSION EQUAL 1800 )
|
||||
- # Visual Studio 2012+ supports c++11 features
|
||||
+ # Visual Studio 2012+ supports c++11 features
|
||||
else ()
|
||||
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
|
||||
endif ()
|
||||
@@ -129,10 +131,10 @@ endif(WITH_DEMO)
|
||||
if( EXISTS LICENSE.txt)
|
||||
install(FILES LICENSE.txt
|
||||
DESTINATION "share/doc/libantlr4")
|
||||
-elseif(EXISTS ../../LICENSE.txt)
|
||||
+elseif(EXISTS ../../LICENSE.txt)
|
||||
install(FILES ../../LICENSE.txt
|
||||
DESTINATION "share/doc/libantlr4")
|
||||
endif()
|
||||
|
||||
-install(FILES README.md VERSION
|
||||
+install(FILES README.md VERSION
|
||||
DESTINATION "share/doc/libantlr4")
|
||||
diff --git a/runtime/src/support/guid.cpp b/runtime/src/support/guid.cpp
|
||||
index b6105d7..5baadb0 100644
|
||||
--- a/runtime/src/support/guid.cpp
|
||||
+++ b/runtime/src/support/guid.cpp
|
||||
@@ -21,7 +21,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
-
|
||||
+#include "antlr4-common.h"
|
||||
#include "guid.h"
|
||||
|
||||
#ifdef GUID_LIBUUID
|
||||
|
Loading…
x
Reference in New Issue
Block a user