Skip to content

Commit

Permalink
mdns: add mdns for local network routing
Browse files Browse the repository at this point in the history
  • Loading branch information
pkova committed Sep 4, 2023
1 parent 43a2568 commit ada3336
Show file tree
Hide file tree
Showing 13 changed files with 2,123 additions and 3 deletions.
30 changes: 29 additions & 1 deletion WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ versioned_http_archive(
name = "rules_foreign_cc",
sha256 = "2a4d07cd64b0719b39a7c12218a3e507672b82a97b98c6a89d38565894cf7c51",
strip_prefix = "rules_foreign_cc-{version}",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/{version}.tar.gz",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/{version}.tar.gz",
version = "0.9.0",
)

Expand Down Expand Up @@ -130,6 +130,15 @@ versioned_http_archive(
version = "a4c1e3f7138c2e577376beb99f964cf71e1c8b1b",
)

versioned_http_archive(
name = "avahi",
build_file = "//bazel/third_party/avahi:avahi.BUILD",
sha256 = "060309d7a333d38d951bc27598c677af1796934dbd98e1024e7ad8de798fedda",
strip_prefix = "avahi-{version}",
url = "https://github.com/lathiat/avahi/releases/download/v{version}/avahi-{version}.tar.gz",
version = "0.8",
)

versioned_http_archive(
name = "bazel_gazelle",
sha256 = "efbbba6ac1a4fd342d5122cbdfdb82aeb2cf2862e35022c752eaddffada7c3f3",
Expand All @@ -154,6 +163,15 @@ versioned_http_archive(
version = "7.85.0",
)

versioned_http_archive(
name = "dbus",
build_file = "//bazel/third_party/dbus:dbus.BUILD",
sha256 = "a6bd5bac5cf19f0c3c594bdae2565a095696980a683a0ef37cb6212e093bde35",
strip_prefix = "dbus-{version}",
url = "https://dbus.freedesktop.org/releases/dbus/dbus-{version}.tar.xz",
version = "1.14.8",
)

versioned_http_archive(
name = "ed25519",
build_file = "//bazel/third_party/ed25519:ed25519.BUILD",
Expand All @@ -163,6 +181,16 @@ versioned_http_archive(
version = "7fa6712ef5d581a6981ec2b08ee623314cd1d1c4",
)

versioned_http_archive(
name = "expat",
build_file = "//bazel/third_party/expat:expat.BUILD",
strip_prefix = "expat-{version}",
sha256 = "ef2420f0232c087801abf705e89ae65f6257df6b7931d37846a193ef2e8cdcbe",
# TODO: fix the R_2_5_0 nonsense
url = "https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-{version}.tar.xz",
version = "2.5.0",
)

versioned_http_archive(
name = "gmp",
build_file = "//bazel/third_party/gmp:gmp.BUILD",
Expand Down
Empty file.
30 changes: 30 additions & 0 deletions bazel/third_party/avahi/avahi.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")

filegroup(
name = "all",
srcs = glob(["**"]),
)

cc_library(
name = "dns-sd",
hdrs = ["dns_sd.h"],
visibility = ["//visibility:public"],
)

configure_make(
name = "avahi",
args = select({
"@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"],
"//conditions:default": ["--jobs=`nproc`"],
}),
configure_options = ["--with-dbus-system-address='unix:path=/var/run/dbus/system_bus_socket' --with-xml=none --disable-libevent --disable-glib --disable-gobject --disable-gdbm --disable-qt3 --disable-qt4 --disable-qt5 --disable-gtk --disable-gtk3 --disable-mono --disable-monodoc --disable-python --disable-libdaemon --enable-compat-libdns_sd --disable-rpath"],
lib_source = ":all",
# out_include_dir = "avahi-compat-libdns_sd",
deps = ["@dbus"],
configure_in_place = True,
autogen = True,
autoconf = True,
autogen_command = "bootstrap.sh",
out_static_libs = ["libdns_sd.a", "libavahi-client.a", "libavahi-common.a"],
visibility = ["//visibility:public"],
)
Empty file.
21 changes: 21 additions & 0 deletions bazel/third_party/dbus/dbus.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")

filegroup(
name = "all",
srcs = glob(["**"]),
)

configure_make(
name = "dbus",
lib_name = "libdbus-1",
args = select({
"@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"],
"//conditions:default": ["--jobs=`nproc`"],
}),
copts = ["-O3"],
lib_source = ":all",
configure_in_place = True,
deps = ["@expat"],
alwayslink = True,
visibility = ["//visibility:public"],
)
Empty file.
20 changes: 20 additions & 0 deletions bazel/third_party/expat/expat.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")

filegroup(
name = "all",
srcs = glob(["**"]),
)

configure_make(
name = "expat",
args = select({
"@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"],
"//conditions:default": ["--jobs=`nproc`"],
}),
# configure_options = ["--with-xml=none --disable-libevent --disable-glib --disable-gobject --disable-gdbm --disable-qt3 --disable-qt4 --disable-qt5 --disable-gtk --disable-gtk3 --disable-mono --disable-monodoc --disable-python --enable-compat-libdns_sd"],
copts = ["-O3"],
lib_source = ":all",
# deps = ["@dbus"],
out_static_libs = ["libexpat.a"],
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions pkg/c3/motes.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
# define c3__deep c3_s4('d','e','e','p')
# define c3__defn c3_s4('d','e','f','n')
# define c3__del c3_s3('d','e','l')
# define c3__dear c3_s4('d','e','a','r')
# define c3__delc c3_s4('d','e','l','c')
# define c3__delt c3_s4('d','e','l','t')
# define c3__dept c3_s4('d','e','p','t')
Expand Down
14 changes: 12 additions & 2 deletions pkg/vere/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ vere_library(
hdrs = [
"db/lmdb.h",
"vere.h",
],
] + select({
"@platforms//os:macos": [],
"@platforms//os:linux": [
"dns_sd.h",
],
}),
includes = ["."],
linkstatic = True,
visibility = ["//pkg:__subpackages__"],
Expand All @@ -133,7 +138,12 @@ vere_library(
"@lmdb",
"@openssl",
"@uv",
],
] + select({
"@platforms//os:macos": [],
"@platforms//os:linux": [
"@avahi",
],
})
)

#
Expand Down
Loading

0 comments on commit ada3336

Please sign in to comment.