From bc5a4c5cb5a94f321d501921c756bbad473c39d8 Mon Sep 17 00:00:00 2001 From: chenneal Date: Thu, 31 Aug 2023 11:11:55 +0800 Subject: [PATCH] Fix some compile problem --- .bazelversion | 1 + BUILD | 31 +++++++++++++++++++--------- WORKSPACE | 6 +++--- bazel/third_party_repositories.bzl | 4 ++-- sentinel-core/log/BUILD | 2 +- sentinel-core/property/BUILD | 2 +- sentinel-core/slot/base/BUILD | 2 +- sentinel-core/transport/common/BUILD | 2 +- 8 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 .bazelversion diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 000000000..0062ac971 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +5.0.0 diff --git a/BUILD b/BUILD index adea3f67e..2afdc6685 100644 --- a/BUILD +++ b/BUILD @@ -1,16 +1,27 @@ -load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make") -# load("@rules_foreign_cc//tools/build_defs:make.bzl", "make") +load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") -configure_make( +package(default_visibility = ["//visibility:public"]) + +cmake( name = "libevent", - visibility = ["//visibility:public"], - configure_options = [ - "--enable-shared=no", - "--disable-libevent-regress", - "--disable-openssl", - ], + cache_entries = { + "EVENT__DISABLE_MBEDTLS": "ON", + "EVENT__DISABLE_OPENSSL": "on", + "EVENT__DISABLE_REGRESS": "on", + "EVENT__DISABLE_TESTS": "on", + "EVENT__LIBRARY_TYPE": "STATIC", + "CMAKE_BUILD_TYPE": "Release", + # Disable ranlib because it is not handled by bazel, and therefore + # doesn't respect custom toolchains such as the Android NDK, + # see https://github.com/bazelbuild/rules_foreign_cc/issues/252 + "CMAKE_RANLIB": "", + }, + generate_args = ["-DCMAKE_C_FLAGS=-fPIC -GNinja"], lib_source = "@com_github_libevent//:all", - out_lib_dir = "lib", + out_static_libs = [ + "libevent.a", + "libevent_pthreads.a", + ] ) # make( diff --git a/WORKSPACE b/WORKSPACE index 4f41e44fa..479aab01c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -18,11 +18,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # Rule repository http_archive( name = "rules_foreign_cc", - strip_prefix = "rules_foreign_cc-master", - url = "https://github.com/bazelbuild/rules_foreign_cc/archive/master.zip", + strip_prefix = "rules_foreign_cc-0.7.1", + urls = ["https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/0.7.1.zip"], ) -load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") +load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") rules_foreign_cc_dependencies() diff --git a/bazel/third_party_repositories.bzl b/bazel/third_party_repositories.bzl index d51360b4c..4c32a1d52 100644 --- a/bazel/third_party_repositories.bzl +++ b/bazel/third_party_repositories.bzl @@ -6,8 +6,8 @@ def include_third_party_repositories(): http_archive( name = "com_github_libevent", build_file_content = all_content, - strip_prefix = "libevent-2.1.8-stable", - urls = ["https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz"], + strip_prefix = "libevent-0d7d85c2083f7a4c9efe01c061486f332b576d28", + urls = ["https://github.com/libevent/libevent/archive/0d7d85c2083f7a4c9efe01c061486f332b576d28.tar.gz"], ) http_archive( diff --git a/sentinel-core/log/BUILD b/sentinel-core/log/BUILD index 13d4f9106..0d4d45b34 100644 --- a/sentinel-core/log/BUILD +++ b/sentinel-core/log/BUILD @@ -57,7 +57,7 @@ cc_test( cc_test( name = "logger_unittests", srcs = [ - "logger_unittests.cc", + "logger_test.cc", ], copts = TEST_COPTS, deps = [ diff --git a/sentinel-core/property/BUILD b/sentinel-core/property/BUILD index 269e214cd..30427dca1 100644 --- a/sentinel-core/property/BUILD +++ b/sentinel-core/property/BUILD @@ -38,7 +38,7 @@ cc_library( cc_test( name = "dynamic_sentinel_property_unittests", srcs = [ - "dynamic_sentinel_property_unittests.cc", + "dynamic_sentinel_property_test.cc", ], copts = TEST_COPTS, deps = [ diff --git a/sentinel-core/slot/base/BUILD b/sentinel-core/slot/base/BUILD index eff376d7c..a9d478431 100644 --- a/sentinel-core/slot/base/BUILD +++ b/sentinel-core/slot/base/BUILD @@ -84,7 +84,7 @@ cc_library( cc_test( name = "default_slot_chain_impl_unittests", srcs = [ - "default_slot_chain_impl_unittests.cc", + "default_slot_chain_impl_test.cc", ], copts = TEST_COPTS, deps = [ diff --git a/sentinel-core/transport/common/BUILD b/sentinel-core/transport/common/BUILD index efd476b80..df8165f39 100644 --- a/sentinel-core/transport/common/BUILD +++ b/sentinel-core/transport/common/BUILD @@ -19,7 +19,7 @@ cc_library( cc_test( name = "event_loop_thread_unittests", srcs = [ - "event_loop_thread.cc", + "event_loop_thread_test.cc", ], copts = TEST_COPTS, deps = [