Changeset 3a51369 in examples-v2


Ignore:
Timestamp:
Dec 1, 2013, 3:38:01 AM (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.11, 286403d7a3d0e521179e677c0d2fd7549c9ceab4
Children:
82de6bf
Parents:
e0430bd
git-author:
Chris Johns <chrisj@…> (12/01/13 03:38:01)
git-committer:
Gedare Bloom <gedare@…> (12/12/13 19:55:56)
Message:

Add checks for various CPU options.

Check the cpuopts.h header file for various options and provide an
API to test them from user wscript files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtems_waf/rtems.py

    re0430bd r3a51369  
    182182
    183183        #
     184        # Checks for various RTEMS features.
     185        #
     186        conf.multicheck({ 'header_name': 'rtems.h'},
     187                        { 'header_name': 'rtems/score/cpuopts.h'},
     188                        msg = 'Checking for RTEMS headers',
     189                        mandatory = True)
     190        load_cpuopts(conf, ab, conf.options.rtems_path)
     191
     192        #
    184193        # Add tweaks.
    185194        #
    186195        tweaks(conf, ab)
    187196
     197        #
     198        # Show commands support the user can supply.
     199        #
    188200        conf.env.SHOW_COMMANDS = show_commands
    189201
     
    199211    if bld.env.SHOW_COMMANDS == 'yes':
    200212        output_command_line()
     213
     214def load_cpuopts(conf, arch_bsp, rtems_path):
     215    options = ['RTEMS_DEBUG',
     216               'RTEMS_MULTIPROCESSING',
     217               'RTEMS_NEWLIB',
     218               'RTEMS_POSIX_API',
     219               'RTEMS_SMP',
     220               'RTEMS_NETWORKING',
     221               'RTEMS_ATOMIC']
     222    for opt in options:
     223        enabled = check_opt(conf, opt, 'rtems/score/cpuopts.h', arch_bsp, rtems_path)
     224        if enabled:
     225            conf.env[opt] = 'Yes'
     226        else:
     227            conf.env[opt] = 'No'
     228
     229def check_opt(conf, opt, header, arch_bsp, rtems_path):
     230    code  = '#include <%s>%s' % (header, os.linesep)
     231    code += '#ifndef %s%s' % (opt, os.linesep)
     232    code += ' #error %s is not defined%s' % (opt, os.linesep)
     233    code += '#endif%s' % (os.linesep)
     234    code += '#if %s%s' % (opt, os.linesep)
     235    code += ' /* %s is true */%s' % (opt, os.linesep)
     236    code += '#else%s' % (os.linesep)
     237    code += ' #error %s is false%s' % (opt, os.linesep)
     238    code += '#endif%s' % (os.linesep)
     239    code += 'int main() { return 0; }%s' % (os.linesep)
     240    try:
     241        conf.check_cc(fragment = code,
     242                      execute = False,
     243                      define_ret = False,
     244                      msg = 'Checking for %s' % (opt))
     245    except conf.errors.WafError:
     246        return False;
     247    return True
    201248
    202249def tweaks(conf, arch_bsp):
     
    297344    return rtems_bin, tools, archs, arch_bsps
    298345
     346def check(ctx, option):
     347    if option in ctx.env:
     348        return ctx.env[option] == 'Yes'
     349    return False
     350
     351def check_debug(ctx):
     352    return check(ctx, 'RTEMS_DEBUG')
     353
     354def check_multiprocessing(ctx):
     355    return check(ctx, 'RTEMS_MULTIPROCESSING')
     356
     357def check_newlib(ctx):
     358    return check(ctx, 'RTEMS_NEWLIB')
     359
     360def check_posix(ctx):
     361    return check(ctx, 'RTEMS_POSIX_API')
     362
     363def check_smp(ctx):
     364    return check(ctx, 'RTEMS_SMP')
     365
     366def check_networking(ctx):
     367    return check(ctx, 'RTEMS_NETWORKING')
     368
     369def check_atomic(ctx):
     370    return check(ctx, 'RTEMS_ATROMIC')
     371
    299372def arch(arch_bsp):
    300373    """ Given an arch/bsp return the architecture."""
     
    316389        return items
    317390    if type(rtems_filters) is not dict:
    318         ctx.fatal("Invalid RTEMS filter type, ie { 'tools': { 'in': [], 'out': [] }, 'arch': {}, 'bsps': {} }")
     391        ctx.fatal("Invalid RTEMS filter type, " \
     392                  "ie { 'tools': { 'in': [], 'out': [] }, 'arch': {}, 'bsps': {} }")
    319393    if filter not in rtems_filters:
    320394        return items
     
    437511        arch_tools['READELF']     = conf.find_program([arch + '-readelf'], path_list = paths)
    438512        arch_tools['STRIP']       = conf.find_program([arch + '-strip'], path_list = paths)
    439         arch_tools['RTEMS_LD']    = conf.find_program(['rtems-ld'], path_list = paths, mandatory = False)
    440         arch_tools['RTEMS_BIN2C'] = conf.find_program(['rtems-bin2c'], path_list = paths, mandatory = False)
     513        arch_tools['RTEMS_LD']    = conf.find_program(['rtems-ld'], path_list = paths,
     514                                                      mandatory = False)
     515        arch_tools['RTEMS_BIN2C'] = conf.find_program(['rtems-bin2c'], path_list = paths,
     516                                                      mandatory = False)
    441517        arch_tools['TAR']         = conf.find_program(['tar'], mandatory = False)
    442518        tools[arch] = arch_tools
     
    621697    conf.to_log('-----------------------------------------')
    622698
     699from waflib import Task
    623700from waflib import TaskGen
     701from waflib import Utils
     702from waflib import Node
    624703from waflib.Tools.ccroot import link_task, USELIB_VARS
    625704USELIB_VARS['rap'] = set(['RTEMS_LINKFLAGS'])
    626705@TaskGen.extension('.c')
    627706class rap(link_task):
    628         "Link object files into a RTEMS application"
    629         run_str = '${RTEMS_LD} ${RTEMS_LINKFLAGS} --cc ${CC} ${SRC} -o ${TGT[0].abspath()} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB}'
    630         ext_out = ['.rap']
    631         vars    = ['RTEMS_LINKFLAGS', 'LINKDEPS']
    632         inst_to = '${BINDIR}'
     707    "Link object files into a RTEMS application"
     708    run_str = '${RTEMS_LD} ${RTEMS_LINKFLAGS} --cc ${CC} ${SRC} -o ${TGT[0].abspath()} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB}'
     709    ext_out = ['.rap']
     710    vars    = ['RTEMS_LINKFLAGS', 'LINKDEPS']
     711    inst_to = '${BINDIR}'
Note: See TracChangeset for help on using the changeset viewer.