From 8220ad187c2570a758b666ba7dbd068361aec1a2 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Mon, 18 Apr 2016 10:24:34 +1000 Subject: Add default RTEMS version support, environment var checking and CC version message. Allow an application the ability to set a version number for RTEMS. This avoids issues with the automatic detection code. It means an application becomes keyed to a specific version of RTEMS. Check the environment for variables being set that could effect a build. We allow the environment to do this but it can have a side effect such as CC being set for one architecture and the rtems_waf being asked to use another. Print the version of CC being used. This is a diagnostic. --- rtems.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/rtems.py b/rtems.py index f036c34..1926e31 100644 --- a/rtems.py +++ b/rtems.py @@ -1,5 +1,5 @@ # -# Copyright 2012, 2013 Chris Johns (chrisj@rtems.org) +# Copyright 2012-2016 Chris Johns (chrisj@rtems.org) # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -33,6 +33,7 @@ from . import pkgconfig import re import subprocess +rtems_default_version = None rtems_filters = None def options(opt): @@ -62,8 +63,19 @@ def options(opt): dest = 'show_commands', help = 'Print the commands as strings.') -def init(ctx, filters = None): +def init(ctx, filters = None, version = None): global rtems_filters + global rtems_default_version + + # + # Set the RTEMS filter to the context. + # + rtems_filters = filters + + # + # Set the default version, can be overridden. + # + rtems_default_version = version try: import waflib.Options @@ -75,11 +87,6 @@ def init(ctx, filters = None): env = waflib.ConfigSet.ConfigSet() env.load(waflib.Options.lockfile) - # - # Set the RTEMS filter to the context. - # - rtems_filters = filters - # # Check the tools, architectures and bsps. # @@ -116,6 +123,15 @@ def init(ctx, filters = None): pass def configure(conf, bsp_configure = None): + # + # Check the environment for any flags. + # + for f in ['CC', 'CXX', 'AS', 'LD', 'AR', 'LINK_CC', 'LINK_CXX', + 'CPPFLAGS', 'CFLAGS', 'CXXFLAGS', 'ASFLAGS', 'LINKFLAGS', 'LIB' + 'WFLAGS', 'RFLAGS', 'MFLAGS', 'IFLAGS']: + if f in os.environ: + conf.msg('Environment variable set', f, color = 'RED') + # # Handle the show commands option. # @@ -138,6 +154,7 @@ def configure(conf, bsp_configure = None): _log_header(conf) + conf.msg('RTEMS Version', rtems_version, 'YELLOW') conf.msg('Architectures', ', '.join(archs), 'YELLOW') tools = {} @@ -168,6 +185,23 @@ def configure(conf, bsp_configure = None): conf.load('g++') conf.load('gas') + # + # Get the version of the tools being used. + # + rtems_cc = conf.env.CC[0] + try: + import waflib.Context + out = conf.cmd_and_log([rtems_cc, '--version'], + output = waflib.Context.STDOUT) + except Exception as e: + conf.fatal('CC version not found: %s' % (e.stderr)) + # + # First line is the version + # + vline = out.split('\n')[0] + conf.msg('Compiler version (%s)' % (os.path.basename(rtems_cc)), + ' '.join(vline.split()[2:])) + flags = _load_flags(conf, ab, rtems_path) cflags = _filter_flags('cflags', flags['CFLAGS'], @@ -288,11 +322,14 @@ def check_options(ctx, prefix, rtems_tools, rtems_path, rtems_version, rtems_arc # Set defaults # if rtems_version is None: - m = re.compile('[^0-9.]*([0-9.]+)$').match(prefix) - if m: - rtems_version = m.group(1) + if rtems_default_version is None: + m = re.compile('[^0-9.]*([0-9.]+)$').match(prefix) + if m: + rtems_version = m.group(1) + else: + ctx.fatal('RTEMS version cannot derived from prefix: ' + prefix) else: - ctx.fatal('RTEMS version cannot derived from prefix: ' + prefix) + rtems_version = rtems_default_version if rtems_path is None: rtems_path = prefix if rtems_tools is None: @@ -528,13 +565,11 @@ def _find_tools(conf, arch, paths, tools): arch_tools = {} arch_tools['CC'] = conf.find_program([arch + '-gcc'], path_list = paths) arch_tools['CXX'] = conf.find_program([arch + '-g++'], path_list = paths) - arch_tools['AS'] = conf.find_program([arch + '-gcc'], path_list = paths) - arch_tools['LD'] = conf.find_program([arch + '-ld'], path_list = paths) - arch_tools['AR'] = conf.find_program([arch + '-ar'], path_list = paths) arch_tools['LINK_CC'] = arch_tools['CC'] arch_tools['LINK_CXX'] = arch_tools['CXX'] + arch_tools['AS'] = conf.find_program([arch + '-gcc'], path_list = paths) + arch_tools['LD'] = conf.find_program([arch + '-ld'], path_list = paths) arch_tools['AR'] = conf.find_program([arch + '-ar'], path_list = paths) - arch_tools['LD'] = conf.find_program([arch + '-ld'], path_list = paths) arch_tools['NM'] = conf.find_program([arch + '-nm'], path_list = paths) arch_tools['OBJDUMP'] = conf.find_program([arch + '-objdump'], path_list = paths) arch_tools['OBJCOPY'] = conf.find_program([arch + '-objcopy'], path_list = paths) -- cgit v1.2.3