Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macos-arm64 binary to the python package #36

Merged
merged 3 commits into from
Feb 2, 2025
Merged
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
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- os: ubuntu-latest
release: linux-x86_64
- os: macos-latest
release: macos-x86_64
release: macos-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
zip -r rootcanal-${{ matrix.release }} rootcanal-${{ matrix.release }}

- name: Upload Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: rootcanal-${{ matrix.release }}
path: rootcanal-${{ matrix.release }}.zip
Expand Down Expand Up @@ -85,14 +85,14 @@ jobs:
prerelease: false

- name: Download rootcanal-linux-x86_64
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: rootcanal-linux-x86_64

- name: Download rootcanal-macos-x86_64
uses: actions/download-artifact@v3
- name: Download rootcanal-macos-arm64
uses: actions/download-artifact@v4
with:
name: rootcanal-macos-x86_64
name: rootcanal-macos-arm64

- name: Build Python Wheel
run: bash py/make_wheel.sh ${{ env.VERSION }}
Expand All @@ -117,12 +117,12 @@ jobs:
asset_name: rootcanal-${{ env.VERSION }}-linux-x86_64.zip
asset_content_type: application/zip

- name: Upload rootcanal-macos-x86_64
- name: Upload rootcanal-macos-arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: rootcanal-macos-x86_64.zip
asset_name: rootcanal-${{ env.VERSION }}-macos-x86_64.zip
asset_path: rootcanal-macos-arm64.zip
asset_name: rootcanal-${{ env.VERSION }}-macos-arm64.zip
asset_content_type: application/zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Cargo.lock
MODULE.bazel.lock
target/
bazel-*
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[submodule "third_party/pdl"]
path = third_party/pdl
url = https://github.com/google/pdl.git
[submodule "third_party/gflags"]
path = third_party/gflags
url = https://github.com/gflags/gflags.git
48 changes: 15 additions & 33 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_rust//rust:defs.bzl", "rust_static_library")
load("@rules_rust//rust:defs.bzl", "rust_library")
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")

package(default_visibility = ["//visibility:private"])
licenses(["notice"])
Expand Down Expand Up @@ -35,18 +32,6 @@ cc_proto_library(
deps = [":rootcanal_proto"],
)

rust_library(
name = "pdl_runtime",
srcs = glob(["third_party/pdl/pdl-runtime/**/*.rs"]),
crate_root = "third_party/pdl/pdl-runtime/src/lib.rs",
edition = "2018",
version = "2.0.0",
deps = [
"//rust/cargo:bytes",
"//rust/cargo:thiserror",
],
)

genrule(
name = "lmp_packets_rs",
cmd = "pdlc --output-format rust $(location rust/lmp_packets.pdl) > $(location lmp_packets.rs)",
Expand Down Expand Up @@ -103,18 +88,18 @@ rust_static_library(
"lmp_packets.rs",
],
proc_macro_deps = [
"//rust/cargo:num_derive",
"//rust/cargo:paste",
"@crates//:num-derive",
"@crates//:paste",
],
deps = [
":pdl_runtime",
"//rust/cargo:bytes",
"//rust/cargo:num_bigint",
"//rust/cargo:num_integer",
"//rust/cargo:num_traits",
"//rust/cargo:pin_utils",
"//rust/cargo:rand",
"//rust/cargo:thiserror",
"@crates//:bytes",
"@crates//:num-bigint",
"@crates//:num-integer",
"@crates//:num-traits",
"@crates//:pdl-runtime",
"@crates//:pin-utils",
"@crates//:rand",
"@crates//:thiserror",
],
)

Expand Down Expand Up @@ -211,9 +196,6 @@ cc_library(
"-I.",
"-fmacro-prefix-map=external/rootcanal/=",
],
linkopts = [
"-lcrypto",
],
defines = [
"NDEBUG",
"_GNU_SOURCE",
Expand All @@ -229,16 +211,14 @@ cc_library(
":rootcanal_rs",
"//packets:generated",
"@fmtlib",
"@openssl//:crypto",
"@pdl//:packet_runtime",
],
)

cc_binary(
name = "librootcanal_ffi.so",
linkopts = [
"-shared",
"-lcrypto",
],
linkopts = ["-shared"],
srcs = [
"include/crypto/crypto.h",
"include/hci/address.h",
Expand Down Expand Up @@ -296,8 +276,9 @@ cc_binary(
":rootcanal_log",
":rootcanal_rs",
"//packets:generated",
"@fmtlib",
"@pdl//:packet_runtime",
"@fmtlib",
"@openssl//:crypto",
],
)

Expand All @@ -316,5 +297,6 @@ cc_binary(
":rootcanal_rs",
"@gflags",
"@fmtlib",
"@openssl//:crypto",
],
)
47 changes: 47 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2025 Google Inc. All Rights Reserved.

module(
name = "rootcanal",
repo_name = "com_github_google_rootcanal",
)

bazel_dep(name = "rules_cc", version = "0.1.0")
bazel_dep(name = "rules_rust", version = "0.57.1")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "rules_python", version = "1.1.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")

bazel_dep(name = "openssl", version = "3.3.1.bcr.1")
bazel_dep(name = "gflags", version = "2.2.2")

local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")

new_local_repository(
name = "fmtlib",
path = "third_party/fmtlib",
build_file = "//:BUILD.fmtlib",
)

new_local_repository(
name = "pdl",
path = "third_party/pdl",
build_file = "//:BUILD.pdl",
)

crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")

crate.spec(package = "bytes", version = "1.0.1")
crate.spec(package = "num-bigint", version = "0.4.3")
crate.spec(package = "num-derive", version = "0.3.3")
crate.spec(package = "num-integer", version = "0.1.45")
crate.spec(package = "num-traits", version = "0.2.14")
crate.spec(package = "paste", version = "1.0.4")
crate.spec(package = "pdl-runtime", version = "0.2.2")
crate.spec(package = "pin-utils", version = "0.1.0")
crate.spec(package = "rand", version = "0.8.3")
crate.spec(package = "thiserror", version = "1.0.23")
crate.spec(package = "bytes", version = "1.0.1")

crate.from_specs()
use_repo(crate, "crates")
77 changes: 0 additions & 77 deletions WORKSPACE

This file was deleted.

8 changes: 4 additions & 4 deletions py/make_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ mkdir -p py/src/rootcanal/bin/linux-x86_64
cp rootcanal-linux-x86_64/bin/rootcanal py/src/rootcanal/bin/linux-x86_64/rootcanal
cp rootcanal-linux-x86_64/lib/librootcanal_ffi.so py/src/rootcanal/bin/linux-x86_64/librootcanal_ffi.so

unzip rootcanal-macos-x86_64.zip
mkdir -p py/src/rootcanal/bin/macos-x86_64
cp rootcanal-macos-x86_64/bin/rootcanal py/src/rootcanal/bin/macos-x86_64/rootcanal
cp rootcanal-macos-x86_64/lib/librootcanal_ffi.so py/src/rootcanal/bin/macos-x86_64/librootcanal_ffi.so
unzip rootcanal-macos-arm64.zip
mkdir -p py/src/rootcanal/bin/macos-arm64
cp rootcanal-macos-arm64/bin/rootcanal py/src/rootcanal/bin/macos-arm64/rootcanal
cp rootcanal-macos-arm64/lib/librootcanal_ffi.so py/src/rootcanal/bin/macos-arm64/librootcanal_ffi.so

# 1. Generate the python backends for packet parsing.
mkdir -p py/src/rootcanal/packets
Expand Down
Loading