Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 628207314
  • Loading branch information
hai007 authored and copybara-github committed Apr 25, 2024
1 parent e9b5745 commit f4bad55
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 54 deletions.
124 changes: 78 additions & 46 deletions presence/implementation/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,88 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

licenses(["notice"])

bool_flag(
name = "enable_rust_decoder",
build_setting_default = False,
)

# In order to build with the rust decoder turned on use:
# blaze build third_party/nearby/presence/implementation:internal /
# --//third_party/nearby/presence/implementation:enable_rust_decoder /
config_setting(
name = "use_rust_decoder",
flag_values = {
":enable_rust_decoder": "true",
},
cc_library(
name = "internal_with_rust",
srcs = [
"action_factory.cc",
"advertisement_decoder_rust_impl.cc",
"advertisement_factory.cc",
"advertisement_filter.cc",
"base_broadcast_request.cc",
"broadcast_manager.cc",
"connection_authenticator_impl.cc",
"credential_manager_impl.cc",
"ldt.cc",
"scan_manager.cc",
"service_controller_impl.cc",
],
hdrs = [
"action_factory.h",
"advertisement_decoder.h",
"advertisement_decoder_rust_impl.h",
"advertisement_factory.h",
"advertisement_filter.h",
"base_broadcast_request.h",
"broadcast_manager.h",
"connection_authenticator.h",
"connection_authenticator_impl.h",
"credential_manager.h",
"credential_manager_impl.h",
"ldt.h",
"scan_manager.h",
"service_controller.h",
"service_controller_impl.h",
],
compatible_with = ["//buildenv/target:non_prod"],
defines = ["USE_RUST_DECODER=1"],
visibility = [
"//presence:__subpackages__",
],
deps = [
"//devtools/rust:rust_okay_here",
"//internal/crypto",
"//internal/crypto_cros",
"//internal/platform:base",
"//internal/platform:comm",
"//internal/platform:types",
"//internal/platform:uuid",
"//internal/platform/implementation:comm",
"//internal/platform/implementation:types",
"//internal/proto:credential_cc_proto",
"//internal/proto:local_credential_cc_proto",
"//internal/proto:metadata_cc_proto",
"//presence:types",
"//presence/implementation/mediums",
"@beto-core//:ldt_np_adv_ffi",
"@beto-core//:np_c_ffi_types",
"@beto-core//:np_cpp_ffi",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/hash",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/log:die_if_null",
"@com_google_absl//absl/random",
"@com_google_absl//absl/random:distributions",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:variant",
],
)

cc_library(
name = "internal",
srcs = [
"action_factory.cc",
"advertisement_decoder_impl.cc",
"advertisement_factory.cc",
"advertisement_filter.cc",
"base_broadcast_request.cc",
Expand All @@ -43,17 +102,11 @@ cc_library(
"ldt.cc",
"scan_manager.cc",
"service_controller_impl.cc",
] + select({
":use_rust_decoder": [
"advertisement_decoder_rust_impl.cc",
],
"//conditions:default": [
"advertisement_decoder_impl.cc",
],
}),
],
hdrs = [
"action_factory.h",
"advertisement_decoder.h",
"advertisement_decoder_impl.h",
"advertisement_factory.h",
"advertisement_filter.h",
"base_broadcast_request.h",
Expand All @@ -66,22 +119,7 @@ cc_library(
"scan_manager.h",
"service_controller.h",
"service_controller_impl.h",
] + select({
":use_rust_decoder": [
"advertisement_decoder_rust_impl.h",
],
"//conditions:default": [
"advertisement_decoder_impl.h",
],
}),
# TODO(b/334166657): Move rust backed decoder to its own build target so it recieved coverage
# metrics
defines = select({
":use_rust_decoder": [
"USE_RUST_DECODER=1",
],
"//conditions:default": [],
}),
],
visibility = [
"//presence:__subpackages__",
],
Expand Down Expand Up @@ -116,13 +154,7 @@ cc_library(
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:variant",
] + select({
":use_rust_decoder": [
"@beto-core//:np_c_ffi_types",
"@beto-core//:np_cpp_ffi",
],
"//conditions:default": [],
}),
],
)

cc_library(
Expand Down Expand Up @@ -194,7 +226,7 @@ cc_test(
size = "small",
srcs = ["advertisement_decoder_new_format_test.cc"],
deps = [
":internal",
":internal_with_rust",
"//internal/platform:base",
"//internal/proto:credential_cc_proto",
"//presence:types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifdef USE_RUST_DECODER

#include <string>
#include <vector>

Expand Down Expand Up @@ -152,5 +150,3 @@ TEST(AdvertisementDecoderImpl, V0InvalidAdvContents) {
} // namespace
} // namespace presence
} // namespace nearby

#endif
4 changes: 0 additions & 4 deletions presence/implementation/advertisement_decoder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef USE_RUST_DECODER

#include "presence/implementation/advertisement_decoder.h"

#include <string>
Expand Down Expand Up @@ -315,5 +313,3 @@ TEST(AdvertisementDecoderImpl, UnsupportedAdvertisementVersion) {
} // namespace
} // namespace presence
} // namespace nearby

#endif

0 comments on commit f4bad55

Please sign in to comment.