[uchardet] Add new port (#8477)

* [uchardet] Add new port

* [uchardet] Fix string no output variable error

[uchardet] Update homepage

* [uchardet] Fix tool build error on Windows

* [uchardet] Update

* [uchardet] Modernize

* [uchardet] Update to 2020-04-26

* [uchardet] Fix static build

* [uchardet] Fix UWP build
This commit is contained in:
myd7349 2020-04-29 04:15:57 +08:00 committed by GitHub
parent b9c3a26392
commit be2f81f912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 0 deletions

8
ports/uchardet/CONTROL Normal file
View File

@ -0,0 +1,8 @@
Source: uchardet
Version: 2020-04-26
Description: An encoding detector library ported from Mozilla
Homepage: https://cgit.freedesktop.org/uchardet/uchardet/
Feature: tool
Description: Build uchardet CLI tool
Build-Depends: getopt

View File

@ -0,0 +1,56 @@
vcpkg_from_git(
OUT_SOURCE_PATH SOURCE_PATH
URL https://gitlab.freedesktop.org/uchardet/uchardet
REF 8681fc060ea07f646434cd2d324e4a5aa7c495c4
)
vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
tool BUILD_BINARY
)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)
if(VCPKG_TARGET_IS_UWP)
# uchardet calls `fopen` and `strdup`, which makes UWP unhappy.
set(VCPKG_C_FLAGS "${VCPKG_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE")
set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE")
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS_DEBUG
-DBUILD_BINARY=OFF
OPTIONS_RELEASE
${FEATURE_OPTIONS}
OPTIONS
-DBUILD_STATIC=${BUILD_STATIC}
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
if(tool IN_LIST FEATURES)
file(COPY
${CURRENT_PACKAGES_DIR}/bin/uchardet${VCPKG_TARGET_EXECUTABLE_SUFFIX}
DESTINATION ${CURRENT_PACKAGES_DIR}/tools/${PORT}
)
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT})
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
else()
file(REMOVE ${CURRENT_PACKAGES_DIR}/bin/uchardet${VCPKG_TARGET_EXECUTABLE_SUFFIX})
endif()
file(REMOVE_RECURSE
${CURRENT_PACKAGES_DIR}/debug/include
${CURRENT_PACKAGES_DIR}/debug/share
${CURRENT_PACKAGES_DIR}/share/man
)
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)