Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[uchardet] Add new port #8477

Merged
merged 10 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 8 additions & 0 deletions ports/uchardet/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Source: uchardet
Version: 2019-10-07
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
13 changes: 13 additions & 0 deletions ports/uchardet/fix-string-no-output-variable.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bf68ec0..4863a5c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,7 +39,7 @@ if (BUILD_SHARED_LIBS)
endif (BUILD_SHARED_LIBS)

if (TARGET_ARCHITECTURE STREQUAL "")
- string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} TARGET_ARCHITECTURE)
+ string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" TARGET_ARCHITECTURE)
endif (TARGET_ARCHITECTURE STREQUAL "")

if (TARGET_ARCHITECTURE MATCHES ".*(x86)|(amd).*")
17 changes: 17 additions & 0 deletions ports/uchardet/fix-tool-build-error.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/src/tools/uchardet.cpp b/src/tools/uchardet.cpp
index f2aabfd..e49a9e2 100644
--- a/src/tools/uchardet.cpp
+++ b/src/tools/uchardet.cpp
@@ -35,11 +35,8 @@
*
* ***** END LICENSE BLOCK ***** */
#include "../uchardet.h"
-#include <cstdio>
-#include <cstring>
-#include <cstdlib>
+#include <stdlib.h>
#include <getopt.h>
-#include <iostream>
#include <stdio.h>

#ifndef VERSION
59 changes: 59 additions & 0 deletions ports/uchardet/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
include(vcpkg_common_functions)
LilyWangL marked this conversation as resolved.
Show resolved Hide resolved

vcpkg_from_git(
OUT_SOURCE_PATH SOURCE_PATH
URL https://gitlab.freedesktop.org/uchardet/uchardet
REF bdfd6116a965fd210ef563613763e724424728b7
PATCHES
fix-string-no-output-variable.patch
fix-tool-build-error.patch
win32-getopt.patch
)

if(VCPKG_TARGET_IS_WINDOWS)
# On Windows, we can get a uchardet.dll, but it exports no symbols.
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()

vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
tool BUILD_BINARY
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS_DEBUG
-DBUILD_BINARY=OFF
OPTIONS_RELEASE
${FEATURE_OPTIONS}
OPTIONS
-DBUILD_STATIC=ON
)

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
)

configure_file(${SOURCE_PATH}/COPYING ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright COPYONLY)
LilyWangL marked this conversation as resolved.
Show resolved Hide resolved
32 changes: 32 additions & 0 deletions ports/uchardet/win32-getopt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index fa15eb2..fbb4203 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -3,6 +3,15 @@ set(
uchardet.cpp
)

+if (WIN32)
+ find_path(GETOPT_INCLUDE_DIR NAMES getopt.h)
+ find_library(GETOPT_LIBRARY NAMES getopt)
+
+ if (NOT GETOPT_INCLUDE_DIR OR NOT GETOPT_LIBRARY)
+ message(FATAL_ERROR "getopt not found!")
+ endif ()
+endif ()
+
set(UCHARDET_BINARY uchardet)

add_executable(
@@ -15,6 +24,11 @@ target_link_libraries(
${UCHARDET_LIBRARY}
)

+if (WIN32)
+ target_include_directories(${UCHARDET_BINARY} PRIVATE ${GETOPT_INCLUDE_DIR})
+ target_link_libraries(${UCHARDET_BINARY} PRIVATE ${GETOPT_LIBRARY})
+endif ()
+
install(
TARGETS
${UCHARDET_BINARY}