Skip to content

Commit a99bb07

Browse files
XToripururestyled-commitsarkq
authored
[Tizen] Use valid QEMU binary (#35715)
* 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>
1 parent 9254bbd commit a99bb07

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

third_party/tizen/tizen_qemu.py

+31-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@
1919
import os
2020
import re
2121
import shlex
22+
import shutil
2223
import subprocess
2324
import sys
2425

2526
# Absolute path to Tizen Studio CLI tool.
26-
tizen_sdk_root = os.environ["TIZEN_SDK_ROOT"]
27+
tizen_sdk_root = os.environ.get("TIZEN_SDK_ROOT", "")
28+
29+
# Pigweed installation directory.
30+
pw_install_dir = os.environ.get("PW_PIGWEED_CIPD_INSTALL_DIR", "")
31+
32+
# Absolute path to default qemu-system-arm binary.
33+
qemu_system_arm = shutil.which("qemu-system-arm")
2734

2835
# Setup basic logging capabilities.
2936
logging.basicConfig(level=logging.DEBUG)
@@ -68,8 +75,30 @@
6875

6976
args = parser.parse_args()
7077

78+
79+
def whereis(binary_name):
80+
# Get the PATH environment variable.
81+
path_dirs = os.environ.get('PATH', '').split(os.pathsep)
82+
83+
# List to store found paths.
84+
found_paths = []
85+
86+
# Search for the binary in each directory.
87+
for directory in path_dirs:
88+
if found := shutil.which(binary_name, path=directory):
89+
found_paths.append(found)
90+
91+
return found_paths
92+
93+
94+
# If qemu-system-arm binary is from Pigweed prefer the next one in PATH if there is one.
95+
if pw_install_dir != "" and qemu_system_arm.startswith(pw_install_dir):
96+
binaries = whereis("qemu-system-arm")
97+
if len(binaries) > 1:
98+
qemu_system_arm = binaries[1]
99+
71100
qemu_args = [
72-
'qemu-system-arm',
101+
qemu_system_arm,
73102
'-monitor', 'null',
74103
'-serial', 'stdio',
75104
'-display', 'none',

0 commit comments

Comments
 (0)