Initial community commit

This commit is contained in:
Jef
2024-09-24 14:54:57 +02:00
parent 537bcbc862
commit 20d28e80a5
16810 changed files with 4640254 additions and 2 deletions

View File

@ -0,0 +1,18 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c83dd83..2d1a7e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,9 +82,11 @@ if(HAVE_WERROR_FLAG)
option(ENABLE_WERROR "Enable -Werror in all Makefiles" OFF)
endif()
+if(MSVC AND NOT WITH_ASM)
+ add_compile_options(/wd4267 /wd4996)
+endif()
+
add_compile_options(
- $<$<BOOL:${MSVC}>:/wd4267>
- $<$<BOOL:${MSVC}>:/wd4996>
$<$<BOOL:${ENABLE_WERROR}>:-Werror>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<BOOL:${HAVE_WEFFCXX_FLAG}>>:-Weffc++>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:${HAVE_DECL_AFTER_STMT_FLAG}>>:-Wdeclaration-after-statement>)

View File

@ -0,0 +1,85 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO xiph/flac
REF b32e5cbf9818ca23dd22aaa75522042c16ea7d17 #1.4.2
SHA512 911891203f3064b39058e209b62fc3fac8940ed01cc3c3d75c9e3e6f94b5cc5905efde94304a6aafa453adde2da2f9bafea9fb5297e6231562133a8acac2ea47 HEAD_REF master
PATCHES
uwp-library-console.patch
uwp-createfile2.patch
fix-compile-options.patch
)
if(VCPKG_TARGET_IS_MINGW)
set(WITH_STACK_PROTECTOR OFF)
string(APPEND VCPKG_C_FLAGS " -D_FORTIFY_SOURCE=0")
string(APPEND VCPKG_CXX_FLAGS " -D_FORTIFY_SOURCE=0")
else()
set(WITH_STACK_PROTECTOR ON)
endif()
if("asm" IN_LIST FEATURES)
VCPKG_FIND_ACQUIRE_PROGRAM(NASM)
GET_FILENAME_COMPONENT(NASM_PATH "${NASM}" DIRECTORY)
vcpkg_add_to_path("${NASM_PATH}")
endif()
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
asm WITH_ASM
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DBUILD_PROGRAMS=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_DOCS=OFF
-DBUILD_TESTING=OFF
-DWITH_STACK_PROTECTOR=${WITH_STACK_PROTECTOR}
-DINSTALL_MANPAGES=OFF
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME FLAC CONFIG_PATH lib/cmake/FLAC)
vcpkg_copy_pdbs()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(REMOVE "${CURRENT_PACKAGES_DIR}/share/LICENSE")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/FLAC/export.h"
"#if defined(FLAC__NO_DLL)"
"#if 0"
)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/FLAC++/export.h"
"#if defined(FLAC__NO_DLL)"
"#if 0"
)
else()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/FLAC/export.h"
"#if defined(FLAC__NO_DLL)"
"#if 1"
)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/FLAC++/export.h"
"#if defined(FLAC__NO_DLL)"
"#if 1"
)
endif()
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/flac.pc" " -lm" "")
if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/flac.pc")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/flac.pc" " -lm" "")
endif()
endif()
vcpkg_fixup_pkgconfig()
# This license (BSD) is relevant only for library - if someone would want to install
# FLAC cmd line tools as well additional license (GPL) should be included
file(INSTALL "${SOURCE_PATH}/COPYING.Xiph" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -0,0 +1,41 @@
diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c
index af6d0f4..6a6de15 100644
--- a/src/share/win_utf8_io/win_utf8_io.c
+++ b/src/share/win_utf8_io/win_utf8_io.c
@@ -160,6 +160,27 @@ int get_utf8_argv(int *argc, char ***argv)
/* similar to CreateFileW but accepts UTF-8 encoded lpFileName */
HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
+#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
+ HANDLE handle = INVALID_HANDLE_VALUE;
+
+ if (!flac_internal_get_utf8_filenames())
+ return handle;
+
+ wchar_t *wname;
+
+ if ((wname = wchar_from_utf8(lpFileName)) != NULL)
+ {
+ CREATEFILE2_EXTENDED_PARAMETERS cfParams = {0};
+ cfParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ cfParams.dwFileAttributes = dwFlagsAndAttributes & FILE_ATTRIBUTE_NORMAL;
+ cfParams.lpSecurityAttributes = lpSecurityAttributes;
+ cfParams.hTemplateFile = hTemplateFile;
+ handle = CreateFile2(wname, dwDesiredAccess, dwShareMode, dwCreationDisposition, &cfParams);
+ free(wname);
+ }
+
+ return handle;
+#else
wchar_t *wname;
HANDLE handle = INVALID_HANDLE_VALUE;
@@ -180,6 +201,7 @@ HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWO
}
return handle;
+#endif
}
/* return number of characters in the UTF-8 string */

View File

@ -0,0 +1,54 @@
diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c
index 65b5699..af6d0f4 100644
--- a/src/share/win_utf8_io/win_utf8_io.c
+++ b/src/share/win_utf8_io/win_utf8_io.c
@@ -115,7 +115,11 @@ int get_utf8_argv(int *argc, char ***argv)
char **utf8argv;
int ret, i;
+#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
+ if ((handle = LoadPackagedLibrary("msvcrt.dll", 0)) == NULL) return 1;
+#else
if ((handle = LoadLibraryW(L"msvcrt.dll")) == NULL) return 1;
+#endif
if ((wgetmainargs = (wgetmainargs_t)GetProcAddress(handle, "__wgetmainargs")) == NULL) {
FreeLibrary(handle);
return 1;
@@ -192,6 +196,9 @@ size_t strlen_utf8(const char *str)
/* get the console width in characters */
int win_get_console_width(void)
{
+#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
+ return 80;
+#else
int width = 80;
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
CONSOLE_SCREEN_BUFFER_INFO csbi;
@@ -201,6 +208,7 @@ int win_get_console_width(void)
width = csbi.dwSize.X;
#endif // WINAPI_PARTITION_DESKTOP
return width;
+#endif
}
/* print functions */
@@ -211,6 +219,11 @@ static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
DWORD out;
int ret;
+#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
+ // disabled for UWP as there's no alternative:
+ // https://docs.microsoft.com/en-us/uwp/win32-and-com/alternatives-to-windows-apis-uwp
+#else
+
do {
if (stream == stdout) {
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -229,6 +242,7 @@ static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
return out;
}
} while(0);
+#endif
ret = fputws(text, stream);
if (ret < 0)

View File

@ -0,0 +1,25 @@
{
"name": "libflac",
"version": "1.4.2",
"port-version": 0,
"description": "Library for manipulating FLAC files",
"homepage": "https://xiph.org/flac/",
"license": "GFDL-1.2-or-later",
"dependencies": [
"libogg",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"asm": {
"description": "Use any assembly optimization routines",
"supports": "x86"
}
}
}