Skip to content

Commit

Permalink
Support multiple installation of avd configs
Browse files Browse the repository at this point in the history
This is done by specifying a common CIPD root
<chromium_src>/.android_emulator, and installing each avd config under
a separate sub directory.

Bug: 1278016
Change-Id: Iaaed9542a74c1257478fd9e220e9f13df97c1c2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3482176
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Haiyang Pan <hypan@google.com>
Cr-Commit-Position: refs/heads/main@{#974269}
  • Loading branch information
Haiyang Pan authored and Chromium LUCI CQ committed Feb 23, 2022
1 parent 51e8691 commit 0fee365
Show file tree
Hide file tree
Showing 33 changed files with 1,162 additions and 2,588 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Thumbs.db
rust-project.json
v8.log
vs-chromium-project.txt
# Store android emulator artifacts, used by //tools/android/avd/avd.py
/.android_emulator/
/.clangd
/.clangd/
/.clangd-index/
Expand Down
10 changes: 7 additions & 3 deletions build/android/pylib/local/emulator/avd.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
from pylib.local.emulator import ini
from pylib.local.emulator.proto import avd_pb2

# A common root directory to store the CIPD packages for creating or starting
# the emulator instance, e.g. emulator binary, system images, AVDs.
COMMON_CIPD_ROOT = os.path.join(constants.DIR_SOURCE_ROOT, '.android_emulator')

_ALL_PACKAGES = object()
_DEFAULT_AVDMANAGER_PATH = os.path.join(
constants.ANDROID_SDK_ROOT, 'cmdline-tools', 'latest', 'bin', 'avdmanager')
Expand Down Expand Up @@ -193,10 +197,10 @@ def __init__(self, avd_proto_path):
self.avd_proto_path = avd_proto_path
self._config = _Load(avd_proto_path)

self._emulator_home = os.path.join(constants.DIR_SOURCE_ROOT,
self._emulator_home = os.path.join(COMMON_CIPD_ROOT,
self._config.avd_package.dest_path)
self._emulator_sdk_root = os.path.join(
constants.DIR_SOURCE_ROOT, self._config.emulator_package.dest_path)
COMMON_CIPD_ROOT, self._config.emulator_package.dest_path)
self._emulator_path = os.path.join(self._emulator_sdk_root, 'emulator',
'emulator')

Expand Down Expand Up @@ -491,7 +495,7 @@ def _IterVersionedCipdPackages(self, packages):
pkgs_by_dir[pkg.dest_path].append(pkg)

for pkg_dir, pkgs in pkgs_by_dir.items():
cipd_root = os.path.join(constants.DIR_SOURCE_ROOT, pkg_dir)
cipd_root = os.path.join(COMMON_CIPD_ROOT, pkg_dir)
yield cipd_root, pkgs

def _InstallCipdPackages(self, packages):
Expand Down
2 changes: 1 addition & 1 deletion build/android/pylib/local/emulator/proto/avd.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ message CIPDPackage {
// Ignored when creating AVD packages.
string version = 2;
// Path into which the package should be installed.
// src-relative.
// relative to pylib.local.emulator.avd.COMMON_CIPD_ROOT.
string dest_path = 3;
}

Expand Down
Loading

0 comments on commit 0fee365

Please sign in to comment.