diff options
author | James Farrell <jamesfarrell@google.com> | 2022-10-17 15:28:01 +0000 |
---|---|---|
committer | James Farrell <jamesfarrell@google.com> | 2022-10-31 17:34:15 +0000 |
commit | 1ffe90343f3ff005432e49dce56fc0eca880e1c1 (patch) | |
tree | 351b04e2d3ba407e743cb0a1286780e914813488 | |
parent | aa11deb4141df2f0a1da5be7d448b55702f7d633 (diff) | |
download | ndk-1ffe90343f3ff005432e49dce56fc0eca880e1c1.tar.gz |
Run packaging in parallel.
Also show some UI when packaging and building tests.
Change-Id: I97bc7e03117958f42da129e9c2e953b49f70c438
-rwxr-xr-x | ndk/checkbuild.py | 79 | ||||
-rwxr-xr-x | ndk/run_tests.py | 14 | ||||
-rw-r--r-- | ndk/test/builder.py | 9 | ||||
-rw-r--r-- | ndk/ui.py | 18 |
4 files changed, 85 insertions, 35 deletions
diff --git a/ndk/checkbuild.py b/ndk/checkbuild.py index bbb69add4..ce9fed7be 100755 --- a/ndk/checkbuild.py +++ b/ndk/checkbuild.py @@ -174,7 +174,11 @@ def create_signer_metadata(package_dir: Path) -> None: def make_app_bundle( - zip_path: Path, ndk_dir: Path, build_number: str, build_dir: Path + worker: ndk.workqueue.Worker, + zip_path: Path, + ndk_dir: Path, + build_number: str, + build_dir: Path, ) -> None: """Builds a macOS App Bundle of the NDK. @@ -195,6 +199,7 @@ def make_app_bundle( ndk_dir: The path to the NDK being bundled. build_dir: The path to the top level build directory. """ + worker.status = "Packaging MacOS App Bundle" package_dir = build_dir / "bundle" app_directory_name = f"AndroidNDK{build_number}.app" bundle_dir = package_dir / app_directory_name @@ -221,6 +226,32 @@ def make_app_bundle( ) +def make_brtar( + worker: ndk.workqueue.Worker, + base_name: Path, + root_dir: Path, + base_dir: Path, + preserve_symlinks: bool, +) -> None: + worker.status = "Packaging .tar.br" + ndk.archive.make_brtar( + base_name, root_dir, base_dir, preserve_symlinks=preserve_symlinks + ) + + +def make_zip( + worker: ndk.workqueue.Worker, + base_name: Path, + root_dir: Path, + paths: List[str], + preserve_symlinks: bool, +) -> None: + worker.status = "Packaging .zip" + ndk.archive.make_zip( + base_name, root_dir, paths, preserve_symlinks=preserve_symlinks + ) + + def package_ndk( ndk_dir: Path, out_dir: Path, dist_dir: Path, host: Host, build_number: str ) -> Path: @@ -238,24 +269,36 @@ def package_ndk( purge_unwanted_files(ndk_dir) - if host == Host.Darwin: - bundle_name = f"android-ndk-{build_number}-app-bundle" - bundle_path = dist_dir / bundle_name - make_app_bundle(bundle_path, ndk_dir, build_number, out_dir) + workqueue: ndk.workqueue.WorkQueue = ndk.workqueue.WorkQueue() + try: + if host == Host.Darwin: + workqueue.add_task( + make_app_bundle, + dist_dir / f"android-ndk-{build_number}-app-bundle", + ndk_dir, + build_number, + out_dir, + ) + workqueue.add_task( + make_brtar, + package_path, + ndk_dir.parent, + Path(ndk_dir.name), + preserve_symlinks=(host != Host.Windows64), + ) + workqueue.add_task( + make_zip, + package_path, + ndk_dir.parent, + [ndk_dir.name], + preserve_symlinks=(host != Host.Windows64), + ) + ndk.ui.finish_workqueue_with_ui(workqueue, ndk.ui.get_build_progress_ui) + finally: + workqueue.terminate() + workqueue.join() # TODO: Treat the .tar.br archive as authoritative and return its path. - # TODO: Create archives in parallel. - ndk.archive.make_brtar( - package_path, - ndk_dir.parent, - Path(ndk_dir.name), - preserve_symlinks=(host != Host.Windows64), - ) - return ndk.archive.make_zip( - package_path, - ndk_dir.parent, - [ndk_dir.name], - preserve_symlinks=(host != Host.Windows64), - ) + return package_path.with_suffix(".zip") def build_ndk_tests(out_dir: Path, dist_dir: Path, args: argparse.Namespace) -> bool: diff --git a/ndk/run_tests.py b/ndk/run_tests.py index a5fea2171..fd9c60094 100755 --- a/ndk/run_tests.py +++ b/ndk/run_tests.py @@ -198,18 +198,6 @@ def push_tests_to_device( device.shell(["chmod", "-R", "777", str(dest_dir)]) -def finish_workqueue_with_ui(workqueue: WorkQueue) -> None: - console = ndk.ansi.get_console() - ui = ndk.ui.get_work_queue_ui(console, workqueue) - with ndk.ansi.disable_terminal_echo(sys.stdin): - with console.cursor_hide_context(): - ui.draw() - while not workqueue.finished(): - workqueue.get_result() - ui.draw() - ui.clear() - - def push_tests_to_devices( workqueue: WorkQueue, test_dir: Path, @@ -225,7 +213,7 @@ def push_tests_to_devices( push_tests_to_device, src_dir, dest_dir, config, device, use_sync ) - finish_workqueue_with_ui(workqueue) + ndk.ui.finish_workqueue_with_ui(workqueue, ndk.ui.get_work_queue_ui) print("Finished pushing tests") diff --git a/ndk/test/builder.py b/ndk/test/builder.py index 2f445bee8..9db6ddb0f 100644 --- a/ndk/test/builder.py +++ b/ndk/test/builder.py @@ -44,6 +44,7 @@ from ndk.test.report import Report import ndk.test.spec import ndk.test.suites import ndk.test.ui +import ndk.ui from ndk.workqueue import LoadRestrictingWorkQueue, Worker, WorkQueue @@ -328,15 +329,14 @@ class TestBuilder: test_groups, DeviceConfig([abi], device_version), ) - while not workqueue.finished(): - workqueue.get_result() + ndk.ui.finish_workqueue_with_ui(workqueue, ndk.ui.get_build_progress_ui) finally: workqueue.terminate() workqueue.join() def _make_tradefed_zip( - _worker: Worker, + worker: Worker, test_options: ndk.test.spec.TestOptions, test_groups: dict[ ndk.test.spec.BuildConfiguration, list[ndk.test.devicetest.case.TestCase] @@ -353,6 +353,9 @@ def _make_tradefed_zip( Returns: Nothing. """ + worker.status = ( + f"Packaging tests for SDK {device_config.version}, {device_config.abis[0]}" + ) abi = device_config.abis[0] api = device_config.version @@ -22,7 +22,7 @@ import math import os import sys import time -from typing import Iterable, List, Optional, Tuple, cast +from typing import Callable, Iterable, List, Optional, Tuple, cast import ndk.ansi from ndk.workqueue import AnyWorkQueue @@ -262,3 +262,19 @@ class WorkQueueUi(Ui): ) ) return lines + + +def finish_workqueue_with_ui( + workqueue: ndk.workqueue.WorkQueue, + ui_fn: Callable[[ndk.ansi.Console, ndk.workqueue.WorkQueue], Ui], +) -> None: + console = ndk.ansi.get_console() + ui = ui_fn(console, workqueue) + with ndk.ansi.disable_terminal_echo(sys.stdin): + with console.cursor_hide_context(): + ui.draw() + while not workqueue.finished(): + ui.draw() + workqueue.get_result() + ui.draw() + ui.clear() |