diff --git a/cue-test.py b/cue-test.py index d6ba3aa..6d253c1 100644 --- a/cue-test.py +++ b/cue-test.py @@ -822,6 +822,7 @@ def setUp(self): def tearDown(self): os.environ.pop('EPICS_HOST_ARCH', None) + os.environ.pop('MAKEFLAGS', None) cue.clear_lists() def test_AddPathsOption(self): @@ -900,6 +901,29 @@ def test_StrawberryInPath(self): 'Strawberry Perl location not in PATH (found PATH = {0})' .format(os.environ['PATH'])) + @unittest.skipIf(ci_os != 'windows' or ci_service == 'appveyor', + 'Make SHELL test only applies to windows (not AppVeyor)') + def test_MakeShellCmdForMinGW(self): + cue.ci['compiler'] = 'gcc' + os.environ['MAKEFLAGS'] = 'k' + cue.setup_for_build(self.args) + self.assertEqual(os.environ['MAKEFLAGS'], 'k SHELL=cmd', + 'SHELL=cmd not added to MAKEFLAGS (found MAKEFLAGS = {0})' + .format(os.environ['MAKEFLAGS'])) + cue.setup_for_build(self.args) + self.assertEqual(os.environ['MAKEFLAGS'], 'k SHELL=cmd', + 'SHELL=cmd added to MAKEFLAGS twice (found MAKEFLAGS = {0})' + .format(os.environ['MAKEFLAGS'])) + os.environ['MAKEFLAGS'] = 'SHELL=sh' + cue.setup_for_build(self.args) + self.assertEqual(os.environ['MAKEFLAGS'], 'SHELL=sh', + 'User setting of SHELL in MAKEFLAGS overridden') + os.environ.pop('MAKEFLAGS', None) + cue.ci['compiler'] = 'vs2019' + cue.setup_for_build(self.args) + self.assertFalse('MAKEFLAGS' in os.environ, + 'MAKEFLAGS set for Visual Studio compiler') + def setBase314(self, yesno): cfg_base_version = os.path.join('configure', 'CONFIG_BASE_VERSION') fout = open(cfg_base_version, 'w') diff --git a/cue.py b/cue.py index f529448..cc0fbd0 100644 --- a/cue.py +++ b/cue.py @@ -864,6 +864,14 @@ def setup_for_build(args): r'C:\Strawberry\perl\bin', os.environ['PATH']]) + if ci['service'] != 'appveyor' and ci['compiler'] == 'gcc': + # Git's sh.exe wrapper prepends Git's own MinGW runtime DLLs to PATH, + # which are incompatible with the Strawberry Perl compiler. + makeflags = os.environ.get('MAKEFLAGS', '') + if 'SHELL=' not in makeflags: + logger.debug('Setting SHELL=cmd in MAKEFLAGS') + os.environ['MAKEFLAGS'] = ' '.join(filter(None, [makeflags, 'SHELL=cmd'])) + if ci['service'] == 'appveyor' and ci['compiler'] == 'gcc': logger.debug('Adding AppVeyor MSYS2/MinGW installation to PATH and INCLUDE') if 'INCLUDE' not in os.environ: