File tree 1 file changed +31
-2
lines changed
1 file changed +31
-2
lines changed Original file line number Diff line number Diff line change 19
19
import os
20
20
import re
21
21
import shlex
22
+ import shutil
22
23
import subprocess
23
24
import sys
24
25
25
26
# 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" )
27
34
28
35
# Setup basic logging capabilities.
29
36
logging .basicConfig (level = logging .DEBUG )
68
75
69
76
args = parser .parse_args ()
70
77
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
+
71
100
qemu_args = [
72
- 'qemu-system-arm' ,
101
+ qemu_system_arm ,
73
102
'-monitor' , 'null' ,
74
103
'-serial' , 'stdio' ,
75
104
'-display' , 'none' ,
You can’t perform that action at this time.
0 commit comments