Changeset 8220ad1 in rtems_waf


Ignore:
Timestamp:
Apr 18, 2016, 12:24:34 AM (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
096372fc4504730e50b51b952ce47ca603b35f01
Children:
9343280
Parents:
b548c77
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtems.py

    rb548c77 r8220ad1  
    11#
    2 # Copyright 2012, 2013 Chris Johns (chrisj@rtems.org)
     2# Copyright 2012-2016 Chris Johns (chrisj@rtems.org)
    33#
    44# Redistribution and use in source and binary forms, with or without
     
    3434import subprocess
    3535
     36rtems_default_version = None
    3637rtems_filters = None
    3738
     
    6364                   help = 'Print the commands as strings.')
    6465
    65 def init(ctx, filters = None):
     66def init(ctx, filters = None, version = None):
    6667    global rtems_filters
     68    global rtems_default_version
     69
     70    #
     71    # Set the RTEMS filter to the context.
     72    #
     73    rtems_filters = filters
     74
     75    #
     76    # Set the default version, can be overridden.
     77    #
     78    rtems_default_version = version
    6779
    6880    try:
     
    7587        env = waflib.ConfigSet.ConfigSet()
    7688        env.load(waflib.Options.lockfile)
    77 
    78         #
    79         # Set the RTEMS filter to the context.
    80         #
    81         rtems_filters = filters
    8289
    8390        #
     
    118125def configure(conf, bsp_configure = None):
    119126    #
     127    # Check the environment for any flags.
     128    #
     129    for f in ['CC', 'CXX', 'AS', 'LD', 'AR', 'LINK_CC', 'LINK_CXX',
     130              'CPPFLAGS', 'CFLAGS', 'CXXFLAGS', 'ASFLAGS', 'LINKFLAGS', 'LIB'
     131              'WFLAGS', 'RFLAGS', 'MFLAGS', 'IFLAGS']:
     132        if f in os.environ:
     133            conf.msg('Environment variable set', f, color = 'RED')
     134
     135    #
    120136    # Handle the show commands option.
    121137    #
     
    139155    _log_header(conf)
    140156
     157    conf.msg('RTEMS Version', rtems_version, 'YELLOW')
    141158    conf.msg('Architectures', ', '.join(archs), 'YELLOW')
    142159
     
    168185        conf.load('g++')
    169186        conf.load('gas')
     187
     188        #
     189        # Get the version of the tools being used.
     190        #
     191        rtems_cc = conf.env.CC[0]
     192        try:
     193            import waflib.Context
     194            out = conf.cmd_and_log([rtems_cc, '--version'],
     195                                   output = waflib.Context.STDOUT)
     196        except Exception as e:
     197            conf.fatal('CC version not found: %s' % (e.stderr))
     198        #
     199        # First line is the version
     200        #
     201        vline = out.split('\n')[0]
     202        conf.msg('Compiler version (%s)' % (os.path.basename(rtems_cc)),
     203                                            ' '.join(vline.split()[2:]))
    170204
    171205        flags = _load_flags(conf, ab, rtems_path)
     
    289323    #
    290324    if rtems_version is None:
    291         m = re.compile('[^0-9.]*([0-9.]+)$').match(prefix)
    292         if m:
    293             rtems_version = m.group(1)
     325        if rtems_default_version is None:
     326            m = re.compile('[^0-9.]*([0-9.]+)$').match(prefix)
     327            if m:
     328                rtems_version = m.group(1)
     329            else:
     330                ctx.fatal('RTEMS version cannot derived from prefix: ' + prefix)
    294331        else:
    295             ctx.fatal('RTEMS version cannot derived from prefix: ' + prefix)
     332            rtems_version = rtems_default_version
    296333    if rtems_path is None:
    297334        rtems_path = prefix
     
    529566        arch_tools['CC']          = conf.find_program([arch + '-gcc'], path_list = paths)
    530567        arch_tools['CXX']         = conf.find_program([arch + '-g++'], path_list = paths)
     568        arch_tools['LINK_CC']     = arch_tools['CC']
     569        arch_tools['LINK_CXX']    = arch_tools['CXX']
    531570        arch_tools['AS']          = conf.find_program([arch + '-gcc'], path_list = paths)
    532571        arch_tools['LD']          = conf.find_program([arch + '-ld'],  path_list = paths)
    533         arch_tools['AR']          = conf.find_program([arch + '-ar'],  path_list = paths)
    534         arch_tools['LINK_CC']     = arch_tools['CC']
    535         arch_tools['LINK_CXX']    = arch_tools['CXX']
    536572        arch_tools['AR']          = conf.find_program([arch + '-ar'], path_list = paths)
    537         arch_tools['LD']          = conf.find_program([arch + '-ld'], path_list = paths)
    538573        arch_tools['NM']          = conf.find_program([arch + '-nm'], path_list = paths)
    539574        arch_tools['OBJDUMP']     = conf.find_program([arch + '-objdump'], path_list = paths)
Note: See TracChangeset for help on using the changeset viewer.