@@ -451,34 +451,30 @@ def make(name, target=None, **makevars):
451
451
execute ('make' , * args )
452
452
453
453
454
- def require_header (header , lang , msg = '' , symbol = False , value = False ):
454
+ def require_header (header , lang , msg = '' , symbol = None , value = None ):
455
455
debug ('require_header "%s"' , header )
456
456
457
- cmd = {'c' :'{cc}' , 'c++' :'{cxx}' }[lang ]
458
- cmd = fill_in (cmd ).split () + ['-fsyntax-only' , '-x' , lang , '-' ]
459
- proc = subprocess .Popen (cmd , stdin = subprocess .PIPE , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
457
+ cmd = {'c' : '{cc}' , 'c++' : '{cxx}' }[lang ]
458
+ cmd = fill_in (cmd ).split ()
459
+ proc = subprocess .Popen (cmd + ['-fsyntax-only' , '-x' , lang , '-' ],
460
+ stdin = subprocess .PIPE ,
461
+ stdout = subprocess .PIPE ,
462
+ stderr = subprocess .PIPE )
460
463
461
- stdin_line = '#include <' + header + '>'
464
+ proc_stdin = [ '#include <%s>' % header ]
462
465
if symbol :
463
466
if value :
464
- stdin_line += """\n #if %s != %s
465
- #error
466
- #endif """ % (symbol , value )
467
+ proc_stdin .append ("#if %s != %s" % (symbol , value ))
467
468
else :
468
- stdin_line += """ \n #ifndef %s
469
- #error
470
- #endif """ % ( symbol )
469
+ proc_stdin . append ( " #ifndef %s" % symbol )
470
+ proc_stdin . append ( " #error" )
471
+ proc_stdin . append ( " #endif" )
471
472
472
- ( result_stdout , result_stderr ) = proc .communicate (stdin_line )
473
+ proc_stdout , proc_stderr = proc .communicate (' \n ' . join ( proc_stdin ) )
473
474
proc .wait ()
474
475
475
- cmd = ' ' .join (cmd )
476
-
477
- if proc .returncode == 0 :
478
- debug ('output from "%s":\n %s' , cmd , result_stdout )
479
- else :
480
- debug ('error output from "%s":\n %s' , cmd , result_stderr )
481
- panic ('require_header failed: %s' , msg )
476
+ if proc .returncode :
477
+ panic (msg )
482
478
483
479
484
480
__all__ = ['setvar' , 'panic' , 'cmpver' , 'find_executable' , 'chmod' , 'execute' ,
0 commit comments