Add compiler-class and compiler-suffix as config

This commit is contained in:
Ralph Lange
2021-02-08 13:49:25 +01:00
parent cef930dd06
commit 2016cb2ae7

50
cue.py
View File

@@ -98,6 +98,9 @@ def detect_context():
if 'BCFG' in os.environ:
buildconfig = os.environ['BCFG'].lower()
ci['compiler-suffix'] = re.sub(r'^.*?(-[0-9.]+|)$', r'\1', ci['compiler'])
ci['compiler-class'] = re.sub(r'^([^0-9.-]*).*?$', r'\1', ci['compiler'])
if re.search('static', buildconfig):
ci['static'] = True
if re.search('debug', buildconfig):
@@ -615,7 +618,7 @@ def add_dependency(dep):
def detect_epics_host_arch():
if ci['os'] == 'windows':
if re.match(r'^vs', ci['compiler']):
if ci['compiler-class'] == 'vs':
# there is no combined static and debug EPICS_HOST_ARCH target,
# so a combined debug and static target will appear to be just static
# but debug will have been specified in CONFIG_SITE by prepare()
@@ -630,7 +633,7 @@ def detect_epics_host_arch():
elif ci['platform'] == 'x64':
os.environ['EPICS_HOST_ARCH'] = 'windows-x64' + hostarchsuffix
elif ci['compiler'] == 'gcc':
elif ci['compiler-class'] == 'gcc':
if ci['platform'] == 'x86':
os.environ['EPICS_HOST_ARCH'] = 'win32-x86-mingw'
elif ci['platform'] == 'x64':
@@ -666,7 +669,7 @@ def setup_for_build(args):
r'C:\Strawberry\perl\bin',
os.environ['PATH']])
if ci['service'] == 'appveyor' and ci['compiler'] == 'gcc':
if ci['service'] == 'appveyor' and ci['compiler-class'] == 'gcc':
logger.debug('Adding AppVeyor MSYS2/MinGW installation to PATH and INCLUDE')
if 'INCLUDE' not in os.environ:
os.environ['INCLUDE'] = ''
@@ -832,7 +835,7 @@ def prepare(args):
.format(optitype, linktype))
# Enable/fix parallel build for VisualStudio compiler on older Base versions
if ci['os'] == 'windows' and re.match(r'^vs', ci['compiler']):
if ci['os'] == 'windows' and ci['compiler-class'] == 'vs':
add_vs_fix = True
config_win = os.path.join(places['EPICS_BASE'], 'configure', 'os', 'CONFIG.win32-x86.win32-x86')
with open(config_win) as f:
@@ -903,33 +906,32 @@ CROSS_COMPILER_TARGET_ARCHS += RTEMS-pc386{0}'''.format(qemu_suffix))
print('Host compiler', ci['compiler'])
if ci['compiler'].startswith('clang'):
if ci['compiler-class'] == 'clang':
with open(os.path.join(places['EPICS_BASE'], 'configure', 'os',
'CONFIG_SITE.Common.'+os.environ['EPICS_HOST_ARCH']), 'a') as f:
'CONFIG_SITE.{0}.{0}'.format(os.environ['EPICS_HOST_ARCH'])), 'a') as f:
f.write('''
GNU = NO
CMPLR_CLASS = clang
CC = {0}
CCC = {1}'''.format(ci['compiler'],
re.sub(r'clang', r'clang++', ci['compiler'])))
GNU = NO
CMPLR_CLASS = clang
CC = clang
CCC = clang++''')
if ci['compiler-suffix']:
f.write('''
CMPLR_SUFFIX = {0}'''.format(ci['compiler-suffix']))
# hack
with open(os.path.join(places['EPICS_BASE'], 'configure', 'CONFIG.gnuCommon'), 'a') as f:
f.write('''
CMPLR_CLASS = clang''')
elif ci['compiler'].startswith('gcc'):
elif ci['compiler-class'] == 'gcc':
with open(os.path.join(places['EPICS_BASE'], 'configure', 'os',
'CONFIG_SITE.Common.' + os.environ['EPICS_HOST_ARCH']), 'a') as f:
'CONFIG_SITE.{0}.{0}'.format(os.environ['EPICS_HOST_ARCH'])), 'a') as f:
f.write('''
CC = {0}
CCC = {1}'''.format(ci['compiler'], re.sub(r'gcc', r'g++', ci['compiler'])))
CMPLR_CLASS = gcc''')
if ci['compiler-suffix']:
f.write('''
CMPLR_SUFFIX = {0}'''.format(ci['compiler-suffix']))
elif ci['compiler'].startswith('vs'):
elif ci['compiler-class'] =='vs':
pass # nothing special
else:
raise ValueError('Unknown compiler name {0}. valid forms include: gcc, gcc-4.8, clang, vs2019'.format(ci['compiler']))
raise ValueError('Unknown compiler name {0}. Valid forms include: gcc, gcc-4.8, clang, vs2019'.format(ci['compiler']))
# Add additional settings to CONFIG_SITE
extra_config = ''
@@ -996,7 +998,7 @@ PERL = C:/Strawberry/perl/bin/perl -CSD'''
sys.stdout.flush()
sp.check_call(['perl', '--version'])
if re.match(r'^vs', ci['compiler']):
if ci['compiler-class'] == 'vs':
print('{0}$ cl{1}'.format(ANSI_CYAN, ANSI_RESET))
sys.stdout.flush()
sp.check_call(['cl'])
@@ -1162,7 +1164,7 @@ def main(raw):
prepare_env()
detect_context()
if args.vcvars and ci['compiler'].startswith('vs'):
if args.vcvars and ci['compiler-class'] == 'vs':
# re-exec with MSVC in PATH
with_vcvars(' '.join(['--no-vcvars'] + raw))
else: