|
8 | 8 | import linker
|
9 | 9 | import config
|
10 | 10 | import patcher
|
| 11 | +import subprocess |
11 | 12 | import pygccxml.utils
|
12 | 13 |
|
13 | 14 | try: #select the faster xml parser
|
@@ -148,16 +149,25 @@ def create_xml_file( self, header, destination=None ):
|
148 | 149 | if not os.path.isabs( ffname ):
|
149 | 150 | ffname = self.__file_full_name(header)
|
150 | 151 | command_line = self.__create_command_line( ffname, gccxml_file )
|
151 |
| - input_, output = os.popen4( command_line ) |
152 |
| - input_.close() |
| 152 | + |
| 153 | + process = subprocess.Popen( args=command_line |
| 154 | + , shell=True |
| 155 | + , stdin=subprocess.PIPE |
| 156 | + , stdout=subprocess.PIPE |
| 157 | + , stderr=subprocess.STDOUT ) |
| 158 | + process.stdin.close() |
| 159 | + |
153 | 160 | gccxml_reports = []
|
154 |
| - while True: |
155 |
| - data = output.readline() |
156 |
| - gccxml_reports.append( data ) |
157 |
| - if not data: |
158 |
| - break |
159 |
| - exit_status = output.close() |
160 |
| - gccxml_msg = ''.join(gccxml_reports) |
| 161 | + while process.poll() is None: |
| 162 | + line = process.stdout.readline() |
| 163 | + if line.strip(): |
| 164 | + gccxml_reports.append( line.rstrip() ) |
| 165 | + for line in process.stdout.readlines(): |
| 166 | + if line.strip(): |
| 167 | + gccxml_reports.append( line.rstrip() ) |
| 168 | + |
| 169 | + exit_status = process.returncode |
| 170 | + gccxml_msg = os.linesep.join(gccxml_reports) |
161 | 171 | if self.__config.ignore_gccxml_output:
|
162 | 172 | if not os.path.isfile(gccxml_file):
|
163 | 173 | raise gccxml_runtime_error_t( "Error occured while running GCC-XML: %s status:%s" % (gccxml_msg, exit_status) )
|
|
0 commit comments