From 3fd04004d65c98ec92ea00427da50ed2c3b1e6b3 Mon Sep 17 00:00:00 2001 From: Lasan Mahaliyana Date: Fri, 6 Feb 2026 23:28:25 +0530 Subject: [PATCH] updated BUILD files and MODULE.bazel for bazel 9 --- MODULE.bazel | 15 ++++++++---- connections/file_share/BUILD | 2 ++ internal/platform/implementation/linux/BUILD | 1 + .../implementation/linux/generated/BUILD | 1 + sharing/linux/BUILD | 24 +++++++++++++++++++ 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 37ba001f..6c10e0fe 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -118,28 +118,33 @@ filegroup( ) # Create a repo that exposes system-installed sdbus-c++ and libsystemd to Bazel. +# +# Important portability note: +# Avoid hardcoding distro-specific library directories (for example +# /usr/lib/x86_64-linux-gnu vs /usr/lib64). Instead, link by soname and let the +# system linker/search path resolve the actual shared object location. new_local_repository = use_repo_rule( "@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository", ) -# Fedora/RHEL layout (lib64); see Ubuntu/Debian variant below new_local_repository( name = "sdbus_cpp", path = "/usr", build_file_content = """ package(default_visibility = ["//visibility:public"]) -cc_import( +load("@rules_cc//cc:defs.bzl", "cc_library") +cc_library( name = "sdbus_cpp", - shared_library = "lib/x86_64-linux-gnu/libsdbus-c++.so", hdrs = glob(["include/sdbus-c++/**/*.h*"]), includes = ["include"], + linkopts = ["-lsdbus-c++"], ) -cc_import( +cc_library( name = "libsystemd", - shared_library = "lib/x86_64-linux-gnu/libsystemd.so", + linkopts = ["-lsystemd"], ) """, ) diff --git a/connections/file_share/BUILD b/connections/file_share/BUILD index 701e91ba..4bb51bac 100644 --- a/connections/file_share/BUILD +++ b/connections/file_share/BUILD @@ -14,6 +14,8 @@ licenses(["notice"]) +load("@rules_cc//cc:defs.bzl", "cc_binary") + cc_binary( name = "file_share", srcs = ["main.cc"], diff --git a/internal/platform/implementation/linux/BUILD b/internal/platform/implementation/linux/BUILD index f5fc1d0e..e38c09f3 100644 --- a/internal/platform/implementation/linux/BUILD +++ b/internal/platform/implementation/linux/BUILD @@ -16,6 +16,7 @@ licenses(["notice"]) +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") #refresh_compile_commands( # name = "refresh_compile_commands", # diff --git a/internal/platform/implementation/linux/generated/BUILD b/internal/platform/implementation/linux/generated/BUILD index 7bb5ea35..86369cc1 100644 --- a/internal/platform/implementation/linux/generated/BUILD +++ b/internal/platform/implementation/linux/generated/BUILD @@ -13,6 +13,7 @@ # limitations under the License. licenses(["notice"]) +load("@rules_cc//cc:defs.bzl", "cc_library") cc_library( name = "types", textual_hdrs = glob(["**/*.h"]), diff --git a/sharing/linux/BUILD b/sharing/linux/BUILD index 365c79e2..df4ead17 100644 --- a/sharing/linux/BUILD +++ b/sharing/linux/BUILD @@ -13,6 +13,30 @@ # limitations under the License. licenses(["notice"]) +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_binary") + +cc_library( + name = "nearby_connections_service_linux", + srcs = ["nearby_connections_service_linux.cc"], + hdrs = [ + "nearby_connections_service_linux.h", + "//sharing:nearby_connections_service.h", + ], + visibility = ["//visibility:public"], + deps = [ + "//connections:core", + "//connections:core_types", + "//internal/base:file_path", + "//internal/platform:base", + "//internal/platform:logging", + "//internal/platform:mac_address", + "//sharing:connection_types", + "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/strings:string_view", + "@com_google_absl//absl/time", + "@com_google_absl//absl/types:span", + ], +) cc_library( name = "nearby_sharing_service_linux",