diff options
author | Aleksandar Trifunovic | 2018-06-15 11:30:37 +0200 |
---|---|---|
committer | Aleksandar Trifunovic | 2018-06-15 11:30:37 +0200 |
commit | a8fd971ce7b11407031b2e63f0dcbdab95ff0870 (patch) | |
tree | 9f3f2f38200fe6030f83aa07a9b5f6f84ebeacbe | |
download | aur-a8fd971ce7b11407031b2e63f0dcbdab95ff0870.tar.gz |
v1.0.0
-rw-r--r-- | .SRCINFO | 18 | ||||
-rw-r--r-- | PKGBUILD | 45 | ||||
-rw-r--r-- | gcc_unsigned_error.patch | 174 | ||||
-rw-r--r-- | use_system_catch2.patch | 47 |
4 files changed, 284 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..0c17cc22d2c4 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,18 @@ +pkgbase = microsoft-gsl + pkgdesc = C++ Core Guidelines Support Library + pkgver = 1.0.0 + pkgrel = 1 + url = https://github.com/Microsoft/GSL + arch = any + license = MIT + makedepends = cmake + makedepends = catch2 + source = https://github.com/Microsoft/GSL/archive/v1.0.0.tar.gz + source = gcc_unsigned_error.patch + source = use_system_catch2.patch + sha256sums = 9694b04cd78e5b1a769868f19fdd9eea2002de3d4c3a81a1b769209364543c36 + sha256sums = c558af38ad46d26b65f0d4d7091fd0b034ffde860b5c5546cda7c43942d93b4b + sha256sums = 984e53dbccf938725519be8fd0b46c67f6f60d2d573a6b0ab82fbe94fce3f43c + +pkgname = microsoft-gsl + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..1005cd1893dd --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,45 @@ +# Maintainer: Aleksandar Trifunović <akstrfn at gmail dot com> + +_pkgname=GSL +pkgname=microsoft-gsl +pkgver=1.0.0 +pkgrel=1 +pkgdesc="C++ Core Guidelines Support Library" +arch=('any') +url="https://github.com/Microsoft/GSL" +license=('MIT') +makedepends=('cmake' 'catch2') +source=("https://github.com/Microsoft/GSL/archive/v${pkgver}.tar.gz" + "gcc_unsigned_error.patch" + "use_system_catch2.patch") +sha256sums=('9694b04cd78e5b1a769868f19fdd9eea2002de3d4c3a81a1b769209364543c36' + 'c558af38ad46d26b65f0d4d7091fd0b034ffde860b5c5546cda7c43942d93b4b' + '984e53dbccf938725519be8fd0b46c67f6f60d2d573a6b0ab82fbe94fce3f43c') + +prepare() { + cd "$_pkgname-$pkgver" + patch -Np1 -i "$srcdir/gcc_unsigned_error.patch" + patch -Np1 -i "$srcdir/use_system_catch2.patch" +} + +build() { + cd "$_pkgname-$pkgver" + cmake -H. -Bbuild \ + -DCMAKE_CXX_FLAGS:STRING="${CXXFLAGS}" \ + -DCMAKE_EXE_LINKER_FLAGS:STRING="${LDFLAGS}" \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + + cmake --build build +} + +check() { + cd "$_pkgname-$pkgver" + cmake --build build -- test +} + +package() { + cd "$_pkgname-$pkgver" + cmake --build build -- DESTDIR="$pkgdir/" install + install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} diff --git a/gcc_unsigned_error.patch b/gcc_unsigned_error.patch new file mode 100644 index 000000000000..e5490d66a547 --- /dev/null +++ b/gcc_unsigned_error.patch @@ -0,0 +1,174 @@ +diff --git a/include/gsl/multi_span b/include/gsl/multi_span +index 65e65a1..f697093 100644 +--- a/include/gsl/multi_span ++++ b/include/gsl/multi_span +@@ -51,6 +51,16 @@ + #endif // _MSC_VER < 1910 + #endif // _MSC_VER + ++// GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t) ++// While there is a conversion from signed to unsigned, it happens at ++// compiletime, so the compiler wouldn't have to warn indiscriminently, but ++// could check if the source value actually doesn't fit into the target type ++// and only warn in those cases. ++#if __GNUC__ > 6 ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wsign-conversion" ++#endif ++ + #ifdef GSL_THROW_ON_CONTRACT_VIOLATION + #define GSL_NOEXCEPT /*noexcept*/ + #else +@@ -2225,4 +2235,8 @@ general_span_iterator<Span> operator+(typename general_span_iterator<Span>::diff + + #endif // _MSC_VER + ++#if __GNUC__ > 6 ++#pragma GCC diagnostic pop ++#endif // __GNUC__ > 6 ++ + #endif // GSL_MULTI_SPAN_H +diff --git a/include/gsl/span b/include/gsl/span +index 6dd1c1f..2fa9cc5 100644 +--- a/include/gsl/span ++++ b/include/gsl/span +@@ -58,6 +58,16 @@ + + #endif // _MSC_VER + ++// GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t) ++// While there is a conversion from signed to unsigned, it happens at ++// compiletime, so the compiler wouldn't have to warn indiscriminently, but ++// could check if the source value actually doesn't fit into the target type ++// and only warn in those cases. ++#if __GNUC__ > 6 ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wsign-conversion" ++#endif ++ + namespace gsl + { + +@@ -191,6 +201,11 @@ namespace details + return ret += n; + } + ++ friend constexpr span_iterator operator+(difference_type n, span_iterator const& rhs) ++ { ++ return rhs + n; ++ } ++ + constexpr span_iterator& operator+=(difference_type n) + { + Expects((index_ + n) >= 0 && (index_ + n) <= span_->size()); +@@ -253,27 +268,49 @@ namespace details + return !(rhs > lhs); + } + ++#ifdef _MSC_VER ++ // MSVC++ iterator debugging support; allows STL algorithms in 15.8+ ++ // to unwrap span_iterator to a pointer type after a range check in STL ++ // algorithm calls ++ friend constexpr void _Verify_range(span_iterator lhs, ++ span_iterator rhs) noexcept ++ { // test that [lhs, rhs) forms a valid range inside an STL algorithm ++ Expects(lhs.span_ == rhs.span_ // range spans have to match ++ && lhs.index_ <= rhs.index_); // range must not be transposed ++ } ++ ++ constexpr void _Verify_offset(const difference_type n) const noexcept ++ { // test that the iterator *this + n is a valid range in an STL ++ // algorithm call ++ Expects((index_ + n) >= 0 && (index_ + n) <= span_->size()); ++ } ++ ++ constexpr pointer _Unwrapped() const noexcept ++ { // after seeking *this to a high water mark, or using one of the ++ // _Verify_xxx functions above, unwrap this span_iterator to a raw ++ // pointer ++ return span_->data() + index_; ++ } ++ ++ // Tell the STL that span_iterator should not be unwrapped if it can't ++ // validate in advance, even in release / optimized builds: ++#if defined(GSL_USE_STATIC_CONSTEXPR_WORKAROUND) ++ static constexpr const bool _Unwrap_when_unverified = false; ++#else ++ static constexpr bool _Unwrap_when_unverified = false; ++#endif ++ constexpr void _Seek_to(const pointer p) noexcept ++ { // adjust the position of *this to previously verified location p ++ // after _Unwrapped ++ index_ = p - span_->data(); ++ } ++#endif ++ + protected: + const Span* span_ = nullptr; + std::ptrdiff_t index_ = 0; + }; + +- template <class Span, bool IsConst> +- constexpr span_iterator<Span, IsConst> +- operator+(typename span_iterator<Span, IsConst>::difference_type n, +- span_iterator<Span, IsConst> rhs) +- { +- return rhs + n; +- } +- +- template <class Span, bool IsConst> +- constexpr span_iterator<Span, IsConst> +- operator-(typename span_iterator<Span, IsConst>::difference_type n, +- span_iterator<Span, IsConst> rhs) +- { +- return rhs - n; +- } +- + template <std::ptrdiff_t Ext> + class extent_type + { +@@ -418,7 +455,7 @@ public: + + ~span() noexcept = default; + constexpr span& operator=(const span& other) noexcept = default; +- ++ + // [span.sub], span subviews + template <std::ptrdiff_t Count> + constexpr span<element_type, Count> first() const +@@ -493,10 +530,16 @@ public: + constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator{cend()}; } + constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator{cbegin()}; } + ++#ifdef _MSC_VER ++ // Tell MSVC how to unwrap spans in range-based-for ++ constexpr pointer _Unchecked_begin() const noexcept { return data(); } ++ constexpr pointer _Unchecked_end() const noexcept { return data() + size(); } ++#endif // _MSC_VER ++ + private: + + // Needed to remove unnecessary null check in subspans +- struct KnownNotNull ++ struct KnownNotNull + { + pointer p; + }; +@@ -508,7 +551,7 @@ private: + class storage_type : public ExtentType + { + public: +- // KnownNotNull parameter is needed to remove unnecessary null check ++ // KnownNotNull parameter is needed to remove unnecessary null check + // in subspans and constructors from arrays + template <class OtherExtentType> + constexpr storage_type(KnownNotNull data, OtherExtentType ext) : ExtentType(ext), data_(data.p) +@@ -716,4 +759,8 @@ constexpr ElementType& at(span<ElementType, Extent> s, index i) + #pragma warning(pop) + #endif // _MSC_VER + ++#if __GNUC__ > 6 ++#pragma GCC diagnostic pop ++#endif // __GNUC__ > 6 ++ + #endif // GSL_SPAN_H diff --git a/use_system_catch2.patch b/use_system_catch2.patch new file mode 100644 index 000000000000..cc7eef3697d7 --- /dev/null +++ b/use_system_catch2.patch @@ -0,0 +1,47 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index dcb6d89..e0c68f2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.7) + + project(GSL CXX) + +-include(ExternalProject) +-find_package(Git) +- + # creates a library GSL which is an interface (header files only) + add_library(GSL INTERFACE) + +diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt +index 0e08d77..7d0f0f0 100644 +--- a/tests/CMakeLists.txt ++++ b/tests/CMakeLists.txt +@@ -5,26 +5,8 @@ project(GSLTests CXX) + # will make visual studio generated project group files + set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +-list(APPEND CATCH_CMAKE_ARGS +- "-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/external" +- "-DNO_SELFTEST=true" +-) +- +-if(GIT_FOUND) +- # add catch +- ExternalProject_Add( +- catch +- PREFIX ${CMAKE_BINARY_DIR}/catch +- GIT_REPOSITORY https://github.com/catchorg/Catch2.git +- GIT_TAG v2.0.1 +- CMAKE_ARGS ${CATCH_CMAKE_ARGS} +- LOG_DOWNLOAD 1 +- UPDATE_DISCONNECTED 1 +- ) +-else() +- # assume catch is installed in a system directory +- add_custom_target(catch) +-endif() ++# assume catch is installed in a system directory ++add_custom_target(catch) + + # this interface adds compile options to how the tests are run + # please try to keep entries ordered =) |