Skip to content

Commit 3bced13

Browse files
authored
feat(compat): add compat.bluez 5.88 (#922)
1 parent b440eaa commit 3bced13

5 files changed

Lines changed: 122 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Add `compat.bluez` (`5.88`)
2+
3+
## Summary
4+
5+
Add `compat.bluez` (`pkgs/c/compat.bluez.lua`) at upstream tag `5.88` (`https://github.com/bluez/bluez`).
6+
7+
## Package Shape
8+
9+
- **Form B** Linux-only `mcpp` package compiling `*/lib/bluetooth/{bluetooth,hci,sdp,uuid}.c` with `include_dirs = { "*/lib", "*/lib/bluetooth" }` (`private_include_dirs = { "*/lib/bluetooth" }`) so consumers get `<bluetooth/*.h>` and the static `libbluetooth` helpers cleanly.
10+
- Verified with `tests/examples/bluez/tests/bluez.cpp` (address/UUID conversion, `sockaddr_l2`, negative error handling).
11+
- SHA256 verified twice: `667203f5dba91cf8b2094239dd9b415b487146cb00d4653179c11723dce52f19`.

‎mcpp.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ members = [
223223
"tests/examples/libinput",
224224
"tests/examples/libseat",
225225
"tests/examples/libudev",
226+
"tests/examples/bluez",
226227
"tests/examples/libxkbcommon",
227228
"tests/examples/mtdev",
228229
"tests/examples/pixman",

‎pkgs/c/compat.bluez.lua‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
local versions = {
2+
["5.88"] = {
3+
url = "https://github.com/bluez/bluez/archive/refs/tags/5.88.tar.gz",
4+
sha256 = "667203f5dba91cf8b2094239dd9b415b487146cb00d4653179c11723dce52f19",
5+
},
6+
}
7+
8+
-- compat.bluez — BlueZ 5.88 user-space Bluetooth headers and libbluetooth helpers (Linux).
9+
--
10+
-- Form B source-built package compiling `*/lib/bluetooth/{bluetooth,hci,sdp,uuid}.c`
11+
-- and exposing `<bluetooth/*.h>` (`bluetooth.h`, `l2cap.h`, `hci.h`, `rfcomm.h`, `uuid.h`).
12+
-- Used on Linux alongside `gnome.gio` (`org.bluez` D-Bus + `AF_BLUETOOTH` sockets).
13+
package = {
14+
spec = "1",
15+
namespace = "compat",
16+
name = "bluez",
17+
description = "BlueZ 5.88 — Linux Bluetooth protocol stack headers and libbluetooth library",
18+
licenses = { "GPL-2.0-or-later", "LGPL-2.1-or-later" },
19+
repo = "https://github.com/bluez/bluez",
20+
type = "package",
21+
22+
extensions = {
23+
autoupdate = {
24+
tag = "${version}",
25+
url = "https://github.com/bluez/bluez/archive/refs/tags/${tag}.tar.gz",
26+
},
27+
},
28+
29+
xpm = {
30+
linux = { ["5.88"] = versions["5.88"] },
31+
},
32+
33+
mcpp = {
34+
language = "c++23",
35+
import_std = false,
36+
c_standard = "c11",
37+
license_files = { "*/COPYING", "*/COPYING.LIB" },
38+
include_dirs = { "*/lib", "*/lib/bluetooth" },
39+
private_include_dirs = { "*/lib/bluetooth" },
40+
41+
cflags = { "-D_GNU_SOURCE" },
42+
43+
sources = {
44+
"*/lib/bluetooth/bluetooth.c",
45+
"*/lib/bluetooth/hci.c",
46+
"*/lib/bluetooth/sdp.c",
47+
"*/lib/bluetooth/uuid.c",
48+
},
49+
50+
targets = {
51+
bluetooth = { kind = "static" },
52+
},
53+
},
54+
}

‎tests/examples/bluez/mcpp.toml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[indices]
2+
compat = { path = "../../.." }
3+
4+
[package]
5+
name = "bluez-tests"
6+
version = "0.1.0"
7+
standard = "c++23"
8+
9+
[target.'cfg(linux)'.dependencies.compat]
10+
bluez = "5.88"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#ifdef __linux__
2+
3+
#include <bluetooth/bluetooth.h>
4+
#include <bluetooth/l2cap.h>
5+
#include <bluetooth/uuid.h>
6+
7+
#include <cassert>
8+
#include <cstring>
9+
#include <iostream>
10+
11+
int main() {
12+
// Positive check: address formatting and parsing via libbluetooth.
13+
bdaddr_t addr{};
14+
assert(str2ba("11:22:33:44:55:66", &addr) == 0);
15+
char formatted[18]{};
16+
assert(ba2str(&addr, formatted) == 17);
17+
assert(std::strcmp(formatted, "11:22:33:44:55:66") == 0);
18+
19+
// Positive check: UUID string conversion via uuid.c + struct sockaddr_l2 layout.
20+
bt_uuid_t uuid{};
21+
assert(bt_string_to_uuid(&uuid, "0000180d-0000-1000-8000-00805f9b34fb") == 0);
22+
sockaddr_l2 l2{};
23+
l2.l2_family = AF_BLUETOOTH;
24+
l2.l2_bdaddr = addr;
25+
assert(l2.l2_family == AF_BLUETOOTH);
26+
27+
// Negative check: malformed Bluetooth address and malformed UUID fail cleanly.
28+
bdaddr_t bad_addr{};
29+
assert(str2ba("not-an-address", &bad_addr) < 0);
30+
bt_uuid_t bad_uuid{};
31+
assert(bt_string_to_uuid(&bad_uuid, "invalid-uuid") < 0);
32+
33+
std::cout << "compat.bluez verification PASSED\n";
34+
return 0;
35+
}
36+
37+
#else
38+
39+
#include <iostream>
40+
41+
int main() {
42+
std::cout << "compat.bluez verification SKIPPED (Linux only)\n";
43+
return 0;
44+
}
45+
46+
#endif

0 commit comments

Comments
 (0)