From 295bb9f45429900d019562e487272a5acde59f16 Mon Sep 17 00:00:00 2001 From: Aybe Date: Fri, 17 Nov 2017 02:10:21 +0100 Subject: [libsndfile] patches for UWP builds --- ports/libsndfile/CONTROL | 2 +- ports/libsndfile/portfile.cmake | 9 ++++++++ ports/libsndfile/uwp-createfile.patch | 39 ++++++++++++++++++++++++++++++++++ ports/libsndfile/uwp-getfilesize.patch | 29 +++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 ports/libsndfile/uwp-createfile.patch create mode 100644 ports/libsndfile/uwp-getfilesize.patch diff --git a/ports/libsndfile/CONTROL b/ports/libsndfile/CONTROL index 67e058991..70be2ab6c 100644 --- a/ports/libsndfile/CONTROL +++ b/ports/libsndfile/CONTROL @@ -1,4 +1,4 @@ Source: libsndfile -Version: 1.0.29-6830c42-1 +Version: 1.0.29-6830c42-2 Description: Library to read, write and manipulate many soundfile types. Authored by Eric de Castro Lopo Build-Depends: libogg, libflac, libvorbis diff --git a/ports/libsndfile/portfile.cmake b/ports/libsndfile/portfile.cmake index ac07f96a0..304bc005b 100644 --- a/ports/libsndfile/portfile.cmake +++ b/ports/libsndfile/portfile.cmake @@ -19,6 +19,15 @@ vcpkg_download_distfile(ARCHIVE ) vcpkg_extract_source_archive(${ARCHIVE}) +if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL WindowsStore) + vcpkg_apply_patches( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libsndfile-6830c421899e32f8d413a903a21a9b6cf384d369 + PATCHES + "${CMAKE_CURRENT_LIST_DIR}/uwp-createfile.patch" + "${CMAKE_CURRENT_LIST_DIR}/uwp-getfilesize.patch" + ) +endif() + if (VCPKG_CRT_LINKAGE STREQUAL "dynamic") set(CRT_LIB_STATIC 0) elseif (VCPKG_CRT_LINKAGE STREQUAL "static") diff --git a/ports/libsndfile/uwp-createfile.patch b/ports/libsndfile/uwp-createfile.patch new file mode 100644 index 000000000..d4b58a74f --- /dev/null +++ b/ports/libsndfile/uwp-createfile.patch @@ -0,0 +1,39 @@ +diff --git a/src/file_io.c b/src/file_io.c +index 7cf8f0c..a47ce6b 100644 +--- a/src/file_io.c ++++ b/src/file_io.c +@@ -787,26 +787,14 @@ psf_open_handle (PSF_FILE * pfile) + return NULL ; + } ; + +- if (pfile->use_wchar) +- handle = CreateFileW ( +- pfile->path.wc, /* pointer to name of the file */ +- dwDesiredAccess, /* access (read-write) mode */ +- dwShareMode, /* share mode */ +- 0, /* pointer to security attributes */ +- dwCreationDistribution, /* how to create */ +- FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */ +- NULL /* handle to file with attributes to copy */ +- ) ; +- else +- handle = CreateFile ( +- pfile->path.c, /* pointer to name of the file */ +- dwDesiredAccess, /* access (read-write) mode */ +- dwShareMode, /* share mode */ +- 0, /* pointer to security attributes */ +- dwCreationDistribution, /* how to create */ +- FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */ +- NULL /* handle to file with attributes to copy */ +- ) ; ++ if (!pfile->use_wchar) ++ return NULL; ++ ++ CREATEFILE2_EXTENDED_PARAMETERS cfParams = {0}; ++ cfParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); ++ cfParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; ++ ++ handle = CreateFile2(pfile->path.wc, dwDesiredAccess, dwShareMode, dwCreationDistribution, &cfParams); + + if (handle == INVALID_HANDLE_VALUE) + return NULL ; diff --git a/ports/libsndfile/uwp-getfilesize.patch b/ports/libsndfile/uwp-getfilesize.patch new file mode 100644 index 000000000..1ecbcda7f --- /dev/null +++ b/ports/libsndfile/uwp-getfilesize.patch @@ -0,0 +1,29 @@ +diff --git a/src/file_io.c b/src/file_io.c +index a47ce6b..4b38455 100644 +--- a/src/file_io.c ++++ b/src/file_io.c +@@ -1093,19 +1093,16 @@ psf_is_pipe (SF_PRIVATE *psf) + /* USE_WINDOWS_API */ sf_count_t + psf_get_filelen_handle (HANDLE handle) + { sf_count_t filelen ; +- DWORD dwFileSizeLow, dwFileSizeHigh, dwError = NO_ERROR ; ++ DWORD dwError = NO_ERROR ; ++ LARGE_INTEGER size; + +- dwFileSizeLow = GetFileSize (handle, &dwFileSizeHigh) ; +- +- if (dwFileSizeLow == 0xFFFFFFFF) +- dwError = GetLastError () ; ++ if (!GetFileSizeEx(handle, &size)) ++ dwError = GetLastError(); + + if (dwError != NO_ERROR) + return (sf_count_t) -1 ; + +- filelen = dwFileSizeLow + ((__int64) dwFileSizeHigh << 32) ; +- +- return filelen ; ++ return size.QuadPart; + } /* psf_get_filelen_handle */ + + /* USE_WINDOWS_API */ void -- cgit v1.2.3 From 72fdd294b05f7b29cc711757a819df2948c72d80 Mon Sep 17 00:00:00 2001 From: Aybe Date: Tue, 21 Nov 2017 04:39:13 +0100 Subject: [libsndfile] patches applied with #ifdef instead --- ports/libsndfile/portfile.cmake | 13 ++--- ports/libsndfile/uwp-createfile-getfilesize.patch | 58 +++++++++++++++++++++++ ports/libsndfile/uwp-createfile.patch | 39 --------------- ports/libsndfile/uwp-getfilesize.patch | 29 ------------ 4 files changed, 63 insertions(+), 76 deletions(-) create mode 100644 ports/libsndfile/uwp-createfile-getfilesize.patch delete mode 100644 ports/libsndfile/uwp-createfile.patch delete mode 100644 ports/libsndfile/uwp-getfilesize.patch diff --git a/ports/libsndfile/portfile.cmake b/ports/libsndfile/portfile.cmake index 304bc005b..503134ff2 100644 --- a/ports/libsndfile/portfile.cmake +++ b/ports/libsndfile/portfile.cmake @@ -19,14 +19,11 @@ vcpkg_download_distfile(ARCHIVE ) vcpkg_extract_source_archive(${ARCHIVE}) -if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL WindowsStore) - vcpkg_apply_patches( - SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libsndfile-6830c421899e32f8d413a903a21a9b6cf384d369 - PATCHES - "${CMAKE_CURRENT_LIST_DIR}/uwp-createfile.patch" - "${CMAKE_CURRENT_LIST_DIR}/uwp-getfilesize.patch" - ) -endif() +vcpkg_apply_patches( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libsndfile-6830c421899e32f8d413a903a21a9b6cf384d369 + PATCHES + "${CMAKE_CURRENT_LIST_DIR}/uwp-createfile-getfilesize.patch" +) if (VCPKG_CRT_LINKAGE STREQUAL "dynamic") set(CRT_LIB_STATIC 0) diff --git a/ports/libsndfile/uwp-createfile-getfilesize.patch b/ports/libsndfile/uwp-createfile-getfilesize.patch new file mode 100644 index 000000000..0e60cde54 --- /dev/null +++ b/ports/libsndfile/uwp-createfile-getfilesize.patch @@ -0,0 +1,58 @@ +diff --git a/src/file_io.c b/src/file_io.c +index 7cf8f0c..47351bc 100644 +--- a/src/file_io.c ++++ b/src/file_io.c +@@ -787,6 +787,19 @@ psf_open_handle (PSF_FILE * pfile) + return NULL ; + } ; + ++#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) ++ if (!pfile->use_wchar) ++ return NULL; ++ ++ CREATEFILE2_EXTENDED_PARAMETERS cfParams = {0}; ++ cfParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); ++ cfParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; ++ ++ handle = CreateFile2(pfile->path.wc, dwDesiredAccess, dwShareMode, dwCreationDistribution, &cfParams); ++ ++ if (handle == INVALID_HANDLE_VALUE) ++ return NULL; ++#else + if (pfile->use_wchar) + handle = CreateFileW ( + pfile->path.wc, /* pointer to name of the file */ +@@ -812,6 +825,7 @@ psf_open_handle (PSF_FILE * pfile) + return NULL ; + + return handle ; ++#endif + } /* psf_open_handle */ + + /* USE_WINDOWS_API */ static void +@@ -1104,7 +1118,16 @@ psf_is_pipe (SF_PRIVATE *psf) + + /* USE_WINDOWS_API */ sf_count_t + psf_get_filelen_handle (HANDLE handle) +-{ sf_count_t filelen ; ++{ ++#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) ++ LARGE_INTEGER size; ++ ++ if (!GetFileSizeEx(handle, &size) && GetLastError() != NO_ERROR) ++ return (sf_count_t) -1 ; ++ ++ return size.QuadPart; ++#else ++ sf_count_t filelen ; + DWORD dwFileSizeLow, dwFileSizeHigh, dwError = NO_ERROR ; + + dwFileSizeLow = GetFileSize (handle, &dwFileSizeHigh) ; +@@ -1118,6 +1141,7 @@ psf_get_filelen_handle (HANDLE handle) + filelen = dwFileSizeLow + ((__int64) dwFileSizeHigh << 32) ; + + return filelen ; ++#endif + } /* psf_get_filelen_handle */ + + /* USE_WINDOWS_API */ void diff --git a/ports/libsndfile/uwp-createfile.patch b/ports/libsndfile/uwp-createfile.patch deleted file mode 100644 index d4b58a74f..000000000 --- a/ports/libsndfile/uwp-createfile.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff --git a/src/file_io.c b/src/file_io.c -index 7cf8f0c..a47ce6b 100644 ---- a/src/file_io.c -+++ b/src/file_io.c -@@ -787,26 +787,14 @@ psf_open_handle (PSF_FILE * pfile) - return NULL ; - } ; - -- if (pfile->use_wchar) -- handle = CreateFileW ( -- pfile->path.wc, /* pointer to name of the file */ -- dwDesiredAccess, /* access (read-write) mode */ -- dwShareMode, /* share mode */ -- 0, /* pointer to security attributes */ -- dwCreationDistribution, /* how to create */ -- FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */ -- NULL /* handle to file with attributes to copy */ -- ) ; -- else -- handle = CreateFile ( -- pfile->path.c, /* pointer to name of the file */ -- dwDesiredAccess, /* access (read-write) mode */ -- dwShareMode, /* share mode */ -- 0, /* pointer to security attributes */ -- dwCreationDistribution, /* how to create */ -- FILE_ATTRIBUTE_NORMAL, /* file attributes (could use FILE_FLAG_SEQUENTIAL_SCAN) */ -- NULL /* handle to file with attributes to copy */ -- ) ; -+ if (!pfile->use_wchar) -+ return NULL; -+ -+ CREATEFILE2_EXTENDED_PARAMETERS cfParams = {0}; -+ cfParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); -+ cfParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; -+ -+ handle = CreateFile2(pfile->path.wc, dwDesiredAccess, dwShareMode, dwCreationDistribution, &cfParams); - - if (handle == INVALID_HANDLE_VALUE) - return NULL ; diff --git a/ports/libsndfile/uwp-getfilesize.patch b/ports/libsndfile/uwp-getfilesize.patch deleted file mode 100644 index 1ecbcda7f..000000000 --- a/ports/libsndfile/uwp-getfilesize.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/src/file_io.c b/src/file_io.c -index a47ce6b..4b38455 100644 ---- a/src/file_io.c -+++ b/src/file_io.c -@@ -1093,19 +1093,16 @@ psf_is_pipe (SF_PRIVATE *psf) - /* USE_WINDOWS_API */ sf_count_t - psf_get_filelen_handle (HANDLE handle) - { sf_count_t filelen ; -- DWORD dwFileSizeLow, dwFileSizeHigh, dwError = NO_ERROR ; -+ DWORD dwError = NO_ERROR ; -+ LARGE_INTEGER size; - -- dwFileSizeLow = GetFileSize (handle, &dwFileSizeHigh) ; -- -- if (dwFileSizeLow == 0xFFFFFFFF) -- dwError = GetLastError () ; -+ if (!GetFileSizeEx(handle, &size)) -+ dwError = GetLastError(); - - if (dwError != NO_ERROR) - return (sf_count_t) -1 ; - -- filelen = dwFileSizeLow + ((__int64) dwFileSizeHigh << 32) ; -- -- return filelen ; -+ return size.QuadPart; - } /* psf_get_filelen_handle */ - - /* USE_WINDOWS_API */ void -- cgit v1.2.3 From 395829c5450f0f964cbfc08e1aac5b4559729aed Mon Sep 17 00:00:00 2001 From: Aybe Date: Tue, 21 Nov 2017 06:54:11 +0100 Subject: [libsndfile] fixed missing return ! --- ports/libsndfile/portfile.cmake | 1 + ports/libsndfile/uwp-createfile-getfilesize-addendum.patch | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 ports/libsndfile/uwp-createfile-getfilesize-addendum.patch diff --git a/ports/libsndfile/portfile.cmake b/ports/libsndfile/portfile.cmake index 503134ff2..daa7de3ae 100644 --- a/ports/libsndfile/portfile.cmake +++ b/ports/libsndfile/portfile.cmake @@ -23,6 +23,7 @@ vcpkg_apply_patches( SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libsndfile-6830c421899e32f8d413a903a21a9b6cf384d369 PATCHES "${CMAKE_CURRENT_LIST_DIR}/uwp-createfile-getfilesize.patch" + "${CMAKE_CURRENT_LIST_DIR}/uwp-createfile-getfilesize-addendum.patch" ) if (VCPKG_CRT_LINKAGE STREQUAL "dynamic") diff --git a/ports/libsndfile/uwp-createfile-getfilesize-addendum.patch b/ports/libsndfile/uwp-createfile-getfilesize-addendum.patch new file mode 100644 index 000000000..62e6b1131 --- /dev/null +++ b/ports/libsndfile/uwp-createfile-getfilesize-addendum.patch @@ -0,0 +1,13 @@ +diff --git a/src/file_io.c b/src/file_io.c +index 47351bc..54741c9 100644 +--- a/src/file_io.c ++++ b/src/file_io.c +@@ -799,6 +799,8 @@ psf_open_handle (PSF_FILE * pfile) + + if (handle == INVALID_HANDLE_VALUE) + return NULL; ++ ++ return handle; + #else + if (pfile->use_wchar) + handle = CreateFileW ( -- cgit v1.2.3