1LOCAL_PATH := $(call my-dir)
2
3#LINT.IfChange
4LOCAL_cert_test_sources := \
5	$(call all-named-files-under,*.py,.) \
6	cert/all_cert_testcases
7LOCAL_cert_test_sources := \
8	$(filter-out gd_cert_venv% venv%, $(LOCAL_cert_test_sources))
9LOCAL_cert_test_sources := \
10	$(addprefix $(LOCAL_PATH)/, $(LOCAL_cert_test_sources))
11
12LOCAL_host_executables := \
13	$(HOST_OUT_EXECUTABLES)/bluetooth_stack_with_facade \
14	$(HOST_OUT_EXECUTABLES)/bluetooth_with_facades \
15	$(HOST_OUT_EXECUTABLES)/root-canal
16
17LOCAL_host_python_extension_libraries := \
18	$(HOST_OUT_SHARED_LIBRARIES)/bluetooth_packets_python3.so
19
20LOCAL_host_libraries := \
21	$(HOST_OUT_SHARED_LIBRARIES)/libbase.so \
22	$(HOST_OUT_SHARED_LIBRARIES)/libbluetooth_gd.so \
23	$(HOST_OUT_SHARED_LIBRARIES)/libc++.so \
24	$(HOST_OUT_SHARED_LIBRARIES)/libchrome.so \
25	$(HOST_OUT_SHARED_LIBRARIES)/libcrypto-host.so \
26	$(HOST_OUT_SHARED_LIBRARIES)/libevent-host.so \
27	$(HOST_OUT_SHARED_LIBRARIES)/libgrpc++_unsecure.so \
28	$(HOST_OUT_SHARED_LIBRARIES)/libgrpc++.so \
29	$(HOST_OUT_SHARED_LIBRARIES)/libgrpc_wrap.so \
30	$(HOST_OUT_SHARED_LIBRARIES)/liblog.so \
31	$(HOST_OUT_SHARED_LIBRARIES)/libssl-host.so \
32	$(HOST_OUT_SHARED_LIBRARIES)/libz-host.so \
33	$(HOST_OUT_SHARED_LIBRARIES)/libprotobuf-cpp-full.so \
34	$(HOST_OUT_SHARED_LIBRARIES)/libunwindstack.so \
35	$(HOST_OUT_SHARED_LIBRARIES)/liblzma.so \
36	$(HOST_OUT_SHARED_LIBRARIES)/libbacktrace.so
37
38LOCAL_target_executables := \
39	$(TARGET_OUT_EXECUTABLES)/bluetooth_stack_with_facade
40
41LOCAL_target_libraries := \
42	$(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so \
43	$(TARGET_OUT_SHARED_LIBRARIES)/libbluetooth_gd.so \
44	$(TARGET_OUT_SHARED_LIBRARIES)/libgrpc++_unsecure.so
45#LINT.ThenChange(cert/run)
46
47bluetooth_cert_src_and_bin_zip := \
48	$(call intermediates-dir-for,PACKAGING,bluetooth_cert_src_and_bin,HOST)/bluetooth_cert_src_and_bin.zip
49
50# Assume 64-bit OS
51$(bluetooth_cert_src_and_bin_zip): PRIVATE_cert_test_sources := $(LOCAL_cert_test_sources)
52$(bluetooth_cert_src_and_bin_zip): PRIVATE_host_executables := $(LOCAL_host_executables)
53$(bluetooth_cert_src_and_bin_zip): PRIVATE_host_python_extension_libraries := $(LOCAL_host_python_extension_libraries)
54$(bluetooth_cert_src_and_bin_zip): PRIVATE_host_libraries := $(LOCAL_host_libraries)
55$(bluetooth_cert_src_and_bin_zip): PRIVATE_target_executables := $(LOCAL_target_executables)
56$(bluetooth_cert_src_and_bin_zip): PRIVATE_target_libraries := $(LOCAL_target_libraries)
57$(bluetooth_cert_src_and_bin_zip): $(SOONG_ZIP) $(LOCAL_cert_test_sources) \
58		$(LOCAL_host_executables) $(LOCAL_host_libraries) $(LOCAL_host_python_extension_libraries) \
59		$(LOCAL_target_executables) $(LOCAL_target_libraries)
60	$(hide) $(SOONG_ZIP) -d -o $@ \
61		-C system/bt/gd $(addprefix -f ,$(PRIVATE_cert_test_sources)) \
62		-C $(HOST_OUT_EXECUTABLES) $(addprefix -f ,$(PRIVATE_host_executables)) \
63		-C $(HOST_OUT_SHARED_LIBRARIES) $(addprefix -f ,$(PRIVATE_host_python_extension_libraries)) \
64		-P lib64 \
65		-C $(HOST_OUT_SHARED_LIBRARIES) $(addprefix -f ,$(PRIVATE_host_libraries)) \
66		-P target \
67		-C $(TARGET_OUT_EXECUTABLES) $(addprefix -f ,$(PRIVATE_target_executables)) \
68		-C $(TARGET_OUT_SHARED_LIBRARIES) $(addprefix -f ,$(PRIVATE_target_libraries))
69
70# TODO: Find a better way to locate output from SOONG genrule()
71LOCAL_cert_generated_py_zip := \
72	$(SOONG_OUT_DIR)/.intermediates/system/bt/gd/BluetoothFacadeAndCertGeneratedStub_py/gen/bluetooth_cert_generated_py.zip
73
74LOCAL_acts_zip := $(HOST_OUT)/acts-dist/acts.zip
75
76bluetooth_cert_tests_py_package_zip := \
77	$(call intermediates-dir-for,PACKAGING,bluetooth_cert_tests_py_package,HOST)/bluetooth_cert_tests.zip
78
79$(bluetooth_cert_tests_py_package_zip): PRIVATE_cert_src_and_bin_zip := $(bluetooth_cert_src_and_bin_zip)
80$(bluetooth_cert_tests_py_package_zip): PRIVATE_acts_zip := $(LOCAL_acts_zip)
81$(bluetooth_cert_tests_py_package_zip): PRIVATE_cert_generated_py_zip := $(LOCAL_cert_generated_py_zip)
82$(bluetooth_cert_tests_py_package_zip): $(SOONG_ZIP) $(LOCAL_acts_zip) \
83		$(bluetooth_cert_src_and_bin_zip) $(bluetooth_cert_generated_py_zip)
84	@echo "Packaging Bluetooth Cert Tests into $@"
85	@rm -rf $(dir $@)bluetooth_cert_tests
86	@rm -rf $(dir $@)acts
87	@mkdir -p $(dir $@)bluetooth_cert_tests
88	@mkdir -p $(dir $@)acts
89	$(hide) unzip -o -q $(PRIVATE_acts_zip) "tools/test/connectivity/acts/framework/*" -d $(dir $@)acts
90	$(hide) unzip -o -q $(PRIVATE_cert_src_and_bin_zip) -d $(dir $@)bluetooth_cert_tests
91	$(hide) unzip -o -q $(PRIVATE_cert_generated_py_zip) -d $(dir $@)bluetooth_cert_tests
92	# Make all subdirectory of gd Python pacakages except lib64 and target
93	$(hide) for f in `find $(dir $@)bluetooth_cert_tests -type d -name "*" \
94					-not -path "$(dir $@)bluetooth_cert_tests/target*" \
95					-not -path "$(dir $@)bluetooth_cert_tests/lib64*"` \
96			; do (touch -a $$f/__init__.py) ; done
97	$(hide) $(SOONG_ZIP) -d -o $@ -C $(dir $@)bluetooth_cert_tests -D $(dir $@)bluetooth_cert_tests \
98		-P acts_framework \
99		-C $(dir $@)acts/tools/test/connectivity/acts/framework -D $(dir $@)acts/tools/test/connectivity/acts/framework \
100		-P llvm_binutils -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) \
101		-f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov \
102		-f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata \
103		-f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-symbolizer \
104		-f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
105
106$(call dist-for-goals,bluetooth_stack_with_facade,$(bluetooth_cert_tests_py_package_zip):bluetooth_cert_tests.zip)
107