Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tizen] Use valid QEMU binary #35715

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions third_party/tizen/tizen_qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@
import os
import re
import shlex
import shutil
import subprocess
import sys

# Absolute path to Tizen Studio CLI tool.
tizen_sdk_root = os.environ["TIZEN_SDK_ROOT"]
tizen_sdk_root = os.environ.get("TIZEN_SDK_ROOT", "")

# Pigweed installation directory.
pw_install_dir = os.environ.get("PW_PIGWEED_CIPD_INSTALL_DIR", "")

# Absolute path to default qemu-system-arm binary.
qemu_system_arm = shutil.which("qemu-system-arm")

# Setup basic logging capabilities.
logging.basicConfig(level=logging.DEBUG)
Expand Down Expand Up @@ -68,8 +75,30 @@

args = parser.parse_args()


def whereis(binary_name):
# Get the PATH environment variable.
path_dirs = os.environ.get('PATH', '').split(os.pathsep)

# List to store found paths.
found_paths = []

# Search for the binary in each directory.
for directory in path_dirs:
if found := shutil.which(binary_name, path=directory):
found_paths.append(found)

return found_paths


# If qemu-system-arm binary is from Pigweed prefer the next one in PATH if there is one.
if pw_install_dir != "" and qemu_system_arm.startswith(pw_install_dir):
binaries = whereis("qemu-system-arm")
if len(binaries) > 1:
qemu_system_arm = binaries[1]

qemu_args = [
'qemu-system-arm',
qemu_system_arm,
'-monitor', 'null',
'-serial', 'stdio',
'-display', 'none',
Expand Down
Loading