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

Commit 495ce2c0 authored by Jizheng Chu's avatar Jizheng Chu Committed by Automerger Merge Worker
Browse files

Merge "Clean up ACTS from gd cert test artifact" am: 4786b942

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1897154

Change-Id: I55ebdbc1edd5de8838845af3ad3279e065ea98f6
parents 58c2e36f 4786b942
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -78,22 +78,16 @@ $(bluetooth_cert_src_and_bin_zip): $(SOONG_ZIP) $(LOCAL_cert_test_sources) \
LOCAL_cert_generated_py_zip := \
	$(SOONG_OUT_DIR)/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothFacadeAndCertGeneratedStub_py/gen/bluetooth_cert_generated_py.zip

LOCAL_acts_zip := $(HOST_OUT)/acts-dist/acts.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_cert_src_and_bin_zip := $(bluetooth_cert_src_and_bin_zip)
$(bluetooth_cert_tests_py_package_zip): PRIVATE_acts_zip := $(LOCAL_acts_zip)
$(bluetooth_cert_tests_py_package_zip): PRIVATE_cert_generated_py_zip := $(LOCAL_cert_generated_py_zip)
$(bluetooth_cert_tests_py_package_zip): $(SOONG_ZIP) $(LOCAL_acts_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
	@rm -rf $(dir $@)acts
	@mkdir -p $(dir $@)bluetooth_cert_tests
	@mkdir -p $(dir $@)acts
	$(hide) unzip -o -q $(PRIVATE_acts_zip) "tools/test/connectivity/acts/framework/*" -d $(dir $@)acts
	$(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
@@ -102,8 +96,6 @@ $(bluetooth_cert_tests_py_package_zip): $(SOONG_ZIP) $(LOCAL_acts_zip) \
					-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 acts_framework \
		-C $(dir $@)acts/tools/test/connectivity/acts/framework -D $(dir $@)acts/tools/test/connectivity/acts/framework \
		-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 \
+9 −33
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import sys
install_requires = [
    'grpcio',
    'psutil',
    'protobuf>=3.14.0',
]

host_executables = [
@@ -37,20 +38,6 @@ host_executables = [
]


# Need to verify acts is importable in a new Python context
def is_acts_importable():
    cmd = [sys.executable, '-c', 'import acts']
    completed_process = subprocess.run(cmd, cwd=os.getcwd())
    return completed_process.returncode == 0


def setup_acts_for_cmd_or_die(cmd_str):
    acts_framework_dir = os.path.abspath('acts_framework')
    acts_setup_bin = os.path.join(acts_framework_dir, 'setup.py')
    cmd = [sys.executable, acts_setup_bin, cmd_str]
    subprocess.run(cmd, cwd=acts_framework_dir, check=True)


def set_permissions_for_host_executables(outputs):
    for file in outputs:
        if os.path.basename(file) in host_executables:
@@ -62,24 +49,15 @@ def set_permissions_for_host_executables(outputs):

class InstallLocalPackagesForInstallation(install):

    user_options = install.user_options + [
        ('reuse-acts', None, "Skip ACTS installation if already installed"),
    ]
    boolean_options = install.boolean_options + ['reuse-acts']
    def run(self):
        install_args = [sys.executable, '-m', 'pip', 'install']
        subprocess.check_call(install_args + ['--upgrade', 'pip'])

    def initialize_options(self):
        install.initialize_options(self)
        self.reuse_acts = False
        for package in install_requires:
            self.announce('Installing %s...' % package, log.INFO)
            subprocess.check_call(install_args + ['-v', '--no-cache-dir', package])
        self.announce('Dependencies installed.')

    def run(self):
        if self.reuse_acts and is_acts_importable():
            self.announce('Reusing existing ACTS installation', log.WARN)
        else:
            self.announce('Installing ACTS library', log.WARN)
            setup_acts_for_cmd_or_die("install")
            self.announce('ACTS installed.', log.WARN)
        if not is_acts_importable():
            raise DistutilsModuleError("Cannot import acts after installation")
        install.run(self)
        set_permissions_for_host_executables(self.get_outputs())

@@ -98,12 +76,10 @@ def main():
        description="""Bluetooth Cert Tests Package""",
        # Include root package so that bluetooth_packets_python3.so can be
        # included as well
        packages=[''] +
        find_packages(exclude=['acts_framework', 'acts_framework.*', 'llvm_binutils', 'llvm_binutils.*']),
        packages=[''] + find_packages(exclude=['llvm_binutils', 'llvm_binutils.*']),
        install_requires=install_requires,
        package_data={
            '': host_executables + ['*.so', 'lib64/*.so', 'target/*', 'llvm_binutils/bin/*', 'llvm_binutils/lib64/*'],
            'cert': ['all_test_cases'],
        },
        cmdclass={
            'install': InstallLocalPackagesForInstallation,