Skip to content

Commit

Permalink
[Tizen] Use valid QEMU binary (#35715)
Browse files Browse the repository at this point in the history
* Use valid QEMU binary

* Restyled by autopep8

* Restyled by isort

* Rename function

* Use shutil.which instead of os.isfile

Co-authored-by: Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com>

---------

Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com>
  • Loading branch information
3 people authored Sep 23, 2024
1 parent 9254bbd commit a99bb07
Showing 1 changed file with 31 additions and 2 deletions.
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

0 comments on commit a99bb07

Please sign in to comment.