From 0c1b57592b54a5959262bcec0e9a6b19c5751ced Mon Sep 17 00:00:00 2001 From: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> Date: Thu, 10 Jun 2021 06:28:21 +0800 Subject: [PATCH] [hunspell] Fix build error on Windows (#18037) * [hunspell] Fix build error on Windows * Update ports/hunspell/portfile.cmake * re-factory win build * Drop support with UWP since the upstream doesn't add app bitset in vcxproj * update baseline * Update port-version * Update version files * Update version-string field as version * Re update versions/h-/hunspell.json Co-authored-by: JackBoosY --- ports/hunspell/0002-disable-test.patch | 36 ++++++++++ ports/hunspell/0003-fix-win-build.patch | 80 +++++++++++++++++++++ ports/hunspell/portfile.cmake | 94 ++++++++++++++++++------- ports/hunspell/vcpkg.json | 5 +- scripts/ci.baseline.txt | 1 + versions/baseline.json | 2 +- versions/h-/hunspell.json | 5 ++ 7 files changed, 194 insertions(+), 29 deletions(-) create mode 100644 ports/hunspell/0002-disable-test.patch create mode 100644 ports/hunspell/0003-fix-win-build.patch diff --git a/ports/hunspell/0002-disable-test.patch b/ports/hunspell/0002-disable-test.patch new file mode 100644 index 0000000000..e475cba85f --- /dev/null +++ b/ports/hunspell/0002-disable-test.patch @@ -0,0 +1,36 @@ +diff --git a/msvc/Hunspell.sln b/msvc/Hunspell.sln +index 5607c8d..dabd755 100644 +--- a/msvc/Hunspell.sln ++++ b/msvc/Hunspell.sln +@@ -5,8 +5,6 @@ VisualStudioVersion = 14.0.25420.1 + MinimumVisualStudioVersion = 10.0.40219.1 + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhunspell", "libhunspell.vcxproj", "{53609BB3-D874-465C-AF7B-DF626DB0D89B}" + EndProject +-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testparser", "testparser.vcxproj", "{611BF6C7-332A-49BB-B2A3-80AFD5B785D9}" +-EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hunspell", "hunspell.vcxproj", "{6A0453F4-B12A-4810-B9A2-8AB059316ED7}" + EndProject + Global +@@ -37,22 +35,6 @@ Global + {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Release|Win32.Build.0 = Release|Win32 + {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Release|x64.ActiveCfg = Release|x64 + {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Release|x64.Build.0 = Release|x64 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Debug_dll|Win32.ActiveCfg = Debug|Win32 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Debug_dll|Win32.Build.0 = Debug|Win32 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Debug_dll|x64.ActiveCfg = Debug|x64 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Debug_dll|x64.Build.0 = Debug|x64 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Debug|Win32.ActiveCfg = Debug|Win32 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Debug|Win32.Build.0 = Debug|Win32 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Debug|x64.ActiveCfg = Debug|x64 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Debug|x64.Build.0 = Debug|x64 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Release_dll|Win32.ActiveCfg = Release|Win32 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Release_dll|Win32.Build.0 = Release|Win32 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Release_dll|x64.ActiveCfg = Release|x64 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Release_dll|x64.Build.0 = Release|x64 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Release|Win32.ActiveCfg = Release|Win32 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Release|Win32.Build.0 = Release|Win32 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Release|x64.ActiveCfg = Release|x64 +- {611BF6C7-332A-49BB-B2A3-80AFD5B785D9}.Release|x64.Build.0 = Release|x64 + {6A0453F4-B12A-4810-B9A2-8AB059316ED7}.Debug_dll|Win32.ActiveCfg = Debug|Win32 + {6A0453F4-B12A-4810-B9A2-8AB059316ED7}.Debug_dll|Win32.Build.0 = Debug|Win32 + {6A0453F4-B12A-4810-B9A2-8AB059316ED7}.Debug_dll|x64.ActiveCfg = Debug|x64 diff --git a/ports/hunspell/0003-fix-win-build.patch b/ports/hunspell/0003-fix-win-build.patch new file mode 100644 index 0000000000..a8fe442db8 --- /dev/null +++ b/ports/hunspell/0003-fix-win-build.patch @@ -0,0 +1,80 @@ +diff --git a/msvc/hunspell.vcxproj b/msvc/hunspell.vcxproj +index ca39388..d4817a5 100644 +--- a/msvc/hunspell.vcxproj ++++ b/msvc/hunspell.vcxproj +@@ -91,7 +91,7 @@ + W32;WIN32;_DEBUG;_CONSOLE;HUNSPELL_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks +- MultiThreadedDebugDLL ++ MultiThreadedDebug + + $(IntDir)$(ProjectName).pdb + Level4 +@@ -112,7 +112,7 @@ + ..\src\hunspell;..\src\parsers;.;%(AdditionalIncludeDirectories) + W32;WIN32;_DEBUG;_CONSOLE;HUNSPELL_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EnableFastChecks +- MultiThreadedDebugDLL ++ MultiThreadedDebug + + + Level4 +@@ -134,7 +134,7 @@ + AnySuitable + ..\src\hunspell;..\src\parsers;.;%(AdditionalIncludeDirectories) + W32;WIN32;NDEBUG;_CONSOLE;HUNSPELL_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) +- MultiThreadedDLL ++ MultiThreaded + + $(IntDir)$(ProjectName).pdb + Level4 +@@ -157,7 +157,7 @@ + AnySuitable + ..\src\hunspell;..\src\parsers;.;%(AdditionalIncludeDirectories) + W32;WIN32;NDEBUG;_CONSOLE;HUNSPELL_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) +- MultiThreadedDLL ++ MultiThreaded + + + $(IntDir)$(ProjectName).pdb +diff --git a/msvc/libhunspell.vcxproj b/msvc/libhunspell.vcxproj +index a0772da..9a875ca 100644 +--- a/msvc/libhunspell.vcxproj ++++ b/msvc/libhunspell.vcxproj +@@ -166,7 +166,7 @@ + WIN32;_DEBUG;_WINDOWS;_USRDLL;HUNSPELL_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + false + EnableFastChecks +- MultiThreadedDebugDLL ++ MultiThreadedDebug + + $(IntDir)$(ProjectName).pdb + Level4 +@@ -187,7 +187,7 @@ + WIN32;_DEBUG;_WINDOWS;_USRDLL;HUNSPELL_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + false + EnableFastChecks +- MultiThreadedDebugDLL ++ MultiThreadedDebug + + + Level4 +@@ -206,7 +206,7 @@ + ..\src\hunspell;.;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;HUNSPELL_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true +- MultiThreadedDLL ++ MultiThreaded + true + + $(IntDir)$(ProjectName).pdb +@@ -232,7 +232,7 @@ + ..\src\hunspell;.;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;HUNSPELL_STATIC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true +- MultiThreadedDLL ++ MultiThreaded + true + + diff --git a/ports/hunspell/portfile.cmake b/ports/hunspell/portfile.cmake index 071a52ad2d..bf48b9c2ea 100644 --- a/ports/hunspell/portfile.cmake +++ b/ports/hunspell/portfile.cmake @@ -1,43 +1,85 @@ +vcpkg_fail_port_install(ON_TARGET "UWP") + vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO hunspell/hunspell REF v1.7.0 SHA512 8149b2e8b703a0610c9ca5160c2dfad3cf3b85b16b3f0f5cfcb7ebb802473b2d499e8e2d0a637a97a37a24d62424e82d3880809210d3f043fa17a4970d47c903 HEAD_REF master - PATCHES 0001_fix_unistd.patch + PATCHES + 0001_fix_unistd.patch + 0002-disable-test.patch + 0003-fix-win-build.patch ) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - tools BUILD_TOOLS + FEATURES + tools BUILD_TOOLS ) -if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - set(ENV{CFLAGS} "$ENV{CFLAGS} -DHUNSPELL_STATIC") - set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} -DHUNSPELL_STATIC") +if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + file(REMOVE "${SOURCE_PATH}/README") #README is a symlink + + #architecture detection + if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + set(HUNSPELL_ARCH Win32) + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + set(HUNSPELL_ARCH x64) + else() + message(FATAL_ERROR "unsupported architecture") + endif() + + if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + set(HUNSPELL_CONFIGURATION _dll) + else() + set(HUNSPELL_CONFIGURATION ) + endif() + + if("tools" IN_LIST FEATURES) + set(HSP_TARGET hunspell) + else() + set(HSP_TARGET libhunspell) + endif() + + vcpkg_install_msbuild( + SOURCE_PATH "${SOURCE_PATH}" + PROJECT_SUBPATH "msvc/Hunspell.sln" + INCLUDES_SUBPATH src/hunspell + PLATFORM ${HUNSPELL_ARCH} + RELEASE_CONFIGURATION Release${HUNSPELL_CONFIGURATION} + DEBUG_CONFIGURATION Debug${HUNSPELL_CONFIGURATION} + ALLOW_ROOT_INCLUDES + ) +else() + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(ENV{CFLAGS} "$ENV{CFLAGS} -DHUNSPELL_STATIC") + set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} -DHUNSPELL_STATIC") + endif() + if(NOT "tools" IN_LIST FEATURES) # Building the tools is not possible on windows! + file(READ "${SOURCE_PATH}/src/Makefile.am" _contents) + string(REPLACE " parsers tools" "" _contents "${_contents}") + file(WRITE "${SOURCE_PATH}/src/Makefile.am" "${_contents}") + endif() + vcpkg_add_to_path("${CURRENT_HOST_INSTALLED_DIR}/tools/gettext/bin") + vcpkg_configure_make( + SOURCE_PATH ${SOURCE_PATH} + OPTIONS + AUTOCONFIG + ADDITIONAL_MSYS_PACKAGES gzip + ) + #install-pkgconfDATA: + vcpkg_build_make(BUILD_TARGET dist LOGFILE_ROOT build-dist) + vcpkg_install_make() + + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug") + vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin") + vcpkg_fixup_pkgconfig() endif() -if(NOT "tools" IN_LIST FEATURES) # Building the tools is not possible on windows! - file(READ "${SOURCE_PATH}/src/Makefile.am" _contents) - string(REPLACE " parsers tools" "" _contents "${_contents}") - file(WRITE "${SOURCE_PATH}/src/Makefile.am" "${_contents}") -endif() -vcpkg_add_to_path("${CURRENT_HOST_INSTALLED_DIR}/tools/gettext/bin") -vcpkg_configure_make( - SOURCE_PATH ${SOURCE_PATH} - OPTIONS - AUTOCONFIG - ADDITIONAL_MSYS_PACKAGES gzip -) -#install-pkgconfDATA: -vcpkg_build_make(BUILD_TARGET dist LOGFILE_ROOT build-dist) -vcpkg_install_make() vcpkg_copy_pdbs() -vcpkg_fixup_pkgconfig() file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug") -vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin") -file(INSTALL ${SOURCE_PATH}/COPYING.LESSER DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright-lgpl) -file(INSTALL ${SOURCE_PATH}/COPYING.MPL DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright-mpl) -file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) +file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +file(INSTALL "${SOURCE_PATH}/COPYING.LESSER" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright-lgpl) +file(INSTALL "${SOURCE_PATH}/COPYING.MPL" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright-mpl) diff --git a/ports/hunspell/vcpkg.json b/ports/hunspell/vcpkg.json index 112062df3c..372bac8dce 100644 --- a/ports/hunspell/vcpkg.json +++ b/ports/hunspell/vcpkg.json @@ -1,9 +1,10 @@ { "name": "hunspell", - "version-string": "1.7.0", - "port-version": 3, + "version": "1.7.0", + "port-version": 4, "description": "The most popular spellchecking library.", "homepage": "https://github.com/hunspell/hunspell", + "supports": "!((arm | uwp) & windows)", "dependencies": [ { "name": "gettext", diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index a342ca2170..37032c03e9 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -449,6 +449,7 @@ hiredis:arm-uwp=fail hiredis:x64-uwp=fail hpx:x64-windows-static=fail hpx:x64-linux=fail +hunspell:x64-windows-static-md=fail libhsplasma:x64-windows-static=fail ideviceinstaller:x64-windows-static-md=fail idevicerestore:x64-linux=fail diff --git a/versions/baseline.json b/versions/baseline.json index 3e9ee5e47d..7ecb3823c4 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -2514,7 +2514,7 @@ }, "hunspell": { "baseline": "1.7.0", - "port-version": 3 + "port-version": 4 }, "hwloc": { "baseline": "2.2.0", diff --git a/versions/h-/hunspell.json b/versions/h-/hunspell.json index b3f6e505ac..0c6d4ad37f 100644 --- a/versions/h-/hunspell.json +++ b/versions/h-/hunspell.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "1441675cd83b048c9fe45d9230ab99c06421b121", + "version": "1.7.0", + "port-version": 4 + }, { "git-tree": "b943abf7281879a8f3ab2c2c14ea5da7cf735dae", "version-string": "1.7.0",