Skip to content

Commit

Permalink
[gettext] Improve and simplify port
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Mar 2, 2018
1 parent 5a83ee1 commit 01ba04e
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 72 deletions.
18 changes: 9 additions & 9 deletions ports/gettext/0002-Fix-uwp-build.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git "a/gettext-0.19/gettext-runtime/intl/langprefs.c" "b/gettext-0.19/gettext-runtime/intl/langprefs.c"
diff --git "a/gettext-runtime/intl/langprefs.c" "b/gettext-runtime/intl/langprefs.c"
index aeb1c4e9..2ac531be 100644
--- "a/gettext-0.19/gettext-runtime/intl/langprefs.c"
+++ "b/gettext-0.19/gettext-runtime/intl/langprefs.c"
--- "a/gettext-runtime/intl/langprefs.c"
+++ "b/gettext-runtime/intl/langprefs.c"
@@ -33,7 +33,13 @@ extern void _nl_locale_name_canonicalize (char *name);
#endif

Expand All @@ -17,10 +17,10 @@ index aeb1c4e9..2ac531be 100644
#endif

#ifdef WIN32_NATIVE
diff --git "a/gettext-0.19/gettext-runtime/intl/localcharset.c" "b/gettext-0.19/gettext-runtime/intl/localcharset.c"
diff --git "a/gettext-runtime/intl/localcharset.c" "b/gettext-runtime/intl/localcharset.c"
index 670b8e6c..035a96bd 100644
--- "a/gettext-0.19/gettext-runtime/intl/localcharset.c"
+++ "b/gettext-0.19/gettext-runtime/intl/localcharset.c"
--- "a/gettext-runtime/intl/localcharset.c"
+++ "b/gettext-runtime/intl/localcharset.c"
@@ -36,6 +36,16 @@
# define WINDOWS_NATIVE
#endif
Expand Down Expand Up @@ -56,10 +56,10 @@ index 670b8e6c..035a96bd 100644

static char buf[2 + 10 + 1];

diff --git "a/gettext-0.19/gettext-runtime/intl/localename.c" "b/gettext-0.19/gettext-runtime/intl/localename.c"
diff --git "a/gettext-runtime/intl/localename.c" "b/gettext-runtime/intl/localename.c"
index 108dd6f1..ace3aa88 100644
--- "a/gettext-0.19/gettext-runtime/intl/localename.c"
+++ "b/gettext-0.19/gettext-runtime/intl/localename.c"
--- "a/gettext-runtime/intl/localename.c"
+++ "b/gettext-runtime/intl/localename.c"
@@ -54,7 +54,13 @@
#endif

Expand Down
66 changes: 65 additions & 1 deletion ports/gettext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
add_subdirectory(gettext-runtime)
cmake_minimum_required(VERSION 3.5)
project(libintl C)

find_library(ICONV_LIB NAMES iconv libiconv)
find_path(ICONV_PATH iconv.h)

find_library(CHARSET_LIB NAMES charset libcharset)
find_path(CHARSET_PATH localcharset.h)

include_directories(${CMAKE_CURRENT_BINARY_DIR} . ${ICONV_PATH} ${CHARSET_PATH})
link_libraries(${CHARSET_LIB} ${ICONV_LIB})

file(READ config.h _contents)
if(NOT WIN32)
string(REPLACE "/* #undef HAVE_STPCPY */" "#define HAVE_STPCPY 1" _contents "${_contents}")
endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config.h" "${_contents}")

FILE(GLOB SOURCES
"intl/bindtextdom.c"
"intl/dcgettext.c"
"intl/dcigettext.c"
"intl/dcngettext.c"
"intl/dgettext.c"
"intl/dngettext.c"
"intl/explodename.c"
"intl/finddomain.c"
"intl/gettext.c"
"intl/hash-string.c"
"intl/intl-compat.c"
"intl/l10nflist.c"
"intl/langprefs.c"
"intl/loadmsgcat.c"
"intl/localealias.c"
"intl/localename.c"
"intl/lock.c"
"intl/log.c"
"intl/ngettext.c"
"intl/osdep.c"
"intl/plural-exp.c"
"intl/plural.c"
"intl/printf.c"
"intl/relocatable.c"
"intl/textdomain.c"
"intl/version.c"
)

set(LOCALDIR "c:/gettext")

add_definitions(-DLOCALEDIR=\"${LOCALDIR}\")
add_definitions(-DLOCALE_ALIAS_PATH=\"${LOCALDIR}\")
add_definitions(-DLIBDIR=\"${LOCALDIR}\")
add_definitions(-DINSTALLDIR=\"${LOCALDIR}\")
add_definitions("-DBUILDING_LIBINTL -DBUILDING_DLL -DIN_LIBINTL -DENABLE_RELOCATABLE=1 -DIN_LIBRARY")

add_definitions("-DNO_XMALLOC -Dset_relocation_prefix=libintl_set_relocation_prefix -Drelocate=libintl_relocate -DDEPENDS_ON_LIBICONV=1 -DHAVE_CONFIG_H -D_CRT_SECURE_NO_WARNINGS")

add_library(libintl ${SOURCES})

install(TARGETS libintl
RUNTIME DESTINATION bin
LIBRARY DESTINATION bin
ARCHIVE DESTINATION lib
)

54 changes: 0 additions & 54 deletions ports/gettext/CMakeLists_libintl.txt

This file was deleted.

1 change: 1 addition & 0 deletions ports/gettext/CONTROL
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Source: gettext
Version: 0.19-2
Description: The GNU gettext utilities are a set of tools that provides a framework to help other GNU packages produce multi-lingual messages
Build-Depends: libiconv
12 changes: 10 additions & 2 deletions ports/gettext/config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */

#ifndef WIN32
# define _GL_INLINE_HEADER_BEGIN
# define _GL_INLINE_HEADER_END
# define _GL_INLINE static inline
#endif

/* Disable function deprecated warnings */
#define _CRT_NONSTDC_NO_WARNINGS

Expand Down Expand Up @@ -471,7 +477,9 @@

/* Define as the maximum value of type 'size_t', if the system doesn't define
it. */
#if defined(_WIN32)
#define SIZE_MAX (((1UL << 31) - 1) * 2 + 1)
#endif

/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type
'size_t'. */
Expand Down Expand Up @@ -607,7 +615,7 @@
/* Define as a signed type of the same size as size_t. */
#ifdef _WIN64
#define ssize_t __int64
#else
#elif _WIN32
#define ssize_t __int32
#endif

Expand All @@ -618,7 +626,7 @@
<inttypes.h> don't define. */
#ifdef _WIN64
#define uintmax_t unsigned __int64
#else
#elif _WIN32
#define uintmax_t unsigned __int32
#endif

Expand Down
2 changes: 1 addition & 1 deletion ports/gettext/libgnuintl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ USA. */
#ifndef _LIBINTL_H
#define _LIBINTL_H 1

#ifdef BUILDING_LIBINTL
#if defined(_WIN32) && defined(libintl_EXPORTS)
#define LIBINTL_DLL_EXPORTED __declspec(dllexport)
#else
#define LIBINTL_DLL_EXPORTED
Expand Down
9 changes: 4 additions & 5 deletions ports/gettext/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@ vcpkg_download_distfile(ARCHIVE
)
vcpkg_extract_source_archive(${ARCHIVE})

file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_libintl.txt DESTINATION ${SOURCE_PATH}/gettext-runtime)
file(RENAME ${SOURCE_PATH}/gettext-runtime/CMakeLists_libintl.txt ${SOURCE_PATH}/gettext-runtime/CMakeLists.txt)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}/gettext-runtime)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/libgnuintl.h DESTINATION ${SOURCE_PATH}/gettext-runtime/intl)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/config.h DESTINATION ${SOURCE_PATH}/gettext-runtime)

vcpkg_apply_patches(
SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/
SOURCE_PATH ${SOURCE_PATH}
PATCHES "${CMAKE_CURRENT_LIST_DIR}/0001-Fix-macro-definitions.patch"
"${CMAKE_CURRENT_LIST_DIR}/0002-Fix-uwp-build.patch"
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
SOURCE_PATH ${SOURCE_PATH}/gettext-runtime
PREFER_NINJA
)

vcpkg_install_cmake()
Expand Down

0 comments on commit 01ba04e

Please sign in to comment.