0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-08 21:18:57 +02:00

ircd: Add icu support if available.

This commit is contained in:
Jason Volk 2020-06-19 01:04:30 -07:00
parent 0d55f02e9c
commit daa49dde51
5 changed files with 97 additions and 3 deletions

View file

@ -1331,12 +1331,12 @@ dnl RB_CHK_SYSHEADER(unicode/utmscale.h, [UNICODE_UTMSCALE_H])
PKG_CHECK_MODULES(icuuc, [icuuc],
[
have_icuuc="yes"
dnl ICU_LIBS+=" -licuuc"
ICU_LIBS+=" -licuuc"
], [
AC_CHECK_LIB([icuuc], [_init],
[
have_icuuc="yes"
dnl ICU_LIBS+=" -licuuc"
ICU_LIBS+=" -licuuc"
], [
have_icuuc="no"
])
@ -2335,6 +2335,7 @@ dnl Units defining spirit grammars may benefit from special compiler flags due
dnl to their various complexities. The ./configure may have generated flags
dnl in $GRAMMAR_UNIT_CXXFLAGS to improve compile time and reduce debug symbol.
AC_SUBST(SPIRIT_UNIT_CPPFLAGS)
SPIRIT_UNIT_CPPFLAGS+=" $ICU_CPPFLAGS"
SPIRIT_UNIT_CPPFLAGS+=" $BOOST_CPPFLAGS"
SPIRIT_UNIT_CPPFLAGS+=" -include ircd/spirit.h"

21
include/ircd/icu.h Normal file
View file

@ -0,0 +1,21 @@
// The Construct
//
// Copyright (C) The Construct Developers, Authors & Contributors
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_ICU_H
/// International Components for Unicode
namespace ircd::icu
{
IRCD_EXCEPTION(ircd::error, error)
extern const info::versions version_api, version_abi;
extern const info::versions unicode_version_api, unicode_version_abi;
}

View file

@ -52,11 +52,12 @@
#include "run.h"
#include "demangle.h"
#include "backtrace.h"
#include "info.h"
#include "icu.h"
#include "locale.h"
#include "time.h"
#include "lex_cast.h"
#include "logger.h"
#include "info.h"
#include "sys.h"
#include "fpe.h"
#include "rand.h"

View file

@ -69,6 +69,7 @@ libircd_la_LDFLAGS = \
$(AM_LDFLAGS) \
@ROCKSDB_LDFLAGS@ \
@JS_LDFLAGS@ \
@ICU_LDFLAGS@ \
@BOOST_LDFLAGS@ \
@SSL_LDFLAGS@ \
@PBC_LDFLAGS@ \
@ -84,6 +85,7 @@ libircd_la_LDFLAGS = \
libircd_la_LIBADD = \
@ROCKSDB_LIBS@ \
@JS_LIBS@ \
@ICU_LIBS@ \
@BOOST_LIBS@ \
@PBC_LIBS@ \
@SSL_LIBS@ \
@ -119,6 +121,7 @@ libircd_la_SOURCES += util.cc
libircd_la_SOURCES += demangle.cc
libircd_la_SOURCES += backtrace.cc
libircd_la_SOURCES += fpe.cc
libircd_la_SOURCES += icu.cc
libircd_la_SOURCES += locale.cc
libircd_la_SOURCES += timedate.cc
libircd_la_SOURCES += lex_cast.cc

68
ircd/icu.cc Normal file
View file

@ -0,0 +1,68 @@
// The Construct
//
// Copyright (C) The Construct Developers, Authors & Contributors
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#if __has_include(<unicode/uversion.h>)
#include <unicode/uversion.h>
#endif
#if __has_include(<unicode/uchar.h>)
#include <unicode/uchar.h>
#endif
decltype(ircd::icu::version_api)
ircd::icu::version_api
{
"icu", info::versions::API, 0,
#if __has_include(<unicode/uversion.h>)
{
U_ICU_VERSION_MAJOR_NUM,
U_ICU_VERSION_MINOR_NUM,
U_ICU_VERSION_PATCHLEVEL_NUM,
},
U_ICU_VERSION
#endif
};
decltype(ircd::icu::version_abi)
ircd::icu::version_abi
{
"icu", info::versions::ABI, 0, {0}, []
(auto &v, const mutable_buffer &s)
{
#if __has_include(<unicode/uversion.h>)
UVersionInfo info;
u_getVersion(info);
u_versionToString(info, data(s));
#endif
}
};
decltype(ircd::icu::unicode_version_api)
ircd::icu::unicode_version_api
{
"unicode", info::versions::API, 0, {0},
#if __has_include(<unicode/uchar.h>)
U_UNICODE_VERSION
#endif
};
decltype(ircd::icu::unicode_version_abi)
ircd::icu::unicode_version_abi
{
"unicode", info::versions::ABI, 0, {0}, []
(auto &v, const mutable_buffer &s)
{
#if __has_include(<unicode/uchar.h>)
UVersionInfo info;
u_getUnicodeVersion(info);
u_versionToString(info, data(s));
#endif
}
};