Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

This file was deleted.

47 changes: 47 additions & 0 deletions ports/icu/patches/0004-Cross-compilation-support-for-pkgdata.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
diff --git a/source/tools/pkgdata/pkgdata.cpp b/source/tools/pkgdata/pkgdata.cpp
index 3e4cfd7..1516f7d 100644
--- a/source/tools/pkgdata/pkgdata.cpp
+++ b/source/tools/pkgdata/pkgdata.cpp
@@ -770,12 +770,27 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
/* Try to detect the arch type, use nullptr if unsuccessful */
char optMatchArch[10] = { 0 };
pkg_createOptMatchArch(optMatchArch);
+
+ /* Determine the CPU architecture string for writeObjectCode.
+ * First check ICU_DATA_CPU_ARCH env var (set during cross-
+ * compilation from a non-Windows host). Otherwise use _M_*
+ * macros which Clang sets for the target architecture. */
+ const char *optCpuArch = getenv("ICU_DATA_CPU_ARCH");
+ if (!optCpuArch) {
+#if defined(_M_AMD64)
+ optCpuArch = "x64";
+#elif defined(_M_ARM64)
+ optCpuArch = "arm64";
+#elif defined(_M_IX86)
+ optCpuArch = "x86";
+#endif
+ }
writeObjectCode(
datFileNamePath,
o->tmpDir,
o->entryName,
(optMatchArch[0] == 0 ? nullptr : optMatchArch),
- nullptr,
+ optCpuArch,
nullptr,
gencFilePath,
sizeof(gencFilePath),
@@ -1783,6 +1798,13 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD
static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, UPKGOptions *o) {
int32_t result = 0;
char cmd[LARGE_BUFFER_MAX_SIZE];
+
+ /* When cross-compiling from a non-Windows host, the CMake build system
+ * links the data library itself; skip the link/lib step here. */
+ const char *skipLink = getenv("ICU_SKIP_PKGDATA_LINK");
+ if (skipLink && skipLink[0] == '1')
+ return 0;
+
if (IN_STATIC_MODE(mode)) {
char staticLibFilePath[SMALL_BUFFER_MAX_SIZE] = "";

This file was deleted.

This file was deleted.

94 changes: 80 additions & 14 deletions ports/icu/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@ vcpkg_download_distfile(ARCHIVE

# Patches
set(PATCHES
# CMake files
# CMake build system (third-party LibCMaker)
${CMAKE_CURRENT_LIST_DIR}/patches/0001-Add-CMake-platform.patch
# Patch specifically for vcpkg on top of above
# vcpkg fixup: remove bin64/lib64 install suffix on Windows
${CMAKE_CURRENT_LIST_DIR}/patches/0002-Remove-install-suffix-on-Windows.patch
# Append CMAKE_EXECUTABLE_SUFFIX and CMAKE_CROSSCOMPILING_EMULATOR to tool paths for cross-compilation
${CMAKE_CURRENT_LIST_DIR}/patches/0003-Append-CMAKE_EXECUTABLE_SUFFIX-to-tool-paths.patch
# Copy stubdata DLL to bin/ during cross-compilation (not just native Windows)
${CMAKE_CURRENT_LIST_DIR}/patches/0004-Copy-stubdata-dll-to-bin-for-cross-compile.patch
# Pass optCpuArch to writeObjectCode to avoid nullptr dereference with clang
${CMAKE_CURRENT_LIST_DIR}/patches/0005-Pass-optCpuArch-from-pkgdata-to-writeObjectCode.patch
# Allow overriding link.exe/LIB.exe via env vars for cross-compilation
${CMAKE_CURRENT_LIST_DIR}/patches/0006-Skip-pkgdata-link-step-when-cross-compiling.patch
# Cross-compilation support for CMake build files
${CMAKE_CURRENT_LIST_DIR}/patches/0003-Support-cross-compilation-in-CMake-build.patch
# Cross-compilation support for pkgdata tool
${CMAKE_CURRENT_LIST_DIR}/patches/0004-Cross-compilation-support-for-pkgdata.patch
)

# Extract archive
Expand All @@ -45,6 +41,64 @@ set(BUILD_OPTIONS
-DICU_ENABLE_TESTS=OFF
)

# When cross-compiling from a non-Windows host (e.g. Linux -> Windows), build
# native host tools first, then use them for the cross-compile. This avoids
# needing Wine to run cross-compiled .exe tools.
if (VCPKG_CROSSCOMPILING AND NOT VCPKG_HOST_IS_WINDOWS AND NOT DEFINED ICU_CROSS_BUILD_ROOT)
message(STATUS "Building native ICU host tools for cross-compilation...")
set(HOST_BUILD_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-host")

# Use ICU's autotools build for the native host tools. The CMake build
# system (from patch 0001) has bugs that only manifest on native Linux
# (lowercase list(append), missing sources.txt for escapesrc), so autotools
# is more reliable here. The resulting bin/ layout is the same either way.
file(MAKE_DIRECTORY "${HOST_BUILD_DIR}")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E env --unset=CC --unset=CXX --unset=CFLAGS --unset=CXXFLAGS --unset=LDFLAGS
"${SOURCE_PATH}/source/configure"
--disable-shared --enable-static
--disable-extras --disable-icuio
--disable-layout --disable-layoutex
--disable-tests --disable-samples
WORKING_DIRECTORY "${HOST_BUILD_DIR}"
COMMAND_ERROR_IS_FATAL ANY
)
include(ProcessorCount)
ProcessorCount(NPROC)
if (NPROC EQUAL 0)
set(NPROC 1)
endif ()
execute_process(
COMMAND make -j${NPROC}
WORKING_DIRECTORY "${HOST_BUILD_DIR}"
COMMAND_ERROR_IS_FATAL ANY
)

set(ICU_CROSS_BUILD_ROOT "${HOST_BUILD_DIR}")

# The CMake cross-compile system expects config/icucross.cmake in the host
# build root (normally generated by a CMake host build). Since we used
# autotools, generate it manually. It just sets TOOLBINDIR and TOOLLIBDIR.
file(MAKE_DIRECTORY "${HOST_BUILD_DIR}/config")
file(WRITE "${HOST_BUILD_DIR}/config/icucross.cmake"
"set(CROSS_ICU_VERSION ${VERSION})\n"
"set(TOOLBINDIR \${ICU_CROSS_BUILDROOT}/bin)\n"
"set(TOOLLIBDIR \${ICU_CROSS_BUILDROOT}/lib)\n"
)

# Patch 0003 appends CMAKE_EXECUTABLE_SUFFIX (.exe) to tool paths in the
# data CMakeLists.txt. CMake's Windows platform module forces this to .exe,
# overriding any cache variable. Create .exe symlinks so the suffixed paths
# resolve to the native Linux binaries.
set(HOST_TOOLS icupkg pkgdata genrb genccode gencmn gennorm2 gensprep
makeconv genbrk gencfu gencnval gendict)
foreach (tool ${HOST_TOOLS})
if (EXISTS "${HOST_BUILD_DIR}/bin/${tool}" AND NOT EXISTS "${HOST_BUILD_DIR}/bin/${tool}.exe")
file(CREATE_LINK "${HOST_BUILD_DIR}/bin/${tool}" "${HOST_BUILD_DIR}/bin/${tool}.exe" SYMBOLIC)
endif ()
endforeach ()
endif ()

# Check for a cross compile
if (DEFINED ICU_CROSS_BUILD_ROOT)
message(STATUS "Cross compiling ICU")
Expand All @@ -59,11 +113,23 @@ else ()
set(ENABLE_TOOLS ON)
endif ()

# When cross-compiling for Windows from a non-Windows host, pkgdata.exe runs
# under Wine but cannot invoke link.exe/LIB.exe. The CMake build links the
# data library itself, so skip the redundant link step in pkgdata (patch 0006).
if (NOT VCPKG_HOST_IS_WINDOWS AND ENABLE_TOOLS)
# When building from a non-Windows host, pkgdata cannot invoke link.exe/LIB.exe.
# The CMake build links the data library itself, so skip the redundant link step
# in pkgdata (patch 0006). This applies whether tools are built locally or
# pre-built native host tools are used via ICU_CROSS_BUILD_ROOT.
if (NOT VCPKG_HOST_IS_WINDOWS)
set(ENV{ICU_SKIP_PKGDATA_LINK} 1)

# Tell the native Linux pkgdata binary which CPU architecture to target
# when generating COFF object code (patch 0005). On native Windows the
# _M_* macros handle this, but a Linux-built pkgdata needs the env var.
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(ENV{ICU_DATA_CPU_ARCH} "arm64")
elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(ENV{ICU_DATA_CPU_ARCH} "x64")
elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(ENV{ICU_DATA_CPU_ARCH} "x86")
endif ()
endif ()

vcpkg_cmake_configure(
Expand Down
2 changes: 1 addition & 1 deletion ports/icu/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "icu",
"version": "77.1.0",
"port-version": 2,
"port-version": 3,
"description": "ICU is a mature, widely used set of C/C++ and Java libraries providing Unicode and Globalization support for software applications. ICU is widely portable and gives applications the same results on all platforms and between C/C++ and Java software.",
"homepage": "http://site.icu-project.org",
"license": "ICU",
Expand Down
20 changes: 20 additions & 0 deletions ports/libwebp/0002-cmake-config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/cmake/WebPConfig.cmake.in b/cmake/WebPConfig.cmake.in
index a0d721f..8726c09 100644
--- a/cmake/WebPConfig.cmake.in
+++ b/cmake/WebPConfig.cmake.in
@@ -13,7 +13,14 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
set_and_check(WebP_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR})
set(WEBP_INCLUDE_DIRS ${WebP_INCLUDE_DIR})
-set(WebP_LIBRARIES "@INSTALLED_LIBRARIES@")
+set(WebP_LIBRARIES "")
+include(SelectLibraryConfigurations)
+foreach(_vcpkg_libwebp_lib IN ITEMS @INSTALLED_LIBRARIES@ sharpyuv)
+ find_library(_vcpkg_${_vcpkg_libwebp_lib}_LIBRARY_RELEASE NAMES ${_vcpkg_libwebp_lib} lib${_vcpkg_libwebp_lib} NAMES_PER_DIR PATHS "${VCPKG_IMPORT_PREFIX}/lib" NO_DEFAULT_PATH)
+ find_library(_vcpkg_${_vcpkg_libwebp_lib}_LIBRARY_DEBUG NAMES ${_vcpkg_libwebp_lib}d lib${_vcpkg_libwebp_lib}d ${_vcpkg_libwebp_lib} lib${_vcpkg_libwebp_lib} NAMES_PER_DIR PATHS "${VCPKG_IMPORT_PREFIX}/debug/lib" NO_DEFAULT_PATH)
+ select_library_configurations(_vcpkg_${_vcpkg_libwebp_lib})
+ list(APPEND WebP_LIBRARIES ${_vcpkg_${_vcpkg_libwebp_lib}_LIBRARIES})
+endforeach()
set(WEBP_LIBRARIES "${WebP_LIBRARIES}")

check_required_components(WebP)
23 changes: 23 additions & 0 deletions ports/libwebp/0003-simd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/cmake/cpu.cmake b/cmake/cpu.cmake
index 3b0b2d37..a376b87b 100644
--- a/cmake/cpu.cmake
+++ b/cmake/cpu.cmake
@@ -50,7 +50,7 @@ if(MSVC AND CMAKE_C_COMPILER_ID STREQUAL "MSVC")
if(MSVC_VERSION GREATER_EQUAL 1800 AND NOT CMAKE_C_FLAGS MATCHES "/arch:")
set(SIMD_ENABLE_FLAGS)
else()
- set(SIMD_ENABLE_FLAGS "/arch:AVX2;/arch:AVX;/arch:SSE2;;;;")
+ set(SIMD_ENABLE_FLAGS ";;/arch:SSE2;;;;") # /arch:AVX2;/arch:AVX is too much for SSE4
endif()
set(SIMD_DISABLE_FLAGS)
else()
@@ -111,6 +111,9 @@ foreach(I_SIMD RANGE ${WEBP_SIMD_FLAGS_RANGE})
"${CMAKE_CURRENT_LIST_DIR}/../src/dsp/*${WEBP_SIMD_FILE_EXTENSION}")
if(WEBP_HAVE_${WEBP_SIMD_FLAG})
# Memorize the file and flags.
+ if("${SIMD_COMPILE_FLAG}" STREQUAL "")
+ set(SIMD_COMPILE_FLAG " ")
+ endif()
foreach(FILE ${SIMD_FILES})
list(APPEND WEBP_SIMD_FILES_TO_INCLUDE ${FILE})
list(APPEND WEBP_SIMD_FLAGS_TO_INCLUDE ${SIMD_COMPILE_FLAG})
43 changes: 43 additions & 0 deletions ports/libwebp/0008-sdl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b785a8e..f214a32 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -665,6 +665,10 @@ if(WEBP_BUILD_EXTRAS)
${CMAKE_CURRENT_BINARY_DIR}/src ${SDL2_INCLUDE_DIRS})
set(WEBP_HAVE_SDL 1)
target_compile_definitions(vwebp_sdl PUBLIC WEBP_HAVE_SDL)
+ target_compile_definitions(vwebp_sdl PRIVATE WEBP_HAVE_JUST_SDL_H)
+ if(WIN32)
+ target_link_libraries(vwebp_sdl dxguid winmm)
+ endif()

set(CMAKE_REQUIRED_INCLUDES "${SDL2_INCLUDE_DIRS}")
check_c_source_compiles(
@@ -699,8 +703,9 @@ if(WEBP_BUILD_WEBP_JS)
if(NOT WEBP_ENABLE_SIMD)
# JavaScript version
add_executable(webp_js ${CMAKE_CURRENT_SOURCE_DIR}/extras/webp_to_sdl.c)
- target_link_libraries(webp_js webpdecoder SDL2)
+ target_link_libraries(webp_js webpdecoder ${SDL_LIBRARY})
target_include_directories(webp_js PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+ target_include_directories(webp_js PRIVATE ${SDL_INCLUDE_DIR})
set(WEBP_HAVE_SDL 1)
set_target_properties(
webp_js
@@ -715,12 +720,15 @@ if(WEBP_BUILD_WEBP_JS)
-sALLOW_MEMORY_GROWTH")
set_target_properties(webp_js PROPERTIES OUTPUT_NAME webp)
target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_SDL)
+ target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_JUST_SDL_H)
endif()

# WASM version
add_executable(webp_wasm ${CMAKE_CURRENT_SOURCE_DIR}/extras/webp_to_sdl.c)
- target_link_libraries(webp_wasm webpdecoder SDL2)
+ target_link_libraries(webp_wasm webpdecoder ${SDL_LIBRARY})
target_include_directories(webp_wasm PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+ target_include_directories(webp_wasm PRIVATE ${SDL_INCLUDE_DIR})
+ target_compile_definitions(webp_wasm PUBLIC EMSCRIPTEN WEBP_HAVE_JUST_SDL_H)
set_target_properties(
webp_wasm
PROPERTIES
31 changes: 31 additions & 0 deletions ports/libwebp/0009-cpufeatures-android.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 39d3d8f6..6169be39 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -185,24 +185,8 @@ if(WEBP_ENABLE_WUNUSED_RESULT)
endif()

# ##############################################################################
-# Android only.
-if(ANDROID)
- include_directories(${ANDROID_NDK}/sources/android/cpufeatures)
- add_library(cpufeatures-webp STATIC
- ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
- list(APPEND INSTALLED_LIBRARIES cpufeatures-webp)
- target_link_libraries(cpufeatures-webp dl)
- set(SHARPYUV_DEP_LIBRARIES ${SHARPYUV_DEP_LIBRARIES} cpufeatures-webp)
- set(WEBP_DEP_LIBRARIES ${WEBP_DEP_LIBRARIES} cpufeatures-webp)
- set(cpufeatures_include_dir ${ANDROID_NDK}/sources/android/cpufeatures)
- set(SHARPYUV_DEP_INCLUDE_DIRS ${SHARPYUV_DEP_INCLUDE_DIRS}
- ${cpufeatures_include_dir})
- set(WEBP_DEP_INCLUDE_DIRS ${WEBP_DEP_INCLUDE_DIRS} ${cpufeatures_include_dir})
- add_definitions(-DHAVE_CPU_FEATURES_H=1)
- set(HAVE_CPU_FEATURES_H 1)
-else()
- set(HAVE_CPU_FEATURES_H 0)
-endif()
+# To streamline dependency management, remove usage of the NDK-bundled cpufeatures.
+set(HAVE_CPU_FEATURES_H 0)

function(configure_pkg_config FILE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.in"
13 changes: 13 additions & 0 deletions ports/libwebp/0010-fix-clang-cl-simd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/cmake/cpu.cmake b/cmake/cpu.cmake
index a376b87..6934e24 100644
--- a/cmake/cpu.cmake
+++ b/cmake/cpu.cmake
@@ -41,7 +41,7 @@ endfunction()
set(WEBP_SIMD_FLAGS "AVX2;SSE41;SSE2;MIPS32;MIPS_DSP_R2;NEON;MSA")
set(WEBP_SIMD_FILE_EXTENSIONS
"_avx2.c;_sse41.c;_sse2.c;_mips32.c;_mips_dsp_r2.c;_neon.c;_msa.c")
-if(MSVC AND CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+if(MSVC)
# With at least Visual Studio 12 (2013)+ /arch is not necessary to build SSE2
# or SSE4 code unless a lesser /arch is forced. MSVC does not have a SSE4
# flag, but an AVX one. Using that with SSE4 code risks generating illegal
Loading
Loading