aboutsummaryrefslogtreecommitdiff
path: root/gen_android_bp.py
diff options
context:
space:
mode:
Diffstat (limited to 'gen_android_bp.py')
-rw-r--r--gen_android_bp.py73
1 files changed, 38 insertions, 35 deletions
diff --git a/gen_android_bp.py b/gen_android_bp.py
index 7c02aec..57979b7 100644
--- a/gen_android_bp.py
+++ b/gen_android_bp.py
@@ -46,8 +46,8 @@ def tool_name() -> str:
class Architecture(Enum):
"""Host instruction set architectures."""
- AARCH64 = auto()
- X86_64 = auto()
+ AARCH64 = 'aarch64'
+ X86_64 = 'x86_64'
def dir(self) -> Path:
"Returns the relative directory path to the specified architecture."
@@ -195,7 +195,7 @@ def crosvm_binaries(arch: Architecture) -> Iterator[Path]:
def qemu_binaries(arch: Architecture) -> Iterator[Path]:
"""Lists qemu binary paths."""
- dir = Path("qemu/x86_64-linux-gnu/bin")
+ dir = Path(f"qemu/{arch.value}-linux-gnu/bin")
yield from dir.glob("*.so.?")
yield from dir.glob("qemu-system*")
@@ -220,37 +220,39 @@ def gen_main_android_bp_modules() -> Iterator[Module]:
),
)
- for binary_path in qemu_binaries(Architecture.X86_64):
- yield Module(
- "cc_prebuilt_binary",
- dict(
- name=f"x86_64_linux_gnu_{binary_path.name}_binary_for_qemu",
- srcs=[binary_path],
- stem=binary_path.name,
- defaults=["cuttlefish_host"],
- check_elf_files=False,
- ),
- )
+ for arch in list(Architecture):
+ for binary_path in qemu_binaries(arch):
+ yield Module(
+ "cc_prebuilt_binary",
+ dict(
+ name=f"{arch.value}_linux_gnu_{binary_path.name}_binary_for_qemu",
+ srcs=[binary_path],
+ stem=binary_path.name,
+ relative_install_path=arch.dir() / "qemu",
+ defaults=["cuttlefish_host"],
+ check_elf_files=False,
+ ),
+ )
resource_paths = [
- Path("qemu/efi-virtio.rom"),
- Path("qemu/keymaps/en-us"),
- Path("qemu/opensbi-riscv64-generic-fw_dynamic.bin"),
+ Path(f"efi-virtio.rom"),
+ Path(f"keymaps/en-us"),
+ Path(f"opensbi-riscv64-generic-fw_dynamic.bin"),
]
- for resource_path in resource_paths:
- base_name = resource_path.name
- arch = "x86_64"
- sub_dir = resource_path.parent
- yield Module(
- "prebuilt_usr_share_host",
- dict(
- name=f"{arch}_{base_name}_resource_for_qemu",
- src=f"qemu/x86_64-linux-gnu/usr/share/{resource_path}",
- filename=base_name,
- sub_dir=sub_dir,
- ),
- )
+ for arch in list(Architecture):
+ for resource_path in resource_paths:
+ base_name = resource_path.name
+ subdir = f"qemu/{arch.value}-linux-gnu" / resource_path.parents[0]
+ yield Module(
+ "prebuilt_usr_share_host",
+ dict(
+ name=f"{arch.value}_{base_name}_resource_for_qemu",
+ src=f"qemu/{arch.value}-linux-gnu/usr/share/qemu/{resource_path}",
+ filename=base_name,
+ sub_dir=subdir,
+ ),
+ )
def gen_main_android_bp_file(android_bp_path: Path, modules: List[Module]):
@@ -288,16 +290,17 @@ def gen_main_android_bp_file(android_bp_path: Path, modules: List[Module]):
def generate_all_cuttlefish_host_package_android_bp(path: Path, modules: list[Module]):
"""Updates the list of module in 'device/google/cuttlefish/Android.bp'."""
- qemu_binaries = [m for m in modules if m.name.endswith("_binary_for_qemu")]
- qemu_resources = [m for m in modules if m.name.endswith("_resource_for_qemu")]
-
def update_list(list_name: str, modules:list[Module]):
names = sorted(m.parameters["name"] for m in modules)
text = f"{list_name} = {value_to_bp(names)}\n"
update_generated_section(path, list_name, text)
- update_list("qemu_x86_64_linux_gnu_binary", qemu_binaries)
- update_list("qemu_x86_64_linux_gnu_resource", qemu_resources)
+ for arch in list(Architecture):
+ qemu_binaries = [m for m in modules if m.name.endswith("_binary_for_qemu") and m.name.startswith(arch.value)]
+ qemu_resources = [m for m in modules if m.name.endswith("_resource_for_qemu") and m.name.startswith(arch.value)]
+
+ update_list(f"qemu_{arch.value}_linux_gnu_binary", qemu_binaries)
+ update_list(f"qemu_{arch.value}_linux_gnu_resource", qemu_resources)
def main(argv):