summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2016-04-18 10:24:34 +1000
committerChris Johns <chrisj@rtems.org>2016-04-18 10:24:34 +1000
commit8220ad187c2570a758b666ba7dbd068361aec1a2 (patch)
treead34cd3c54af85c55c4bab8bfff5251dace45fb6
parentFix module import for msys2 (diff)
downloadrtems_waf-8220ad187c2570a758b666ba7dbd068361aec1a2.tar.bz2
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.
-rw-r--r--rtems.py65
1 files 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
@@ -76,11 +88,6 @@ def init(ctx, filters = None):
env.load(waflib.Options.lockfile)
#
- # Set the RTEMS filter to the context.
- #
- rtems_filters = filters
-
- #
# Check the tools, architectures and bsps.
#
rtems_version, rtems_path, rtems_bin, rtems_tools, archs, arch_bsps = \
@@ -117,6 +124,15 @@ def init(ctx, filters = None):
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.
#
if conf.options.show_commands:
@@ -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)