Skip to content

Commit

Permalink
continue split proto and non-proto crates
Browse files Browse the repository at this point in the history
Can succesfully do a WebRTC call on localhost.
  • Loading branch information
ystreet committed Apr 11, 2024
1 parent 5f7fc7d commit 86c263c
Show file tree
Hide file tree
Showing 25 changed files with 4,053 additions and 969 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["librice", "librice-proto", "fuzz"]
members = ["librice-proto", "librice", "fuzz"]
default-members = ["librice", "librice-proto"]
resolver = "2"

Expand All @@ -12,6 +12,7 @@ rust-version = "1.68.2"
[workspace.dependencies]
arbitrary = { version = "1", features = ["derive"] }
byteorder = "1"
get_if_addrs = "0.5"
rand = "0.8"
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", features = ["std", "env-filter"] }
Expand Down
15 changes: 15 additions & 0 deletions librice-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,32 @@ repository.workspace = true
rust-version.workspace = true
workspace = ".."

[features]
capi = ["libc", "socket2", "tracing-subscriber", "get_if_addrs"]

[dependencies]
arbitrary = { workspace = true, optional = true }
byteorder.workspace = true
crc = "3"
get_if_addrs = { workspace = true, optional = true }
hmac = "0.12"
md-5 = "0.10"
nom = "7"
rand.workspace = true
sha-1 = "0.10"
sha2 = "0.10"
tracing.workspace = true
libc = { version = "0.2", optional = true }
socket2 = { version = "0.5", optional = true }
tracing-subscriber = { workspace = true, optional = true }

[dev-dependencies]
tracing-subscriber.workspace = true

[package.metadata.capi]
min_version = "0.9.21"

[package.metadata.capi.library]
name = "rice-proto"
version_suffix_components = 1
rustflags = "-Cpanic=abort"
24 changes: 24 additions & 0 deletions librice-proto/cbindgen.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
header = "// SPDX-License-Identifier: MIT OR Apache-2.0"
sys_includes = ["sys/socket.h"]
include_guard = "LIBRICE_PROTO_H"
tab_width = 4
language = "C"
cpp_compat = true
usize_is_size_t = true

[export]
exclude = ["MAGIC_COOKIE", "BINDING", "RTP", "RTCP"]
item_types = ["enums", "structs", "opaque", "functions"]

[export.rename]
#"sockaddr" = "struct sockaddr"
#"sockaddr_storage" = "struct sockaddr_storage"
"CandidateType" = "RiceCandidateType"
"TransportType" = "RiceTransportType"
"ComponentConnectionState" = "RiceComponentConnectionState"

[fn]
args = "vertical"

[enum]
rename_variants = "QualifiedScreamingSnakeCase"
41 changes: 41 additions & 0 deletions librice-proto/check_meson_wraps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3

import os, subprocess
import pathlib, configparser

def parse_cargo_tree_line(line):
components = line.split()
# FIXME doesn't support more than single digit depths
depth = int(components[0][0])
name = components[0][1:]
version = components[1][1:]
features = []
if len(components) > 2 and components[2][0] != '(':
features = components[2].split(',')
print(depth, name, version, features)
return (name, version, features)

CRATES_URL_TEMPL = "https://crates.io/api/v1/crates/{name}/{version}/download"

def main():
crates_features = subprocess.run(["cargo", "tree", "-f", "{p} {f}", "-p", "librice-proto", "-e", "normal", "--prefix", "depth"], capture_output=True, check=True, text=True).stdout
crates = {}
for line in crates_features.splitlines():
(name, version, features) = parse_cargo_tree_line(line)
if name != 'librice-proto':
if name in crates:
assert(crates[name] == (version, features))
continue
crates[name] = (version, features)
wrap_file = pathlib.Path('..') / 'librice-proto' / 'subprojects' / (name + '.wrap')
with wrap_file.open(mode="r") as f:
wrap = configparser.ConfigParser()
wrap.read_file(f)
name_version = name + '-' + version
assert(wrap["wrap-file"]["directory"] == name_version)
assert(wrap["wrap-file"]["source_url"] == CRATES_URL_TEMPL.format(name=name, version=version))
assert(wrap["wrap-file"]["source_filename"] == name_version + '.tar.gz')
assert(wrap["provide"]["dependency_names"] == name + '-rs')

if __name__ == "__main__":
main()
Loading

0 comments on commit 86c263c

Please sign in to comment.