Skip to content

Commit

Permalink
dev-libs/date: add new 'date' C++ library
Browse files Browse the repository at this point in the history
The 'date' library is voted into C++20 and Howard Hinnants
implementation serves as a free standing library and foundation for the
standardized library.

Bug: https://bugs.gentoo.org/712236
Package-Manager: Portage-3.0.2, Repoman-2.3.23
Signed-off-by: Jonas Toth <gentoo@jonas-toth.eu>
  • Loading branch information
JonasToth committed Aug 12, 2020
1 parent 4a52857 commit 3ca089b
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev-libs/date/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DIST date-3.0.0.tar.gz 822623 BLAKE2B 438a7a5c153c7c2d695fefc95bbd474ef507af2cd8182d1e7d54d482b0128c3f9c57582ed5b40ef46d8f6f5539228d20322c684b1e1b418e5ade3b4871bf4ec1 SHA512 03ba0faef68e053aba888591b9350af1a043ef543825c80b1ca3f0dc0448697f56286e561f1a2a59e684680d7fc1e51fd24955c4cc222fe28db64f56037dc1aa
43 changes: 43 additions & 0 deletions dev-libs/date/date-3.0.0.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit cmake

DESCRIPTION="A date and time library based on the C++11/14/17 <chrono> header"
HOMEPAGE="https://github.com/HowardHinnant/date"

if [[ ${PV} == *9999 ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/HowardHinnant/${PN}"
else
SRC_URI="https://github.com/HowardHinnant/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86"
fi

LICENSE="MIT"
SLOT="0"
IUSE="test tz system_tz only_c_locale"
RESTRICT="!test? ( test )"

BDEPEND=""
DEPEND=""
RDEPEND="${DEPEND}"

src_prepare() {
eapply "${FILESDIR}"/${P}-c-locale-export.patch \
"${FILESDIR}"/${P}-version.patch
eapply_user
cmake_src_prepare
}

src_configure() {
local mycmakeargs=(
-DBUILD_TZ_LIB=$(usex tz)
-DUSE_SYSTEM_TZ_DB=$(usex system_tz)
-DENABLE_DATE_TESTING=$(usex test)
-DCOMPILE_WITH_C_LOCALE=$(usex only_c_locale)
)
cmake_src_configure
}
36 changes: 36 additions & 0 deletions dev-libs/date/date-9999.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit cmake

DESCRIPTION="A date and time library based on the C++11/14/17 <chrono> header"
HOMEPAGE="https://github.com/HowardHinnant/date"

if [[ ${PV} == *9999 ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/HowardHinnant/${PN}"
else
SRC_URI="https://github.com/HowardHinnant/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86"
fi

LICENSE="MIT"
SLOT="0"
IUSE="test tz system_tz only_c_locale"
RESTRICT="!test? ( test )"

BDEPEND=""
DEPEND=""
RDEPEND="${DEPEND}"

src_configure() {
local mycmakeargs=(
-DBUILD_TZ_LIB=$(usex tz)
-DUSE_SYSTEM_TZ_DB=$(usex system_tz)
-DENABLE_DATE_TESTING=$(usex test)
-DCOMPILE_WITH_C_LOCALE=$(usex only_c_locale)
)
cmake_src_configure
}
86 changes: 86 additions & 0 deletions dev-libs/date/files/date-3.0.0-c-locale-export.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -76,10 +76,25 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.15)
# public headers will get installed:
set_target_properties( date PROPERTIES PUBLIC_HEADER include/date/date.h )
endif ()
-target_compile_definitions( date INTERFACE
- #To workaround libstdc++ issue https://github.com/HowardHinnant/date/issues/388
- ONLY_C_LOCALE=$<IF:$<BOOL:${COMPILE_WITH_C_LOCALE}>,1,0>
- $<$<BOOL:${DISABLE_STRING_VIEW}>:HAS_STRING_VIEW=0> )
+
+# These used to be set with generator expressions,
+#
+# ONLY_C_LOCALE=$<IF:$<BOOL:${COMPILE_WITH_C_LOCALE}>,1,0>
+#
+# which expand in the output target file to, e.g.
+#
+# ONLY_C_LOCALE=$<IF:$<BOOL:FALSE>,1,0>
+#
+# This string is then (somtimes?) not correctly interpreted.
+if ( COMPILE_WITH_C_LOCALE )
+ # To workaround libstdc++ issue https://github.com/HowardHinnant/date/issues/388
+ target_compile_definitions( date INTERFACE ONLY_C_LOCALE=1 )
+else()
+ target_compile_definitions( date INTERFACE ONLY_C_LOCALE=0 )
+endif()
+if ( DISABLE_STRING_VIEW )
+ target_compile_definitions( date INTERFACE HAS_STRING_VIEW=0 )
+endif()

#[===================================================================[
tz (compiled) library
@@ -89,27 +104,40 @@ if( BUILD_TZ_LIB )
target_sources( date-tz
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>$<INSTALL_INTERFACE:include>/date/tz.h
- $<$<BOOL:${IOS}>:$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>$<INSTALL_INTERFACE:include>/date/ios.h>
PRIVATE
include/date/tz_private.h
- $<$<BOOL:${IOS}>:src/ios.mm>
src/tz.cpp )
+ if ( IOS )
+ target_sources( date-tz
+ PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>$<INSTALL_INTERFACE:include>/date/ios.h
+ PRIVATE
+ src/ios.mm )
+ endif()
add_library( date::tz ALIAS date-tz )
target_link_libraries( date-tz PUBLIC date )
target_include_directories( date-tz PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> )
- target_compile_definitions( date-tz
- PRIVATE
- AUTO_DOWNLOAD=$<IF:$<OR:$<BOOL:${USE_SYSTEM_TZ_DB}>,$<BOOL:${MANUAL_TZ_DB}>>,0,1>
- HAS_REMOTE_API=$<IF:$<OR:$<BOOL:${USE_SYSTEM_TZ_DB}>,$<BOOL:${MANUAL_TZ_DB}>>,0,1>
- $<$<AND:$<BOOL:${WIN32}>,$<BOOL:${BUILD_SHARED_LIBS}>>:DATE_BUILD_DLL=1>
- $<$<BOOL:${USE_TZ_DB_IN_DOT}>:INSTALL=.>
- PUBLIC
- USE_OS_TZDB=$<IF:$<AND:$<BOOL:${USE_SYSTEM_TZ_DB}>,$<NOT:$<BOOL:${WIN32}>>,$<NOT:$<BOOL:${MANUAL_TZ_DB}>>>,1,0>
- INTERFACE
- $<$<AND:$<BOOL:${WIN32}>,$<BOOL:${BUILD_SHARED_LIBS}>>:DATE_USE_DLL=1> )
+
+ if ( USE_SYSTEM_TZ_DB OR MANUAL_TZ_DB )
+ target_compile_definitions( date-tz PRIVATE AUTO_DOWNLOAD=0 HAS_REMOTE_API=0 )
+ else()
+ target_compile_definitions( date-tz PRIVATE AUTO_DOWNLOAD=1 HAS_REMOTE_API=1 )
+ endif()
+
+ if ( USE_SYSTEM_TZ_DB AND NOT WIN32 AND NOT MANUAL_TZ_DB )
+ target_compile_definitions( date-tz PRIVATE INSTALL=. PUBLIC USE_OS_TZDB=1 )
+ else()
+ target_compile_definitions( date-tz PUBLIC USE_OS_TZDB=0 )
+ endif()
+
+ if ( WIN32 AND BUILD_SHARED_LIBS )
+ target_compile_definitions( date-tz PUBLIC DATE_BUILD_DLL=1 )
+ endif()
+
set(TZ_HEADERS include/date/tz.h)
+
if( IOS )
list(APPEND TZ_HEADERS include/date/ios.h)
endif( )
--
13 changes: 13 additions & 0 deletions dev-libs/date/files/date-3.0.0-version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad74900..819ca5b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,7 @@

cmake_minimum_required( VERSION 3.7 )

-project( date VERSION 2.4.1 )
+project( date VERSION 3.0.0 )

include( GNUInstallDirs )

18 changes: 18 additions & 0 deletions dev-libs/date/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM 'http://www.gentoo.org/dtd/metadata.dtd'>
<pkgmetadata>
<maintainer type="person">
<email>gentoo@jonas-toth.eu</email>
<name>Jonas Toth</name>
</maintainer>
<use>
<flag name="tz">Build timezone library on top of date.h</flag>
<flag name="system_tz">Use the operating system's timezone database</flag>
<flag name="only_c_locale">Build only the C locale</flag>
</use>
<upstream>
<remote-id type="github">HowardHinnant/date</remote-id>
<bugs-to>https://github.com/HowardHinnant/date/issues</bugs-to>
<changelog>https://github.com/HowardHinnant/date/releases</changelog>
</upstream>
</pkgmetadata>

0 comments on commit 3ca089b

Please sign in to comment.