1313from glob import glob
1414import subprocess as sp
1515import sysconfig
16+ import shutil
1617
1718logger = logging .getLogger (__name__ )
1819
@@ -32,6 +33,11 @@ def log_modified():
3233 sys .stdout .write (F .read ())
3334 sys .stdout .write (os .linesep )
3435
36+ def whereis (cmd ):
37+ if hasattr (shutil , 'which' ): # >= py3.3
38+ loc = shutil .which (cmd )
39+ print ('{0}Found exec {1} at {2!r} {3}' .format (ANSI_CYAN , cmd , loc , ANSI_RESET ))
40+
3541def prepare_env ():
3642 '''HACK
3743 github actions yaml configuration doesn't allow
@@ -452,9 +458,7 @@ def call_make(args=None, **kws):
452458 makeargs = []
453459 else :
454460 makeargs = ['-j{0}' .format (parallel )]
455- if not is_make3 and ci ['os' ] != 'windows' :
456- # not available until make 3
457- # buggy on windows https://github.com/epics-base/ci-scripts/issues/84
461+ if not is_make3 :
458462 makeargs += ['-Otarget' ]
459463 if silent :
460464 makeargs += ['-s' ]
@@ -689,8 +693,10 @@ def setup_for_build(args):
689693 if ci ['os' ] == 'windows' :
690694 if os .path .exists (r'C:\Strawberry\perl\bin' ):
691695 # Put strawberry perl in front of the PATH (so that Git Perl is further behind)
696+ # Put Chocolatey\bin ahead to select correct make.exe
692697 logger .debug ('Adding Strawberry Perl in front of the PATH' )
693- os .environ ['PATH' ] = os .pathsep .join ([r'C:\Strawberry\c\bin' ,
698+ os .environ ['PATH' ] = os .pathsep .join ([r'C:\ProgramData\Chocolatey\bin' ,
699+ r'C:\Strawberry\c\bin' ,
694700 r'C:\Strawberry\perl\site\bin' ,
695701 r'C:\Strawberry\perl\bin' ,
696702 os .environ ['PATH' ]])
@@ -758,14 +764,6 @@ def setup_for_build(args):
758764 if re .match ('^test-results:' , line ):
759765 has_test_results = True
760766
761- # Check make version
762- if re .match (r'^GNU Make 3' , sp .check_output (['make' , '-v' ]).decode ('ascii' )):
763- is_make3 = True
764- logger .debug ('Check if make is a 3.x series: %s' , is_make3 )
765-
766- # apparently %CD% is handled automagically
767- os .environ ['TOP' ] = os .getcwd ()
768-
769767 addpaths = []
770768 for path in args .paths :
771769 try :
@@ -777,6 +775,18 @@ def setup_for_build(args):
777775
778776 os .environ ['PATH' ] = os .pathsep .join ([os .environ ['PATH' ]] + addpaths )
779777
778+ logger .debug ('Final PATH' )
779+ for loc in os .environ ['PATH' ].split (os .pathsep ):
780+ logger .debug (' %r' , loc )
781+
782+ # Check make version
783+ if re .match (r'^GNU Make 3' , sp .check_output (['make' , '-v' ]).decode ('ascii' )):
784+ is_make3 = True
785+ logger .debug ('Check if make is a 3.x series: %s' , is_make3 )
786+
787+ # apparently %CD% is handled automagically
788+ os .environ ['TOP' ] = os .getcwd ()
789+
780790 # Add EXTRA make arguments
781791 for tag in ['EXTRA' , 'EXTRA1' , 'EXTRA2' , 'EXTRA3' , 'EXTRA4' , 'EXTRA5' ]:
782792 val = os .environ .get (tag , "" )
@@ -1248,23 +1258,28 @@ def prepare(args):
12481258 setup_for_build (args )
12491259
12501260 print ('{0}EPICS_HOST_ARCH = {1}{2}' .format (ANSI_CYAN , os .environ ['EPICS_HOST_ARCH' ], ANSI_RESET ))
1261+ whereis ('make' )
12511262 print ('{0}$ make --version{1}' .format (ANSI_CYAN , ANSI_RESET ))
12521263 sys .stdout .flush ()
12531264 call_make (['--version' ], parallel = 0 )
1265+ whereis ('perl' )
12541266 print ('{0}$ perl --version{1}' .format (ANSI_CYAN , ANSI_RESET ))
12551267 sys .stdout .flush ()
12561268 sp .check_call (['perl' , '--version' ])
12571269
12581270 if re .match (r'^vs' , ci ['compiler' ]):
1271+ whereis ('cl' )
12591272 print ('{0}$ cl{1}' .format (ANSI_CYAN , ANSI_RESET ))
12601273 sys .stdout .flush ()
12611274 sp .check_call (['cl' ])
12621275 else :
12631276 cc = ci ['compiler' ]
1277+ whereis (cc )
12641278 print ('{0}$ {1} --version{2}' .format (ANSI_CYAN , cc , ANSI_RESET ))
12651279 sys .stdout .flush ()
12661280 sp .check_call ([cc , '--version' ])
12671281 if cxx :
1282+ whereis (cxx )
12681283 print ('{0}$ {1} --version{2}' .format (ANSI_CYAN , cxx , ANSI_RESET ))
12691284 sys .stdout .flush ()
12701285 sp .check_call ([cxx , '--version' ])
0 commit comments