@@ -89,18 +89,27 @@ def get_settings_from_makefile(port_dir, board_name):
89
89
into account, without having to re-encode the logic that sets them
90
90
in this script, something that has proved error-prone
91
91
"""
92
-
93
- status , contents = subprocess .getstatusoutput (f"make -C { port_dir } BOARD={ board_name } -qp print-CC" )
92
+ contents = subprocess .run (
93
+ ["make" , "-C" , port_dir , f"BOARD={ board_name } " , "-qp" , "print-CC" ],
94
+ encoding = "utf-8" ,
95
+ errors = "replace" ,
96
+ stdout = subprocess .PIPE ,
97
+ stderr = subprocess .PIPE
98
+ )
94
99
# Make signals errors with exit status 2; 0 and 1 are "non-error" statuses
95
- if status not in (0 , 1 ):
96
- raise RuntimeError (f'Invoking make exited with { status } ' )
97
- if isinstance (contents , bytes ):
98
- contents = contents .decode ('utf-8' , errors = 'replace' )
100
+ if contents .returncode not in (0 , 1 ):
101
+ error_msg = (
102
+ f"Invoking '{ ' ' .join (contents .args )} ' exited with "
103
+ f"{ contents .returncode } : { contents .stderr } "
104
+ )
105
+ raise RuntimeError (error_msg )
106
+
99
107
settings = {}
100
- for line in contents .split ('\n ' ):
108
+ for line in contents .stdout . split ('\n ' ):
101
109
m = re .match (r'^([A-Z][A-Z0-9_]*) = (.*)$' , line )
102
110
if m :
103
111
settings [m .group (1 )] = m .group (2 )
112
+
104
113
return settings
105
114
106
115
def lookup_setting (settings , key , default = '' ):
0 commit comments