Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9bb55a0 authored by Jack He's avatar Jack He Committed by Myles Watson
Browse files

Fix local GD cert runner

* Local GD cert test runner stopped working after mobly migration
* Fix it by using p/m/B/system as root instead of gd
* Change namespace strings in every test and facade files
* Move interface protos to blueberry namespaces

Test: system/gd/cert/run --clean
Test: system/gd/cert/run --device
Test: system/gd/cert/run
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines
Tag: #refactor

Change-Id: Ib1bd0b9e2e43264bdb9eb0e5bd8173d2015d87cf
parent c5167e99
Loading
Loading
Loading
Loading

system/Android.bp

0 → 100644
+173 −0
Original line number Diff line number Diff line
filegroup {
    name: "BlueberryFacadeProto",
    srcs: [
        "blueberry/facade/common.proto",
        "blueberry/facade/rootservice.proto",
        "blueberry/facade/hal/hal_facade.proto",
        "blueberry/facade/hci/hci_facade.proto",
        "blueberry/facade/hci/acl_manager_facade.proto",
        "blueberry/facade/hci/controller_facade.proto",
        "blueberry/facade/hci/le_acl_manager_facade.proto",
        "blueberry/facade/hci/le_advertising_manager_facade.proto",
        "blueberry/facade/hci/le_initiator_address_facade.proto",
        "blueberry/facade/hci/le_scanning_manager_facade.proto",
        "blueberry/facade/iso/facade.proto",
        "blueberry/facade/neighbor/facade.proto",
        "blueberry/facade/l2cap/classic/facade.proto",
        "blueberry/facade/l2cap/le/facade.proto",
        "blueberry/facade/security/facade.proto",
        "blueberry/facade/shim/facade.proto",
        "blueberry/facade/topshim/facade.proto",
    ],
}

genrule {
    name: "BlueberryFacadeGeneratedStub_h",
    tools: [
        "aprotoc",
        "protoc-gen-grpc-cpp-plugin",
    ],
    cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)",
    srcs: [
        ":BlueberryFacadeProto",
    ],
    out: [
        "blueberry/facade/common.grpc.pb.h",
        "blueberry/facade/common.pb.h",
        "blueberry/facade/rootservice.grpc.pb.h",
        "blueberry/facade/rootservice.pb.h",
        "blueberry/facade/hal/hal_facade.grpc.pb.h",
        "blueberry/facade/hal/hal_facade.pb.h",
        "blueberry/facade/hci/hci_facade.grpc.pb.h",
        "blueberry/facade/hci/hci_facade.pb.h",
        "blueberry/facade/hci/acl_manager_facade.grpc.pb.h",
        "blueberry/facade/hci/acl_manager_facade.pb.h",
        "blueberry/facade/hci/controller_facade.grpc.pb.h",
        "blueberry/facade/hci/controller_facade.pb.h",
        "blueberry/facade/hci/le_acl_manager_facade.grpc.pb.h",
        "blueberry/facade/hci/le_acl_manager_facade.pb.h",
        "blueberry/facade/hci/le_advertising_manager_facade.grpc.pb.h",
        "blueberry/facade/hci/le_advertising_manager_facade.pb.h",
        "blueberry/facade/hci/le_initiator_address_facade.grpc.pb.h",
        "blueberry/facade/hci/le_initiator_address_facade.pb.h",
        "blueberry/facade/hci/le_scanning_manager_facade.grpc.pb.h",
        "blueberry/facade/hci/le_scanning_manager_facade.pb.h",
        "blueberry/facade/iso/facade.grpc.pb.h",
        "blueberry/facade/iso/facade.pb.h",
        "blueberry/facade/l2cap/classic/facade.grpc.pb.h",
        "blueberry/facade/l2cap/classic/facade.pb.h",
        "blueberry/facade/l2cap/le/facade.grpc.pb.h",
        "blueberry/facade/l2cap/le/facade.pb.h",
        "blueberry/facade/neighbor/facade.grpc.pb.h",
        "blueberry/facade/neighbor/facade.pb.h",
        "blueberry/facade/security/facade.grpc.pb.h",
        "blueberry/facade/security/facade.pb.h",
        "blueberry/facade/shim/facade.grpc.pb.h",
        "blueberry/facade/shim/facade.pb.h",
    ],
}

genrule {
    name: "BlueberryFacadeGeneratedStub_cc",
    tools: [
        "aprotoc",
        "protoc-gen-grpc-cpp-plugin",
    ],
    cmd: "$(location aprotoc) -Ipackages/modules/Bluetooth/system -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-cpp-plugin) $(in) --grpc_out=$(genDir) --cpp_out=$(genDir)",
    srcs: [
        ":BlueberryFacadeProto",
    ],
    out: [
        "blueberry/facade/common.grpc.pb.cc",
        "blueberry/facade/common.pb.cc",
        "blueberry/facade/rootservice.grpc.pb.cc",
        "blueberry/facade/rootservice.pb.cc",
        "blueberry/facade/hal/hal_facade.grpc.pb.cc",
        "blueberry/facade/hal/hal_facade.pb.cc",
        "blueberry/facade/hci/hci_facade.grpc.pb.cc",
        "blueberry/facade/hci/hci_facade.pb.cc",
        "blueberry/facade/hci/acl_manager_facade.grpc.pb.cc",
        "blueberry/facade/hci/acl_manager_facade.pb.cc",
        "blueberry/facade/hci/controller_facade.grpc.pb.cc",
        "blueberry/facade/hci/controller_facade.pb.cc",
        "blueberry/facade/hci/le_acl_manager_facade.grpc.pb.cc",
        "blueberry/facade/hci/le_acl_manager_facade.pb.cc",
        "blueberry/facade/hci/le_advertising_manager_facade.grpc.pb.cc",
        "blueberry/facade/hci/le_advertising_manager_facade.pb.cc",
        "blueberry/facade/hci/le_initiator_address_facade.grpc.pb.cc",
        "blueberry/facade/hci/le_initiator_address_facade.pb.cc",
        "blueberry/facade/hci/le_scanning_manager_facade.grpc.pb.cc",
        "blueberry/facade/hci/le_scanning_manager_facade.pb.cc",
        "blueberry/facade/iso/facade.grpc.pb.cc",
        "blueberry/facade/iso/facade.pb.cc",
        "blueberry/facade/l2cap/classic/facade.grpc.pb.cc",
        "blueberry/facade/l2cap/classic/facade.pb.cc",
        "blueberry/facade/l2cap/le/facade.grpc.pb.cc",
        "blueberry/facade/l2cap/le/facade.pb.cc",
        "blueberry/facade/neighbor/facade.grpc.pb.cc",
        "blueberry/facade/neighbor/facade.pb.cc",
        "blueberry/facade/security/facade.grpc.pb.cc",
        "blueberry/facade/security/facade.pb.cc",
        "blueberry/facade/shim/facade.grpc.pb.cc",
        "blueberry/facade/shim/facade.pb.cc",
    ],
}

genrule {
    name: "BlueberryFacadeAndCertGeneratedStub_py",
    tools: [
        "aprotoc",
        "protoc-gen-grpc-python-plugin",
        "soong_zip",
    ],
    cmd: "mkdir -p $(genDir)/files && " +
        "$(location aprotoc) -Ipackages/modules/Bluetooth/system -Iexternal/protobuf/src --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin) $(in) --grpc_out=$(genDir)/files --python_out=$(genDir)/files && " +
        "find $(genDir)/files -type d -exec touch {}/__init__.py \\; &&" +
        "$(location soong_zip) -C $(genDir)/files -D $(genDir)/files -o $(out)",
    srcs: [
        ":BlueberryFacadeProto",
    ],
    out: ["blueberry_facade_generated_py.zip"],
}

rust_protobuf {
    name: "libbt_facade_proto",
    crate_name: "bt_facade_proto",
    protos: ["blueberry/facade/common.proto"],
    grpc_protos: [
        "blueberry/facade/hci/controller_facade.proto",
        "blueberry/facade/hci/hci_facade.proto",
        "blueberry/facade/hal/hal_facade.proto",
        "blueberry/facade/rootservice.proto",
    ],
    source_stem: "facade",
    host_supported: true,
    apex_available: [
        "//apex_available:platform",
        "com.android.bluetooth",
    ],
    min_sdk_version: "30",
}

rust_protobuf {
    name: "libbt_topshim_facade_protobuf",
    crate_name: "bt_topshim_facade_protobuf",
    source_stem: "topshim_facade",
    host_supported: true,
    grpc_protos: ["blueberry/facade/topshim/facade.proto"],
}

genrule {
    name: "libbt_topshim_facade_py_proto",
    tools: [
        "aprotoc",
        "protoc-gen-grpc-python-plugin",
        "soong_zip",
    ],
    cmd: "$(location aprotoc) --plugin=protoc-gen-grpc=$(location protoc-gen-grpc-python-plugin) -Ipackages/modules/Bluetooth/system $(in) --grpc_out=$(genDir) --python_out=$(genDir)",
    srcs: ["blueberry/facade/topshim/facade.proto"],
    out: [
        "blueberry/facade/topshim/facade_pb2.py",
        "blueberry/facade/topshim/facade_pb2_grpc.py"
    ],
}
 No newline at end of file
+14 −9
Original line number Diff line number Diff line
LOCAL_PATH := $(call my-dir)

#LINT.IfChange
LOCAL_bluetooth_project_dir := $(LOCAL_PATH)

LOCAL_cert_test_sources := \
    $(call all-named-files-under,*.py,blueberry) \
    $(call all-named-files-under,*.yaml,blueberry) \
  	setup.py
LOCAL_cert_test_sources := \
	$(filter-out gd_cert_venv% venv%, $(LOCAL_cert_test_sources))
@@ -49,12 +53,13 @@ LOCAL_target_libraries := \
	$(TARGET_OUT_SHARED_LIBRARIES)/libgrpc++.so \
	$(TARGET_OUT_SHARED_LIBRARIES)/libgrpc_wrap.so \
	$(TARGET_OUT_SHARED_LIBRARIES)/libstatslog_bt.so
#LINT.ThenChange(cert/run)
#LINT.ThenChange(gd/cert/run)

bluetooth_cert_src_and_bin_zip := \
	$(call intermediates-dir-for,PACKAGING,bluetooth_cert_src_and_bin,HOST)/bluetooth_cert_src_and_bin.zip

# Assume 64-bit OS
$(bluetooth_cert_src_and_bin_zip): PRIVATE_bluetooth_project_dir := $(LOCAL_bluetooth_project_dir)
$(bluetooth_cert_src_and_bin_zip): PRIVATE_cert_test_sources := $(LOCAL_cert_test_sources)
$(bluetooth_cert_src_and_bin_zip): PRIVATE_host_executables := $(LOCAL_host_executables)
$(bluetooth_cert_src_and_bin_zip): PRIVATE_host_python_extension_libraries := $(LOCAL_host_python_extension_libraries)
@@ -65,7 +70,7 @@ $(bluetooth_cert_src_and_bin_zip): $(SOONG_ZIP) $(LOCAL_cert_test_sources) \
		$(LOCAL_host_executables) $(LOCAL_host_libraries) $(LOCAL_host_python_extension_libraries) \
		$(LOCAL_target_executables) $(LOCAL_target_libraries)
	$(hide) $(SOONG_ZIP) -d -o $@ \
		-C packages/modules/Bluetooth/system/gd $(addprefix -f ,$(PRIVATE_cert_test_sources)) \
		-C $(PRIVATE_bluetooth_project_dir) $(addprefix -f ,$(PRIVATE_cert_test_sources)) \
		-C $(HOST_OUT_EXECUTABLES) $(addprefix -f ,$(PRIVATE_host_executables)) \
		-C $(HOST_OUT_SHARED_LIBRARIES) $(addprefix -f ,$(PRIVATE_host_python_extension_libraries)) \
		-P lib64 \
@@ -75,28 +80,28 @@ $(bluetooth_cert_src_and_bin_zip): $(SOONG_ZIP) $(LOCAL_cert_test_sources) \
		-C $(TARGET_OUT_SHARED_LIBRARIES) $(addprefix -f ,$(PRIVATE_target_libraries))

# TODO: Find a better way to locate output from SOONG genrule()
LOCAL_cert_generated_py_zip := \
	$(SOONG_OUT_DIR)/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothFacadeAndCertGeneratedStub_py/gen/bluetooth_cert_generated_py.zip
LOCAL_facade_generated_py_zip := \
	$(SOONG_OUT_DIR)/.intermediates/packages/modules/Bluetooth/system/BlueberryFacadeAndCertGeneratedStub_py/gen/blueberry_facade_generated_py.zip

bluetooth_cert_tests_py_package_zip := \
	$(call intermediates-dir-for,PACKAGING,bluetooth_cert_tests_py_package,HOST)/bluetooth_cert_tests.zip

$(bluetooth_cert_tests_py_package_zip): PRIVATE_bluetooth_project_dir := $(LOCAL_bluetooth_project_dir)
$(bluetooth_cert_tests_py_package_zip): PRIVATE_cert_src_and_bin_zip := $(bluetooth_cert_src_and_bin_zip)
$(bluetooth_cert_tests_py_package_zip): PRIVATE_cert_generated_py_zip := $(LOCAL_cert_generated_py_zip)
$(bluetooth_cert_tests_py_package_zip): PRIVATE_facade_generated_py_zip := $(LOCAL_facade_generated_py_zip)
$(bluetooth_cert_tests_py_package_zip): $(SOONG_ZIP) \
		$(bluetooth_cert_src_and_bin_zip) $(bluetooth_cert_generated_py_zip)
	@echo "Packaging Bluetooth Cert Tests into $@"
	@rm -rf $(dir $@)bluetooth_cert_tests
	@mkdir -p $(dir $@)bluetooth_cert_tests
	$(hide) unzip -o -q $(PRIVATE_cert_src_and_bin_zip) -d $(dir $@)bluetooth_cert_tests
	$(hide) unzip -o -q $(PRIVATE_cert_generated_py_zip) -d $(dir $@)bluetooth_cert_tests
	# Make all subdirectory of gd Python pacakages except lib64 and target
	$(hide) unzip -o -q $(PRIVATE_facade_generated_py_zip) -d $(dir $@)bluetooth_cert_tests
	# Make all subdirectory Python packages except lib64 and target
	$(hide) for f in `find $(dir $@)bluetooth_cert_tests -type d -name "*" \
					-not -path "$(dir $@)bluetooth_cert_tests/target*" \
					-not -path "$(dir $@)bluetooth_cert_tests/lib64*"` \
			; do (touch -a $$f/__init__.py) ; done
	$(hide) $(SOONG_ZIP) -d -o $@ -C $(dir $@)bluetooth_cert_tests -D $(dir $@)bluetooth_cert_tests \
		-P blueberry -C packages/modules/Bluetooth/system/blueberry -D packages/modules/Bluetooth/system/blueberry \
		-P llvm_binutils -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) \
		-f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov \
		-f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata \
+1 −1
Original line number Diff line number Diff line
syntax = "proto3";

package bluetooth.facade;
package blueberry.facade;

message Data {
  bytes payload = 1;
+20 −0
Original line number Diff line number Diff line
syntax = "proto3";

package blueberry.facade.hal;

import "google/protobuf/empty.proto";
import "blueberry/facade/common.proto";

service HciHalFacade {
  rpc SendCommand(blueberry.facade.Data) returns (google.protobuf.Empty) {}
  rpc StreamEvents(google.protobuf.Empty) returns (stream blueberry.facade.Data) {}

  rpc SendAcl(blueberry.facade.Data) returns (google.protobuf.Empty) {}
  rpc StreamAcl(google.protobuf.Empty) returns (stream blueberry.facade.Data) {}

  rpc SendSco(blueberry.facade.Data) returns (google.protobuf.Empty) {}
  rpc StreamSco(google.protobuf.Empty) returns (stream blueberry.facade.Data) {}

  rpc SendIso(blueberry.facade.Data) returns (google.protobuf.Empty) {}
  rpc StreamIso(google.protobuf.Empty) returns (stream blueberry.facade.Data) {}
}
+1 −1
Original line number Diff line number Diff line
syntax = "proto3";

package bluetooth.hci;
package blueberry.facade.hci;

import "google/protobuf/empty.proto";

Loading