Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
common --check_direct_dependencies=off
common --noincompatible_disallow_empty_glob
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
8.0.1
35 changes: 30 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,44 @@ exports_files(["LICENSE"])

cc_library(
name = "common",
srcs = glob(["common/*.cpp"], exclude=["common/loglevel.cpp", "common/loglevel_util.cpp"]),
srcs = glob(
["common/*.cpp"],
["common/loglevel.cpp", "common/loglevel_util.cpp"]
),
hdrs = glob([
"common/*.h",
"common/*.hpp",
]),
], allow_empty = True),
copts = [
"-std=c++14",
"-I/usr/include/libnl3", # Expected location in the SONiC build container"
# TODO: this is not required with apt.installed debs.
# "-I/usr/include/libnl3", # Expected location in the SONiC build container"
],
# Not needed with apt.install
# linkopts = ["-lpthread -lhiredis -lnl-genl-3 -lnl-nf-3 -lnl-route-3 -lnl-3 -lzmq -luuid -lyang"],
includes = [
"common",
],
linkopts = ["-lpthread -lhiredis -lnl-genl-3 -lnl-nf-3 -lnl-route-3 -lnl-3 -lzmq -lboost_serialization -luuid -lyang"],
# Approach 1:
deps = [
"@focal//libhiredis-dev:libhiredis",
"@focal//nlohmann-json3-dev:nlohmann-json3",
"@focal//libnl-3-dev:libnl-3",
"@focal//libnl-route-3-dev:libnl-route-3",
"@focal//libnl-nf-3-dev:libnl-nf-3",
"@focal//libyang-dev:libyang",
"@focal//libzmq3-dev:libzmq3",
"@focal//uuid-dev:uuid",
"@focal//libboost-dev:libboost"
],
# Approach 2: BCR entries compiled from source
# deps = [
# "@boost.algorithm",
# "@boost.serialization",
# "@nlohmann_json//:json",
# "@libuuid//:libuuid",
# "@swig//:swig",
# ],
visibility = ["//visibility:public"],
)

Expand All @@ -25,7 +50,7 @@ cc_library(
hdrs = glob([
"common/*.h",
"common/*.hpp",
]),
], allow_empty = True),
include_prefix = "swss",
strip_include_prefix = "common",
deps = [":common"],
Expand Down
74 changes: 74 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
module(name = "sonic-swss-common")

bazel_dep(name = "rules_distroless", version = "0.0.0")
local_path_override(
module_name = "rules_distroless",
path = "../rules_distroless"
)


apt = use_extension("@rules_distroless//apt:extensions.bzl", "apt")

apt.sources_list(
architectures = ["amd64"],
components = [
"main",
"restricted",
"universe"
],
suites = [
"focal",
"focal-security",
"focal-updates",
],
uris = [
"https://snapshot.ubuntu.com/ubuntu/20240301T030400Z",
"mirror+https://snapshot.ubuntu.com/ubuntu/20240301T030400Z",
],
)


# sudo apt-get install -y
# make libtool m4 autoconf dh-exec debhelper cmake pkg-config
# nlohmann-json3-dev libhiredis-dev libnl-3-dev libnl-genl-3-dev
# libnl-route-3-dev libnl-nf-3-dev swig3.0 libpython2.7-dev libboost-dev
# libboost-serialization-dev uuid-dev libzmq3-dev

apt.install(
dependency_set = "focal",
target_release = "focal",
packages = [
"nlohmann-json3-dev",
"libhiredis-dev",
"libnl-3-dev",
"libnl-genl-3-dev",
"libnl-route-3-dev",
"libnl-nf-3-dev",
"libboost-dev",
"libboost-serialization-dev",
"uuid-dev",
"libzmq3-dev",
"libyang-dev",

# These seem to be unused
# "swig3.0",
# "libpython2.7-dev",
# "libgtest-dev",
# "libgmock-dev",
]
)

apt.lock(into = ":packages.lock")

use_repo(apt, "focal")

# bazel_dep(name = "googletest", version = "1.11.0", repo_name = "com_google_googletest")
# bazel_dep(name = "glog", version = "0.5.0", repo_name = "com_github_google_glog")
# bazel_dep(name = "nlohmann_json", version = "3.12.0")
# bazel_dep(name = "boost.algorithm", version = "1.87.0")
# bazel_dep(name = "boost.serialization", version = "1.87.0")
# bazel_dep(name = "libuuid", version = "2.39.3.bcr.1")
# bazel_dep(name = "libzmq", version = "4.3.5.bcr.3")
# bazel_dep(name = "swig", version = "4.3.0")
# bazel_dep(name = "abseil-cpp", version = "20210324.2")
# bazel_dep(name = "gflags", version = "2.2.2")
Loading
Loading