diff options
author | Peter Marko <peter.marko@siemens.com> | 2024-03-28 00:06:47 +0100 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2024-03-27 18:10:41 -0700 |
commit | a0a114361758cd07143c6d960dde311479e79d27 (patch) | |
tree | eae3360cedd8d514c04c1b1260a93e5a0d7f35fa /meta-oe/recipes-devtools | |
parent | b1ed6a24f8669dad756bcb7ff50d37212e2533de (diff) | |
download | meta-openembedded-a0a114361758cd07143c6d960dde311479e79d27.tar.gz |
microsoft-gsl: add new recipe including ptest
The Guidelines Support Library (GSL) contains functions
and types that are suggested for use by the C++ Core Guidelines
maintained by the Standard C++ Foundation.
This repo contains Microsoft's implementation of GSL.
Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe/recipes-devtools')
5 files changed, 295 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0001-Fix-initialization-in-test-1140.patch b/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0001-Fix-initialization-in-test-1140.patch new file mode 100644 index 000000000..84a585d3c --- /dev/null +++ b/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0001-Fix-initialization-in-test-1140.patch | |||
@@ -0,0 +1,113 @@ | |||
1 | From 1b4d42ca2e97061042ec44a0b34ceb176c78c7e1 Mon Sep 17 00:00:00 2001 | ||
2 | From: d-winsor <danwin@microsoft.com> | ||
3 | Date: Mon, 26 Feb 2024 13:17:12 -0800 | ||
4 | Subject: [PATCH] Fix initialization in test (#1140) | ||
5 | |||
6 | * Suppress unsafe-buffer-usage | ||
7 | |||
8 | Upstream-Status: Backport [https://github.com/microsoft/GSL/commit/1b4d42ca2e97061042ec44a0b34ceb176c78c7e1] | ||
9 | |||
10 | Signed-off-by: Peter Marko <peter.marko@siemens.com> | ||
11 | --- | ||
12 | include/gsl/span | 10 ++++++++++ | ||
13 | include/gsl/util | 10 ++++++++++ | ||
14 | tests/CMakeLists.txt | 10 ++++++++++ | ||
15 | tests/span_tests.cpp | 2 +- | ||
16 | 4 files changed, 31 insertions(+), 1 deletion(-) | ||
17 | |||
18 | diff --git a/include/gsl/span b/include/gsl/span | ||
19 | index cc8a7b9..d254e4d 100644 | ||
20 | --- a/include/gsl/span | ||
21 | +++ b/include/gsl/span | ||
22 | @@ -58,6 +58,12 @@ | ||
23 | #pragma GCC diagnostic ignored "-Wsign-conversion" | ||
24 | #endif | ||
25 | |||
26 | +// Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks | ||
27 | +#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
28 | +#pragma clang diagnostic push | ||
29 | +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" | ||
30 | +#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
31 | + | ||
32 | namespace gsl | ||
33 | { | ||
34 | |||
35 | @@ -818,4 +824,8 @@ as_writable_bytes(span<ElementType, Extent> s) noexcept | ||
36 | #pragma GCC diagnostic pop | ||
37 | #endif // __GNUC__ > 6 | ||
38 | |||
39 | +#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
40 | +#pragma clang diagnostic pop | ||
41 | +#endif | ||
42 | + | ||
43 | #endif // GSL_SPAN_H | ||
44 | diff --git a/include/gsl/util b/include/gsl/util | ||
45 | index a215bad..11735a8 100644 | ||
46 | --- a/include/gsl/util | ||
47 | +++ b/include/gsl/util | ||
48 | @@ -39,6 +39,12 @@ | ||
49 | |||
50 | #endif // _MSC_VER | ||
51 | |||
52 | +// Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks | ||
53 | +#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
54 | +#pragma clang diagnostic push | ||
55 | +#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" | ||
56 | +#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
57 | + | ||
58 | #if defined(__cplusplus) && (__cplusplus >= 201703L) | ||
59 | #define GSL_NODISCARD [[nodiscard]] | ||
60 | #else | ||
61 | @@ -157,4 +163,8 @@ constexpr auto at(std::span<T, extent> sp, const index i) -> decltype(sp[sp.size | ||
62 | |||
63 | #endif // _MSC_VER | ||
64 | |||
65 | +#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
66 | +#pragma clang diagnostic pop | ||
67 | +#endif | ||
68 | + | ||
69 | #endif // GSL_UTIL_H | ||
70 | diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt | ||
71 | index cab4e56..20de9e1 100644 | ||
72 | --- a/tests/CMakeLists.txt | ||
73 | +++ b/tests/CMakeLists.txt | ||
74 | @@ -167,6 +167,11 @@ else() | ||
75 | > | ||
76 | ) | ||
77 | endif(MSVC) | ||
78 | +check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER) | ||
79 | +if (WARN_UNSAFE_BUFFER) | ||
80 | + # This test uses very greedy heuristics such as "no pointer arithmetic on raw buffer" | ||
81 | + target_compile_options(gsl_tests_config INTERFACE "-Wno-unsafe-buffer-usage") | ||
82 | +endif() | ||
83 | |||
84 | # for tests to find the gtest header | ||
85 | target_include_directories(gsl_tests_config SYSTEM INTERFACE | ||
86 | @@ -267,6 +272,11 @@ else() | ||
87 | > | ||
88 | ) | ||
89 | endif(MSVC) | ||
90 | +check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER) | ||
91 | +if (WARN_UNSAFE_BUFFER) | ||
92 | + # This test uses very greedy heuristics such as "no pointer arithmetic on raw buffer" | ||
93 | + target_compile_options(gsl_tests_config_noexcept INTERFACE "-Wno-unsafe-buffer-usage") | ||
94 | +endif() | ||
95 | |||
96 | add_executable(gsl_noexcept_tests no_exception_ensure_tests.cpp) | ||
97 | target_link_libraries(gsl_noexcept_tests | ||
98 | diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp | ||
99 | index 33ccf56..3c1dfe5 100644 | ||
100 | --- a/tests/span_tests.cpp | ||
101 | +++ b/tests/span_tests.cpp | ||
102 | @@ -330,7 +330,7 @@ TEST(span_test, from_array_constructor) | ||
103 | EXPECT_TRUE(s.data() == std::addressof(arr2d[0])); | ||
104 | } | ||
105 | |||
106 | - int arr3d[2][3][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; | ||
107 | + int arr3d[2][3][2] = { { {1, 2}, {3, 4}, {5, 6} }, { {7, 8}, {9, 10}, {11, 12} } }; | ||
108 | |||
109 | #ifdef CONFIRM_COMPILATION_ERRORS | ||
110 | { | ||
111 | -- | ||
112 | 2.30.2 | ||
113 | |||
diff --git a/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0002-Fix-gcc-build-problem.patch b/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0002-Fix-gcc-build-problem.patch new file mode 100644 index 000000000..2f7542c62 --- /dev/null +++ b/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0002-Fix-gcc-build-problem.patch | |||
@@ -0,0 +1,82 @@ | |||
1 | From aa4fd1f57794964640005900c2b47af1a0940b7b Mon Sep 17 00:00:00 2001 | ||
2 | From: Werner Henze <w.henze@avm.de> | ||
3 | Date: Fri, 1 Mar 2024 15:53:50 +0100 | ||
4 | Subject: [PATCH] Fix gcc build problem | ||
5 | |||
6 | Closes issue #1148 by fixing problems introduced in PR #1140. | ||
7 | |||
8 | Upstream-Status: Submitted [https://github.com/microsoft/GSL/pull/1149] | ||
9 | |||
10 | Signed-off-by: Peter Marko <peter.marko@siemens.com> | ||
11 | --- | ||
12 | include/gsl/span | 12 ++++++++---- | ||
13 | include/gsl/util | 12 ++++++++---- | ||
14 | 2 files changed, 16 insertions(+), 8 deletions(-) | ||
15 | |||
16 | diff --git a/include/gsl/span b/include/gsl/span | ||
17 | index 0de2932..d2ef9f7 100644 | ||
18 | --- a/include/gsl/span | ||
19 | +++ b/include/gsl/span | ||
20 | @@ -59,10 +59,12 @@ | ||
21 | #endif | ||
22 | |||
23 | // Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks | ||
24 | -#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
25 | +#if defined(__clang__) | ||
26 | +#if __has_warning("-Wunsafe-buffer-usage") | ||
27 | #pragma clang diagnostic push | ||
28 | #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" | ||
29 | -#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
30 | +#endif // __has_warning("-Wunsafe-buffer-usage") | ||
31 | +#endif // defined(__clang__) | ||
32 | |||
33 | namespace gsl | ||
34 | { | ||
35 | @@ -824,8 +826,10 @@ as_writable_bytes(span<ElementType, Extent> s) noexcept | ||
36 | #pragma GCC diagnostic pop | ||
37 | #endif // __GNUC__ > 6 | ||
38 | |||
39 | -#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
40 | +#if defined(__clang__) | ||
41 | +#if __has_warning("-Wunsafe-buffer-usage") | ||
42 | #pragma clang diagnostic pop | ||
43 | -#endif | ||
44 | +#endif // __has_warning("-Wunsafe-buffer-usage") | ||
45 | +#endif // defined(__clang__) | ||
46 | |||
47 | #endif // GSL_SPAN_H | ||
48 | diff --git a/include/gsl/util b/include/gsl/util | ||
49 | index b853017..26b2f5f 100644 | ||
50 | --- a/include/gsl/util | ||
51 | +++ b/include/gsl/util | ||
52 | @@ -40,10 +40,12 @@ | ||
53 | #endif // _MSC_VER | ||
54 | |||
55 | // Turn off clang unsafe buffer warnings as all accessed are guarded by runtime checks | ||
56 | -#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
57 | +#if defined(__clang__) | ||
58 | +#if __has_warning("-Wunsafe-buffer-usage") | ||
59 | #pragma clang diagnostic push | ||
60 | #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" | ||
61 | -#endif // defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
62 | +#endif // __has_warning("-Wunsafe-buffer-usage") | ||
63 | +#endif // defined(__clang__) | ||
64 | |||
65 | #if defined(__cplusplus) && (__cplusplus >= 201703L) | ||
66 | #define GSL_NODISCARD [[nodiscard]] | ||
67 | @@ -163,8 +165,10 @@ constexpr auto at(std::span<T, extent> sp, const index i) -> decltype(sp[sp.size | ||
68 | |||
69 | #endif // _MSC_VER | ||
70 | |||
71 | -#if defined(__clang__) && __has_warning("-Wunsafe-buffer-usage") | ||
72 | +#if defined(__clang__) | ||
73 | +#if __has_warning("-Wunsafe-buffer-usage") | ||
74 | #pragma clang diagnostic pop | ||
75 | -#endif | ||
76 | +#endif // __has_warning("-Wunsafe-buffer-usage") | ||
77 | +#endif // defined(__clang__) | ||
78 | |||
79 | #endif // GSL_UTIL_H | ||
80 | -- | ||
81 | 2.30.2 | ||
82 | |||
diff --git a/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0003-Adapt-check_cxx_compiler_flag-to-cmake-3.0.2.patch b/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0003-Adapt-check_cxx_compiler_flag-to-cmake-3.0.2.patch new file mode 100644 index 000000000..ed057f524 --- /dev/null +++ b/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/0003-Adapt-check_cxx_compiler_flag-to-cmake-3.0.2.patch | |||
@@ -0,0 +1,53 @@ | |||
1 | From 85e1c38bcf84bd4e2ce63ef74f0cfa1f5e92261e Mon Sep 17 00:00:00 2001 | ||
2 | From: Peter Marko <peter.marko@siemens.com> | ||
3 | Date: Wed, 27 Mar 2024 23:46:31 +0100 | ||
4 | Subject: [PATCH] Adapt check_cxx_compiler_flag to cmake 3.0.2 | ||
5 | |||
6 | Backporting commits which are upgrading cmake_minimum_required and | ||
7 | include check_cxx_compiler_flag have too many additional changes. | ||
8 | |||
9 | Let's just do a simple adaptation of our backported patch so | ||
10 | it works with older cmake version instead. | ||
11 | |||
12 | This can be safely removed when recipe version is upgraded. | ||
13 | |||
14 | Upstream-Status: Inappropriate | ||
15 | |||
16 | Signed-off-by: Peter Marko <peter.marko@siemens.com> | ||
17 | --- | ||
18 | tests/CMakeLists.txt | 5 +++-- | ||
19 | 1 file changed, 3 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt | ||
22 | index 20de9e1..54c3ac5 100644 | ||
23 | --- a/tests/CMakeLists.txt | ||
24 | +++ b/tests/CMakeLists.txt | ||
25 | @@ -5,6 +5,7 @@ enable_testing() # again, for support standalone testing | ||
26 | |||
27 | include(FindPkgConfig) | ||
28 | include(ExternalProject) | ||
29 | +include(CheckCXXCompilerFlag) | ||
30 | |||
31 | # will make visual studio generated project group files | ||
32 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
33 | @@ -167,7 +168,7 @@ else() | ||
34 | > | ||
35 | ) | ||
36 | endif(MSVC) | ||
37 | -check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER) | ||
38 | +CHECK_CXX_COMPILER_FLAG("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER) | ||
39 | if (WARN_UNSAFE_BUFFER) | ||
40 | # This test uses very greedy heuristics such as "no pointer arithmetic on raw buffer" | ||
41 | target_compile_options(gsl_tests_config INTERFACE "-Wno-unsafe-buffer-usage") | ||
42 | @@ -272,7 +273,7 @@ else() | ||
43 | > | ||
44 | ) | ||
45 | endif(MSVC) | ||
46 | -check_cxx_compiler_flag("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER) | ||
47 | +CHECK_CXX_COMPILER_FLAG("-Wno-unsafe-buffer-usage" WARN_UNSAFE_BUFFER) | ||
48 | if (WARN_UNSAFE_BUFFER) | ||
49 | # This test uses very greedy heuristics such as "no pointer arithmetic on raw buffer" | ||
50 | target_compile_options(gsl_tests_config_noexcept INTERFACE "-Wno-unsafe-buffer-usage") | ||
51 | -- | ||
52 | 2.30.2 | ||
53 | |||
diff --git a/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest b/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest new file mode 100644 index 000000000..2d5bdf4ff --- /dev/null +++ b/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl/run-ptest | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | gsl_tests && echo "PASS: gsl_tests" || echo "FAIL: gsl_tests" | ||
4 | gsl_noexcept_tests && echo "PASS: gsl_noexcept_tests" || echo "FAIL: gsl_noexcept_tests" | ||
diff --git a/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb b/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb new file mode 100644 index 000000000..7fc31486f --- /dev/null +++ b/meta-oe/recipes-devtools/microsoft-gsl/microsoft-gsl_4.0.0.bb | |||
@@ -0,0 +1,43 @@ | |||
1 | SUMMARY = "GSL: Guidelines Support Library" | ||
2 | DESCRIPTION = "The Guidelines Support Library (GSL) contains functions \ | ||
3 | and types that are suggested for use by the C++ Core Guidelines \ | ||
4 | maintained by the Standard C++ Foundation. \ | ||
5 | This repo contains Microsoft's implementation of GSL." | ||
6 | HOMEPAGE = "https://github.com/microsoft/GSL" | ||
7 | |||
8 | LICENSE = "MIT" | ||
9 | LIC_FILES_CHKSUM = "file://LICENSE;md5=363055e71e77071107ba2bb9a54bd9a7" | ||
10 | |||
11 | SRC_URI = "git://github.com/microsoft/GSL.git;protocol=https;branch=main \ | ||
12 | file://run-ptest \ | ||
13 | file://0001-Fix-initialization-in-test-1140.patch \ | ||
14 | file://0002-Fix-gcc-build-problem.patch \ | ||
15 | file://0003-Adapt-check_cxx_compiler_flag-to-cmake-3.0.2.patch \ | ||
16 | " | ||
17 | SRCREV = "a3534567187d2edc428efd3f13466ff75fe5805c" | ||
18 | |||
19 | S = "${WORKDIR}/git" | ||
20 | |||
21 | inherit cmake pkgconfig ptest | ||
22 | |||
23 | # this is header-only library | ||
24 | ALLOW_EMPTY:${PN} = "1" | ||
25 | |||
26 | PACKAGECONFIG ??= "${@bb.utils.contains('PTEST_ENABLED', '1', 'ptest','', d)}" | ||
27 | PACKAGECONFIG[ptest] = "-DGSL_TEST=ON,-DGSL_TEST=OFF,googletest" | ||
28 | |||
29 | # clang disagrees with https://github.com/google/googletest/pull/3457 | ||
30 | CXXFLAGS:append:toolchain-clang = " -Wno-error=switch-default" | ||
31 | |||
32 | do_install_ptest() { | ||
33 | install -d ${D}${bindir} | ||
34 | install -m 0755 ${B}/tests/gsl_tests ${D}${bindir} | ||
35 | install -m 0755 ${B}/tests/gsl_noexcept_tests ${D}${bindir} | ||
36 | } | ||
37 | |||
38 | FILES:${PN}-ptest = "${bindir}/gsl*_tests" | ||
39 | |||
40 | # there is already other gsl recipe, so recipe name does not match the real component name | ||
41 | CVE_PRODUCT = "microsoft:gsl" | ||
42 | |||
43 | BBCLASSEXTEND = "native nativesdk" | ||