Meta: Add an overlay port for ICU

This will allow us to upgrade to ICU 76 independent of upstream vcpkg.
This commit is contained in:
Timothy Flynn 2025-01-18 10:28:42 -05:00 committed by Tim Flynn
commit 96558b98f9
Notes: github-actions[bot] 2025-01-18 22:57:57 +00:00
13 changed files with 387 additions and 0 deletions

View file

@ -0,0 +1,14 @@
diff --git a/source/config/mh-darwin b/source/config/mh-darwin
index 7b15709..e2cdbdb 100644
--- a/source/config/mh-darwin
+++ b/source/config/mh-darwin
@@ -31,7 +31,8 @@ SHLIB.cc= $(CXX) -dynamiclib -dynamic $(CXXFLAGS) $(LDFLAGS) $(LD_SOOPTIONS)
## Compiler switches to embed a library name and version information
ifeq ($(ENABLE_RPATH),YES)
-LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(libdir)/$(notdir $(MIDDLE_SO_TARGET))
+ID_PREFIX = @rpath
+LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(ID_PREFIX)/$(notdir $(MIDDLE_SO_TARGET))
else
LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(notdir $(MIDDLE_SO_TARGET)) $(PKGDATA_TRAILING_SPACE)
endif

View file

@ -0,0 +1,17 @@
diff --git a/source/tools/Makefile.in b/source/tools/Makefile.in
index e0896f1..5ead980 100644
--- a/source/tools/Makefile.in
+++ b/source/tools/Makefile.in
@@ -19,9 +19,9 @@ SUBDIRS = toolutil ctestfw makeconv genrb genbrk \
gencnval gensprep icuinfo genccode gencmn icupkg pkgdata \
gentest gennorm2 gencfu gendict icuexportdata
-ifneq (@platform_make_fragment_name@,mh-cygwin-msvc)
-SUBDIRS += escapesrc
-endif
+#ifneq (@platform_make_fragment_name@,mh-cygwin-msvc)
+#SUBDIRS += escapesrc
+#endif
## List of phony targets
.PHONY : all all-local all-recursive install install-local \

View file

@ -0,0 +1,20 @@
diff --git a/source/icudefs.mk.in b/source/icudefs.mk.in
index 24bd97a..33169de 100644
--- a/source/icudefs.mk.in
+++ b/source/icudefs.mk.in
@@ -213,13 +213,13 @@ LIBICU = $(LIBPREFIX)$(ICUPREFIX)
## If we can't use the shared libraries, use the static libraries
ifneq ($(ENABLE_SHARED),YES)
-STATIC_PREFIX_WHEN_USED = s
+STATIC_PREFIX_WHEN_USED =
else
STATIC_PREFIX_WHEN_USED =
endif
# Static library prefix and file extension
-STATIC_PREFIX = s
+STATIC_PREFIX =
LIBSICU = $(LIBPREFIX)$(STATIC_PREFIX)$(ICUPREFIX)
A = a
SOBJ = $(SO)

View file

@ -0,0 +1,13 @@
diff --urN a/source/extra/Makefile.in b/source/extra/Makefile.in
--- a/source/extra/Makefile.in
+++ b/source/extra/Makefile.in
@@ -23,7 +23,7 @@
## Files to remove for 'make clean'
CLEANFILES = *~
-SUBDIRS = scrptrun uconv
+SUBDIRS = uconv
## List of phony targets
.PHONY : all all-local all-recursive install install-local \

View file

@ -0,0 +1,35 @@
diff --git a/source/configure.ac b/source/configure.ac
index 425fdc7..97210f8 100644
--- a/source/configure.ac
+++ b/source/configure.ac
@@ -114,6 +114,15 @@ AC_ARG_ENABLE([icu-config],
esac], [enable_icu_config=true])
AC_SUBST(INSTALL_ICU_CONFIG, [$enable_icu_config])
+AC_ARG_ENABLE([icu-build-win],
+ AS_HELP_STRING([--enable-icu-build-win], [install icu-build-win]),
+ [case "${enableval}" in
+ yes) enable_icu_build_win=true ;;
+ no) enable_icu_build_win=false ;;
+ *) AC_MSG_ERROR([bad value '${enableval}' for --enable-icu-build-win]) ;;
+ esac], [enable_icu_build_win=true])
+AC_SUBST(INSTALL_ICU_BUILD_WIN, [$enable_icu_build_win])
+
# Check whether to build debug libraries
AC_MSG_CHECKING([whether to build debug libraries])
enabled=no
@@ -263,12 +272,14 @@ ICU_CHECK_MH_FRAG
# Checks for libraries and other host specific stuff
# On HP/UX, don't link to -lm from a shared lib because it isn't
# PIC (at least on 10.2)
+if test "$enable_icu_build_win" = no; then
case "${host}" in
*-*-hpux*) AC_CHECK_LIB(m, floor, LIB_M="-lm") ;;
*) AC_CHECK_LIB(m, floor)
LIB_M="" ;;
esac
+fi
AC_SUBST(LIB_M)
# Check whether to build shared libraries

View file

@ -0,0 +1,25 @@
diff --urN a/source/data/Makefile.in b/source/data/Makefile.in
--- a/source/data/Makefile.in
+++ b/source/data/Makefile.in
@@ -236,11 +236,12 @@
## Include the main build rules for data files
include $(top_builddir)/$(subdir)/rules.mk
+PKGDATA_LIST = $(TMP_DIR)/icudata.lst
ifeq ($(ENABLE_SO_VERSION_DATA),1)
ifeq ($(PKGDATA_MODE),dll)
SO_VERSION_DATA = $(OUTTMPDIR)/icudata.res
-$(SO_VERSION_DATA) : $(MISCSRCDIR)/icudata.rc | $(TMP_DIR)/dirs.timestamp
+$(SO_VERSION_DATA) : $(MISCSRCDIR)/icudata.rc $(PKGDATA_LIST)
ifeq ($(MSYS_RC_MODE),1)
rc.exe -i$(srcdir)/../common -i$(top_builddir)/common -fo$@ $(CPPFLAGS) $<
else
@@ -249,7 +250,6 @@
endif
endif
-PKGDATA_LIST = $(TMP_DIR)/icudata.lst
#####################################################

View file

@ -0,0 +1,26 @@
diff --git a/source/config/mh-mingw b/source/config/mh-mingw
index 30f6e5be81..b6364551ea 100644
--- a/source/config/mh-mingw
+++ b/source/config/mh-mingw
@@ -13,7 +13,7 @@
# On Windows we generally have the DLLs in the bin directory rather than the lib directory.
# This setting moves the ICU DLLs into the bin folder for MinGW/MSYS2 when "make install" is run.
# If you prefer to have the DLLs in the lib folder, then set this to NO instead.
-MINGW_MOVEDLLSTOBINDIR = YES
+MINGW_MOVEDLLSTOBINDIR = NO
# We install sbin tools into the same bin directory because
# pkgdata needs some of the tools in sbin, and we can't always depend on
diff --git a/source/config/mh-mingw64 b/source/config/mh-mingw64
index fb64c56260..a43cc4dd71 100644
--- a/source/config/mh-mingw64
+++ b/source/config/mh-mingw64
@@ -10,7 +10,7 @@
# On Windows we generally have the DLLs in the bin directory rather than the lib directory.
# This setting moves the ICU DLLs into the bin folder for MinGW/MSYS2 when "make install" is run.
# If you prefer to have the DLLs in the lib folder, then set this to NO instead.
-MINGW_MOVEDLLSTOBINDIR = YES
+MINGW_MOVEDLLSTOBINDIR = NO
# This file is similar to mh-mingw
# Any changes made here may also need to be made in mh-mingw

View file

@ -0,0 +1,12 @@
diff --git a/source/common/putil.cpp b/source/common/putil.cpp
index ab25f3b..94782f8 100644
--- a/source/common/putil.cpp
+++ b/source/common/putil.cpp
@@ -48,7 +48,6 @@
#if U_PLATFORM == U_PF_MINGW && defined __STRICT_ANSI__
/* tzset isn't defined in strict ANSI on MinGW. */
-#undef __STRICT_ANSI__
#endif
/*

View file

@ -0,0 +1,163 @@
if(NOT VCPKG_TARGET_IS_WINDOWS)
message(WARNING "${PORT} currently requires the following programs from the system package manager:
autoconf automake autoconf-archive
On Debian and Ubuntu derivatives:
sudo apt-get install autoconf automake autoconf-archive
On recent Red Hat and Fedora derivatives:
sudo dnf install autoconf automake autoconf-archive
On Arch Linux and derivatives:
sudo pacman -S autoconf automake autoconf-archive
On Alpine:
apk add autoconf automake autoconf-archive
On macOS:
brew install autoconf automake autoconf-archive\n")
endif()
string(REGEX MATCH "^[0-9]*" ICU_VERSION_MAJOR "${VERSION}")
string(REPLACE "." "_" VERSION2 "${VERSION}")
string(REPLACE "." "-" VERSION3 "${VERSION}")
vcpkg_download_distfile(
ARCHIVE
URLS "https://github.com/unicode-org/icu/releases/download/release-${VERSION3}/icu4c-${VERSION2}-src.tgz"
FILENAME "icu4c-${VERSION2}-src.tgz"
SHA512 e6c7876c0f3d756f3a6969cad9a8909e535eeaac352f3a721338b9cbd56864bf7414469d29ec843462997815d2ca9d0dab06d38c37cdd4d8feb28ad04d8781b0
)
vcpkg_extract_source_archive(SOURCE_PATH
ARCHIVE "${ARCHIVE}"
PATCHES
disable-escapestr-tool.patch
remove-MD-from-configure.patch
fix_parallel_build_on_windows.patch
fix-extra.patch
mingw-dll-install.patch
disable-static-prefix.patch # https://gitlab.kitware.com/cmake/cmake/-/issues/16617; also mingw.
fix-win-build.patch
vcpkg-cross-data.patch
darwin-rpath.patch
mingw-strict-ansi.diff # backport of https://github.com/unicode-org/icu/pull/3003
)
vcpkg_find_acquire_program(PYTHON3)
set(ENV{PYTHON} "${PYTHON3}")
vcpkg_list(SET CONFIGURE_OPTIONS)
vcpkg_list(SET BUILD_OPTIONS)
if(VCPKG_TARGET_IS_EMSCRIPTEN)
vcpkg_list(APPEND CONFIGURE_OPTIONS --disable-extras)
vcpkg_list(APPEND BUILD_OPTIONS "PKGDATA_OPTS=--without-assembly -O ../data/icupkg.inc")
elseif(VCPKG_TARGET_IS_UWP)
vcpkg_list(APPEND CONFIGURE_OPTIONS --disable-extras ac_cv_func_tzset=no ac_cv_func__tzset=no)
string(APPEND VCPKG_C_FLAGS " -DU_PLATFORM_HAS_WINUWP_API=1")
string(APPEND VCPKG_CXX_FLAGS " -DU_PLATFORM_HAS_WINUWP_API=1")
vcpkg_list(APPEND BUILD_OPTIONS "PKGDATA_OPTS=--windows-uwp-build -O ../data/icupkg.inc")
elseif(VCPKG_TARGET_IS_OSX AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
vcpkg_list(APPEND CONFIGURE_OPTIONS --enable-rpath)
if(DEFINED CMAKE_INSTALL_NAME_DIR)
vcpkg_list(APPEND BUILD_OPTIONS "ID_PREFIX=${CMAKE_INSTALL_NAME_DIR}")
endif()
endif()
if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND CONFIGURE_OPTIONS --enable-icu-build-win)
endif()
if("tools" IN_LIST FEATURES)
list(APPEND CONFIGURE_OPTIONS --enable-tools)
else()
list(APPEND CONFIGURE_OPTIONS --disable-tools)
endif()
if(CMAKE_HOST_WIN32 AND VCPKG_TARGET_IS_MINGW AND NOT HOST_TRIPLET MATCHES "mingw")
# Assuming no cross compiling because the host (windows) pkgdata tool doesn't
# use the '/' path separator when creating compiler commands for mingw bash.
elseif(VCPKG_CROSSCOMPILING)
set(TOOL_PATH "${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT}")
# convert to unix path
string(REGEX REPLACE "^([a-zA-Z]):/" "/\\1/" _VCPKG_TOOL_PATH "${TOOL_PATH}")
list(APPEND CONFIGURE_OPTIONS "--with-cross-build=${_VCPKG_TOOL_PATH}")
endif()
vcpkg_configure_make(
SOURCE_PATH "${SOURCE_PATH}"
PROJECT_SUBPATH source
AUTOCONFIG
DETERMINE_BUILD_TRIPLET
ADDITIONAL_MSYS_PACKAGES autoconf-archive
OPTIONS
${CONFIGURE_OPTIONS}
--disable-samples
--disable-tests
--disable-layoutex
OPTIONS_RELEASE
--disable-debug
--enable-release
OPTIONS_DEBUG
--enable-debug
--disable-release
)
vcpkg_install_make(OPTIONS ${BUILD_OPTIONS})
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/share"
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/lib/icu"
"${CURRENT_PACKAGES_DIR}/debug/lib/icu"
"${CURRENT_PACKAGES_DIR}/debug/lib/icud")
file(GLOB TEST_LIBS
"${CURRENT_PACKAGES_DIR}/lib/*test*"
"${CURRENT_PACKAGES_DIR}/debug/lib/*test*")
if(TEST_LIBS)
file(REMOVE ${TEST_LIBS})
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
# force U_STATIC_IMPLEMENTATION macro
foreach(HEADER utypes.h utf_old.h platform.h)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/unicode/${HEADER}" "defined(U_STATIC_IMPLEMENTATION)" "1")
endforeach()
endif()
# Install executables from /tools/icu/sbin to /tools/icu/bin on unix (/bin because icu require this for cross compiling)
if(VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX AND "tools" IN_LIST FEATURES)
vcpkg_copy_tools(
TOOL_NAMES icupkg gennorm2 gencmn genccode gensprep
SEARCH_DIR "${CURRENT_PACKAGES_DIR}/tools/icu/sbin"
DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin"
)
endif()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/tools/icu/sbin"
"${CURRENT_PACKAGES_DIR}/tools/icu/debug")
# To cross compile, we need some files at specific positions. So lets copy them
file(GLOB CROSS_COMPILE_DEFS "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/config/icucross.*")
file(INSTALL ${CROSS_COMPILE_DEFS} DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/config")
file(GLOB RELEASE_DLLS "${CURRENT_PACKAGES_DIR}/lib/*icu*${ICU_VERSION_MAJOR}.dll")
file(COPY ${RELEASE_DLLS} DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin")
# copy dlls
file(GLOB RELEASE_DLLS "${CURRENT_PACKAGES_DIR}/lib/*icu*${ICU_VERSION_MAJOR}.dll")
file(COPY ${RELEASE_DLLS} DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
if(NOT VCPKG_BUILD_TYPE)
file(GLOB DEBUG_DLLS "${CURRENT_PACKAGES_DIR}/debug/lib/*icu*${ICU_VERSION_MAJOR}.dll")
file(COPY ${DEBUG_DLLS} DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
# remove any remaining dlls in /lib
file(GLOB DUMMY_DLLS "${CURRENT_PACKAGES_DIR}/lib/*.dll" "${CURRENT_PACKAGES_DIR}/debug/lib/*.dll")
if(DUMMY_DLLS)
file(REMOVE ${DUMMY_DLLS})
endif()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/icu/bin/icu-config" "${CURRENT_INSTALLED_DIR}" "`dirname $0`/../../../" IGNORE_UNCHANGED)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

View file

@ -0,0 +1,18 @@
diff -urN a/source/runConfigureICU b/source/runConfigureICU
--- a/source/runConfigureICU 2018-03-26 21:38:44.000000000 +0800
+++ b/source/runConfigureICU 2018-08-26 09:04:53.197454400 +0800
@@ -322,10 +322,10 @@
THE_COMP="Microsoft Visual C++"
CC=cl; export CC
CXX=cl; export CXX
- RELEASE_CFLAGS='-Gy -MD'
- RELEASE_CXXFLAGS='-Gy -MD'
- DEBUG_CFLAGS='-FS -Zi -MDd'
- DEBUG_CXXFLAGS='-FS -Zi -MDd'
+ RELEASE_CFLAGS='-Gy'
+ RELEASE_CXXFLAGS='-Gy'
+ DEBUG_CFLAGS='-FS -Zi'
+ DEBUG_CXXFLAGS='-FS -Zi'
DEBUG_LDFLAGS='-DEBUG'
;;
*BSD)

View file

@ -0,0 +1,8 @@
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW)
if(NOT "COMPONENTS" IN_LIST ARGS)
_find_package(${ARGS} COMPONENTS data)
else()
_find_package(${ARGS})
endif()
cmake_policy(POP)

View file

@ -0,0 +1,13 @@
diff --git a/source/configure.ac b/source/configure.ac
index 1bd5871..c508f48 100644
--- a/source/configure.ac
+++ b/source/configure.ac
@@ -1151,7 +1151,7 @@ AC_ARG_ENABLE(fuzzer,
fuzzer=false)
ICU_CONDITIONAL(FUZZER, test "$fuzzer" = true)
-ICU_CONDITIONAL(DATA, test "$tools" = true || test "$cross_compiling" = "yes")
+ICU_CONDITIONAL(DATA, test "$tools" = true || test "$cross_compiling" = "yes" || test -n "$cross_buildroot")
AC_ARG_WITH(data-packaging,
[ --with-data-packaging specify how to package ICU data. Possible values:

View file

@ -0,0 +1,23 @@
{
"name": "icu",
"version": "74.2",
"port-version": 4,
"description": "Mature and widely used Unicode and localization library.",
"homepage": "https://icu.unicode.org/home",
"license": "ICU",
"dependencies": [
{
"name": "icu",
"host": true,
"features": [
"tools"
]
}
],
"features": {
"tools": {
"description": "Build tools",
"supports": "!uwp"
}
}
}