From c34786efe5093e6ddd317b763e0a5fcf03007b24 Mon Sep 17 00:00:00 2001 From: Dave Johansen Date: Mon, 29 Aug 2016 21:55:35 -0600 Subject: [PATCH] Initial RPM release --- .gitignore | 1 + fmt.spec | 111 ++++++++++++++++++++++++++++++++++++++++++ fmt_gmock_crash.patch | 25 ++++++++++ fmt_mock_locale.patch | 99 +++++++++++++++++++++++++++++++++++++ sources | 1 + 5 files changed, 237 insertions(+) create mode 100644 fmt.spec create mode 100644 fmt_gmock_crash.patch create mode 100644 fmt_mock_locale.patch diff --git a/.gitignore b/.gitignore index e69de29..6fb6561 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/fmt-3.0.0.zip diff --git a/fmt.spec b/fmt.spec new file mode 100644 index 0000000..a25c1f8 --- /dev/null +++ b/fmt.spec @@ -0,0 +1,111 @@ +Name: fmt +Version: 3.0.0 +Release: 1%{?dist} +Summary: Small, safe and fast formatting library for C++ + +License: BSD +URL: https://github.com/fmtlib/fmt +Source0: https://github.com/fmtlib/fmt/releases/download/%{version}/%{name}-%{version}.zip +# See https://github.com/fmtlib/fmt/issues/325 +Patch0: fmt_gmock_crash.patch +# See https://github.com/fmtlib/fmt/issues/329 +Patch1: fmt_mock_locale.patch + +%if 0%{?rhel} +BuildRequires: cmake3 +%else +BuildRequires: cmake +%endif + +%description +C++ Format is an open-source formatting library for C++. It can be used as a +safe alternative to printf or as a fast alternative to IOStreams. + +# This package replaces the old name of cppformat +Provides: cppformat = %{version}-%{release} +Obsoletes: cppformat < %{version}-%{release} + +%package devel +Summary: Development files for %{name} +Requires: %{name}%{?_isa} = %{version}-%{release} + +# This package replaces the old name of cppformat +Provides: cppformat-devel = %{version}-%{release} +Obsoletes: cppformat-devel < %{version}-%{release} + +%description devel +This package contains the header file for using %{name}. + +%package static +Summary: Header only development files for %{name} +Requires: %{name}-devel%{?_isa} = %{version}-%{release} + +%description static +This package contains the files for using %{name} as a header only library. + +%package doc +Summary: Documentation files for %{name} +License: Python +BuildArch: noarch + +# This package replaces the old name of cppformat +Provides: cppformat-doc = %{version}-%{release} +Obsoletes: cppformat-doc < %{version}-%{release} + +%description doc +This package contains documentation for developer documentation for %{name}. + +%prep +%autosetup -p1 + +%build +mkdir build +cd build +cmakeopts="-DFMT_LIB_DIR=%{_lib} -DFMT_CMAKE_DIR=%{_datarootdir}/cmake/%{name}" +# NOTE: Specifying CMAKE_SKIP_RPATH=OFF is so it will link properly on RHEL 6 +# See https://bugzilla.redhat.com/show_bug.cgi?id=640672 +%if 0%{?rhel}%{?fedora} == 6 +cmakeopts="$cmakeopts -DCMAKE_SKIP_RPATH=OFF" +%endif +%if 0%{?rhel} +%cmake3 \ +%else +%cmake \ +%endif + $cmakeopts .. +make %{?_smp_mflags} all + +%install +make -C build install DESTDIR=%{buildroot} + +%check +make -C build test + +%files +%{_libdir}/libfmt.so.* +%{!?_licensedir:%global license %%doc} +%license LICENSE.rst + +%files devel +%{_includedir}/fmt/ +%{_libdir}/libfmt.so +%{_datarootdir}/cmake/fmt/ + +%files static +%{_includedir}/fmt/format.cc +%{_includedir}/fmt/ostream.cc +%{_includedir}/fmt/ostream.h +%{_includedir}/fmt/posix.h +%{_includedir}/fmt/time.h + +%files doc +%doc doc/html/ +%license doc/python-license.txt + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%changelog +* Wed Aug 24 2016 Dave Johansen - 3.0.0-1 +- Initial RPM release diff --git a/fmt_gmock_crash.patch b/fmt_gmock_crash.patch new file mode 100644 index 0000000..e71ba6e --- /dev/null +++ b/fmt_gmock_crash.patch @@ -0,0 +1,25 @@ +From d00b43c592eecb69d46210ec24968ab30ea330f7 Mon Sep 17 00:00:00 2001 +From: Victor Zverovich +Date: Sat, 14 May 2016 17:58:14 -0700 +Subject: [PATCH] Workaround an issue with "delete this" in GMock and gcc 6.1.1 + +--- + test/gmock/gmock.h | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/test/gmock/gmock.h b/test/gmock/gmock.h +index 17bde1e..84f58cd 100644 +--- a/test/gmock/gmock.h ++++ b/test/gmock/gmock.h +@@ -10090,8 +10090,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase { + // threads concurrently. + Result InvokeWith(const ArgumentTuple& args) + GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { +- return static_cast( +- this->UntypedInvokeWith(&args))->GetValueAndDelete(); ++ const ResultHolder *rh = static_cast( ++ this->UntypedInvokeWith(&args)); ++ return rh ? rh->GetValueAndDelete() : Result(); + } + + // Adds and returns a default action spec for this mock function. diff --git a/fmt_mock_locale.patch b/fmt_mock_locale.patch new file mode 100644 index 0000000..0087028 --- /dev/null +++ b/fmt_mock_locale.patch @@ -0,0 +1,99 @@ +From e2a332e5df1783580c42f62eb7f4bef04d8000b2 Mon Sep 17 00:00:00 2001 +From: Victor Zverovich +Date: Thu, 19 May 2016 15:04:25 -0700 +Subject: [PATCH] Use a mock to test locale support + +--- + test/format-test.cc | 29 ++++++++++++++++++++++------- + test/gtest-extra.h | 8 +++++++- + test/posix-mock-test.cc | 6 ------ + 3 files changed, 29 insertions(+), 14 deletions(-) + +diff --git a/test/format-test.cc b/test/format-test.cc +index 31f9d57..4a0e85c 100644 +--- a/test/format-test.cc ++++ b/test/format-test.cc +@@ -43,6 +43,22 @@ + // Test that the library compiles if None is defined to 0 as done by xlib.h. + #define None 0 + ++struct LocaleMock { ++ static LocaleMock *instance; ++ ++ MOCK_METHOD0(localeconv, lconv *()); ++} *LocaleMock::instance; ++ ++namespace fmt { ++namespace std { ++using namespace ::std; ++lconv *localeconv() { ++ return LocaleMock::instance ? ++ LocaleMock::instance->localeconv() : ::std::localeconv(); ++} ++} ++} ++ + #include "fmt/format.h" + #include "fmt/time.h" + +@@ -1209,13 +1225,12 @@ TEST(FormatterTest, FormatOct) { + } + + TEST(FormatterTest, FormatIntLocale) { +-#ifndef _WIN32 +- const char *locale = "en_US.utf-8"; +-#else +- const char *locale = "English_United States"; +-#endif +- std::setlocale(LC_ALL, locale); +- EXPECT_EQ("1,234,567", format("{:n}", 1234567)); ++ ScopedMock mock; ++ lconv lc = {}; ++ char sep[] = "--"; ++ lc.thousands_sep = sep; ++ EXPECT_CALL(mock, localeconv()).WillOnce(testing::Return(&lc)); ++ EXPECT_EQ("1--234--567", format("{:n}", 1234567)); + } + + TEST(FormatterTest, FormatFloat) { +diff --git a/test/gtest-extra.h b/test/gtest-extra.h +index 649fbe2..5f7fe29 100644 +--- a/test/gtest-extra.h ++++ b/test/gtest-extra.h +@@ -29,7 +29,7 @@ + #define FMT_GTEST_EXTRA_H_ + + #include +-#include ++#include + + #include "fmt/format.h" + +@@ -172,4 +172,10 @@ std::string read(fmt::File &f, std::size_t count); + + #endif // FMT_USE_FILE_DESCRIPTORS + ++template ++struct ScopedMock : testing::StrictMock { ++ ScopedMock() { Mock::instance = this; } ++ ~ScopedMock() { Mock::instance = 0; } ++}; ++ + #endif // FMT_GTEST_EXTRA_H_ +diff --git a/test/posix-mock-test.cc b/test/posix-mock-test.cc +index 2a89a82..3eaca21 100644 +--- a/test/posix-mock-test.cc ++++ b/test/posix-mock-test.cc +@@ -453,12 +453,6 @@ TEST(BufferedFileTest, FilenoNoRetry) { + fileno_count = 0; + } + +-template +-struct ScopedMock : testing::StrictMock { +- ScopedMock() { Mock::instance = this; } +- ~ScopedMock() { Mock::instance = 0; } +-}; +- + struct TestMock { + static TestMock *instance; + } *TestMock::instance; diff --git a/sources b/sources index e69de29..7f9e8b1 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +c099561e70fa194bb03b3fd5de2d3fd0 fmt-3.0.0.zip