From 40479c2d3d1e9bd3eb213aba537570d28d37d8a2 Mon Sep 17 00:00:00 2001 From: thegeorg Date: Thu, 8 Jun 2023 13:56:44 +0300 Subject: Restrict direct usages of google benchmarking library Forbid PEERDIR-ing Google Benchmark from modules other than G_BENCHMARK. --- library/cpp/testing/CMakeLists.txt | 2 +- .../testing/gbenchmark/CMakeLists.darwin-x86_64.txt | 19 +++++++++++++++++++ .../testing/gbenchmark/CMakeLists.linux-aarch64.txt | 20 ++++++++++++++++++++ .../testing/gbenchmark/CMakeLists.linux-x86_64.txt | 20 ++++++++++++++++++++ library/cpp/testing/gbenchmark/CMakeLists.txt | 17 +++++++++++++++++ .../testing/gbenchmark/CMakeLists.windows-x86_64.txt | 19 +++++++++++++++++++ library/cpp/testing/gbenchmark/benchmark.h | 3 +++ library/cpp/testing/gbenchmark/main.cpp | 16 ++++++++++++++++ .../gbenchmark_main/CMakeLists.darwin-x86_64.txt | 19 ------------------- .../gbenchmark_main/CMakeLists.linux-aarch64.txt | 20 -------------------- .../gbenchmark_main/CMakeLists.linux-x86_64.txt | 20 -------------------- library/cpp/testing/gbenchmark_main/CMakeLists.txt | 17 ----------------- .../gbenchmark_main/CMakeLists.windows-x86_64.txt | 19 ------------------- library/cpp/testing/gbenchmark_main/main.cpp | 16 ---------------- 14 files changed, 115 insertions(+), 112 deletions(-) create mode 100644 library/cpp/testing/gbenchmark/CMakeLists.darwin-x86_64.txt create mode 100644 library/cpp/testing/gbenchmark/CMakeLists.linux-aarch64.txt create mode 100644 library/cpp/testing/gbenchmark/CMakeLists.linux-x86_64.txt create mode 100644 library/cpp/testing/gbenchmark/CMakeLists.txt create mode 100644 library/cpp/testing/gbenchmark/CMakeLists.windows-x86_64.txt create mode 100644 library/cpp/testing/gbenchmark/benchmark.h create mode 100644 library/cpp/testing/gbenchmark/main.cpp delete mode 100644 library/cpp/testing/gbenchmark_main/CMakeLists.darwin-x86_64.txt delete mode 100644 library/cpp/testing/gbenchmark_main/CMakeLists.linux-aarch64.txt delete mode 100644 library/cpp/testing/gbenchmark_main/CMakeLists.linux-x86_64.txt delete mode 100644 library/cpp/testing/gbenchmark_main/CMakeLists.txt delete mode 100644 library/cpp/testing/gbenchmark_main/CMakeLists.windows-x86_64.txt delete mode 100644 library/cpp/testing/gbenchmark_main/main.cpp (limited to 'library/cpp/testing') diff --git a/library/cpp/testing/CMakeLists.txt b/library/cpp/testing/CMakeLists.txt index 38ecc236cf3..70c5d112f1c 100644 --- a/library/cpp/testing/CMakeLists.txt +++ b/library/cpp/testing/CMakeLists.txt @@ -8,7 +8,7 @@ add_subdirectory(benchmark) add_subdirectory(common) -add_subdirectory(gbenchmark_main) +add_subdirectory(gbenchmark) add_subdirectory(gmock_in_unittest) add_subdirectory(gtest) add_subdirectory(gtest_extensions) diff --git a/library/cpp/testing/gbenchmark/CMakeLists.darwin-x86_64.txt b/library/cpp/testing/gbenchmark/CMakeLists.darwin-x86_64.txt new file mode 100644 index 00000000000..6b4fdb826d8 --- /dev/null +++ b/library/cpp/testing/gbenchmark/CMakeLists.darwin-x86_64.txt @@ -0,0 +1,19 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-testing-gbenchmark) +target_link_libraries(cpp-testing-gbenchmark PUBLIC + contrib-libs-cxxsupp + yutil + restricted-google-benchmark + cpp-testing-hook +) +target_sources(cpp-testing-gbenchmark PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark/main.cpp +) diff --git a/library/cpp/testing/gbenchmark/CMakeLists.linux-aarch64.txt b/library/cpp/testing/gbenchmark/CMakeLists.linux-aarch64.txt new file mode 100644 index 00000000000..f3cdb5fbc1e --- /dev/null +++ b/library/cpp/testing/gbenchmark/CMakeLists.linux-aarch64.txt @@ -0,0 +1,20 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-testing-gbenchmark) +target_link_libraries(cpp-testing-gbenchmark PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + restricted-google-benchmark + cpp-testing-hook +) +target_sources(cpp-testing-gbenchmark PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark/main.cpp +) diff --git a/library/cpp/testing/gbenchmark/CMakeLists.linux-x86_64.txt b/library/cpp/testing/gbenchmark/CMakeLists.linux-x86_64.txt new file mode 100644 index 00000000000..f3cdb5fbc1e --- /dev/null +++ b/library/cpp/testing/gbenchmark/CMakeLists.linux-x86_64.txt @@ -0,0 +1,20 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-testing-gbenchmark) +target_link_libraries(cpp-testing-gbenchmark PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + restricted-google-benchmark + cpp-testing-hook +) +target_sources(cpp-testing-gbenchmark PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark/main.cpp +) diff --git a/library/cpp/testing/gbenchmark/CMakeLists.txt b/library/cpp/testing/gbenchmark/CMakeLists.txt new file mode 100644 index 00000000000..f8b31df0c11 --- /dev/null +++ b/library/cpp/testing/gbenchmark/CMakeLists.txt @@ -0,0 +1,17 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-aarch64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + include(CMakeLists.darwin-x86_64.txt) +elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA) + include(CMakeLists.windows-x86_64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-x86_64.txt) +endif() diff --git a/library/cpp/testing/gbenchmark/CMakeLists.windows-x86_64.txt b/library/cpp/testing/gbenchmark/CMakeLists.windows-x86_64.txt new file mode 100644 index 00000000000..6b4fdb826d8 --- /dev/null +++ b/library/cpp/testing/gbenchmark/CMakeLists.windows-x86_64.txt @@ -0,0 +1,19 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-testing-gbenchmark) +target_link_libraries(cpp-testing-gbenchmark PUBLIC + contrib-libs-cxxsupp + yutil + restricted-google-benchmark + cpp-testing-hook +) +target_sources(cpp-testing-gbenchmark PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark/main.cpp +) diff --git a/library/cpp/testing/gbenchmark/benchmark.h b/library/cpp/testing/gbenchmark/benchmark.h new file mode 100644 index 00000000000..b7be8ef5336 --- /dev/null +++ b/library/cpp/testing/gbenchmark/benchmark.h @@ -0,0 +1,3 @@ +#pragma once + +#include diff --git a/library/cpp/testing/gbenchmark/main.cpp b/library/cpp/testing/gbenchmark/main.cpp new file mode 100644 index 00000000000..523d18901a0 --- /dev/null +++ b/library/cpp/testing/gbenchmark/main.cpp @@ -0,0 +1,16 @@ +#include + +#include +#include + +int main(int argc, char** argv) { + NTesting::THook::CallBeforeInit(); + ::benchmark::Initialize(&argc, argv); + if (::benchmark::ReportUnrecognizedArguments(argc, argv)) { + return 1; + } + NTesting::THook::CallBeforeRun(); + Y_DEFER { NTesting::THook::CallAfterRun(); }; + ::benchmark::RunSpecifiedBenchmarks(); + return 0; +} diff --git a/library/cpp/testing/gbenchmark_main/CMakeLists.darwin-x86_64.txt b/library/cpp/testing/gbenchmark_main/CMakeLists.darwin-x86_64.txt deleted file mode 100644 index 3253a09a82e..00000000000 --- a/library/cpp/testing/gbenchmark_main/CMakeLists.darwin-x86_64.txt +++ /dev/null @@ -1,19 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - - -add_library(cpp-testing-gbenchmark_main) -target_link_libraries(cpp-testing-gbenchmark_main PUBLIC - contrib-libs-cxxsupp - yutil - contrib-libs-benchmark - cpp-testing-hook -) -target_sources(cpp-testing-gbenchmark_main PRIVATE - ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark_main/main.cpp -) diff --git a/library/cpp/testing/gbenchmark_main/CMakeLists.linux-aarch64.txt b/library/cpp/testing/gbenchmark_main/CMakeLists.linux-aarch64.txt deleted file mode 100644 index 66a59ee4146..00000000000 --- a/library/cpp/testing/gbenchmark_main/CMakeLists.linux-aarch64.txt +++ /dev/null @@ -1,20 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - - -add_library(cpp-testing-gbenchmark_main) -target_link_libraries(cpp-testing-gbenchmark_main PUBLIC - contrib-libs-linux-headers - contrib-libs-cxxsupp - yutil - contrib-libs-benchmark - cpp-testing-hook -) -target_sources(cpp-testing-gbenchmark_main PRIVATE - ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark_main/main.cpp -) diff --git a/library/cpp/testing/gbenchmark_main/CMakeLists.linux-x86_64.txt b/library/cpp/testing/gbenchmark_main/CMakeLists.linux-x86_64.txt deleted file mode 100644 index 66a59ee4146..00000000000 --- a/library/cpp/testing/gbenchmark_main/CMakeLists.linux-x86_64.txt +++ /dev/null @@ -1,20 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - - -add_library(cpp-testing-gbenchmark_main) -target_link_libraries(cpp-testing-gbenchmark_main PUBLIC - contrib-libs-linux-headers - contrib-libs-cxxsupp - yutil - contrib-libs-benchmark - cpp-testing-hook -) -target_sources(cpp-testing-gbenchmark_main PRIVATE - ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark_main/main.cpp -) diff --git a/library/cpp/testing/gbenchmark_main/CMakeLists.txt b/library/cpp/testing/gbenchmark_main/CMakeLists.txt deleted file mode 100644 index f8b31df0c11..00000000000 --- a/library/cpp/testing/gbenchmark_main/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - -if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA) - include(CMakeLists.linux-aarch64.txt) -elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - include(CMakeLists.darwin-x86_64.txt) -elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA) - include(CMakeLists.windows-x86_64.txt) -elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA) - include(CMakeLists.linux-x86_64.txt) -endif() diff --git a/library/cpp/testing/gbenchmark_main/CMakeLists.windows-x86_64.txt b/library/cpp/testing/gbenchmark_main/CMakeLists.windows-x86_64.txt deleted file mode 100644 index 3253a09a82e..00000000000 --- a/library/cpp/testing/gbenchmark_main/CMakeLists.windows-x86_64.txt +++ /dev/null @@ -1,19 +0,0 @@ - -# This file was generated by the build system used internally in the Yandex monorepo. -# Only simple modifications are allowed (adding source-files to targets, adding simple properties -# like target_include_directories). These modifications will be ported to original -# ya.make files by maintainers. Any complex modifications which can't be ported back to the -# original buildsystem will not be accepted. - - - -add_library(cpp-testing-gbenchmark_main) -target_link_libraries(cpp-testing-gbenchmark_main PUBLIC - contrib-libs-cxxsupp - yutil - contrib-libs-benchmark - cpp-testing-hook -) -target_sources(cpp-testing-gbenchmark_main PRIVATE - ${CMAKE_SOURCE_DIR}/library/cpp/testing/gbenchmark_main/main.cpp -) diff --git a/library/cpp/testing/gbenchmark_main/main.cpp b/library/cpp/testing/gbenchmark_main/main.cpp deleted file mode 100644 index 523d18901a0..00000000000 --- a/library/cpp/testing/gbenchmark_main/main.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#include -#include - -int main(int argc, char** argv) { - NTesting::THook::CallBeforeInit(); - ::benchmark::Initialize(&argc, argv); - if (::benchmark::ReportUnrecognizedArguments(argc, argv)) { - return 1; - } - NTesting::THook::CallBeforeRun(); - Y_DEFER { NTesting::THook::CallAfterRun(); }; - ::benchmark::RunSpecifiedBenchmarks(); - return 0; -} -- cgit v1.3