Beispiel #1
0
def run(common_args, cmd_argv):
    global WRKSPACE_ROOT
    global PKG_ROOT

    # Parse command line
    args = docopt(__doc__, argv=cmd_argv)

    # Generate header file
    if (not args['--cpp']):
        ofname = args['<class>'] + ".h"
        cmd = 'f4 header_skeleton.f4t -z --global //colony.core/resources/f4 -v {} -o {} map {} {}'.format(
            common_args['-g'], ofname, args['<class>'], common_args['-n'])
        rc, output = utils2.run_shell(cmd)
        utils2.verbose(cmd, output, common_args)
        if (rc != 0):
            sys.exit(
                "ERROR: Failed to create output: {}.  Rerun using the '-v' for additional error information"
                .format(ofname))

    # Generate CPP file
    if (not args['--header']):
        ofname = args['<class>'] + ".cpp"
        cmd = 'f4 cpp_skeleton.f4t -z --global //colony.core/resources/f4 -v {} -o {} map {} {}'.format(
            common_args['-g'], ofname, args['<class>'], common_args['-n'])
        rc, output = utils2.run_shell(cmd)
        utils2.verbose(cmd, output, common_args)
        if (rc != 0):
            sys.exit(
                "ERROR: Failed to create output: {}.  Rerun using the '-v' for additional error information"
                .format(ofname))
Beispiel #2
0
def run(argv):

    # Parse command line
    args = docopt(__doc__, version="0.1", options_first=True)

    # Trap help on a specific command
    if (args['<template>'] == 'help'):

        # Display list of commands if none specified
        if (args['<args>'] == []):
            display_command_list()

        # Display command specific help
        else:
            load_command(args['<args>'][0]).run(args, ['--help'])

    # Trap no command specified
    elif (args['<template>'] == None):
        docopt(__doc__, argv=['--help'])

    # Run the command (if it exists)
    else:
        global WRKSPACE_ROOT
        global PKG_ROOT

        # Get workspace/package info
        WRKSPACE_ROOT, PKG_ROOT = utils2.set_pkg_and_wrkspace_roots()

        # Get namespace as a list
        if (args['-n']):
            namespaces = args['-n'].split('::')
        else:
            namespaces = utils2.get_relative_subtree(PKG_ROOT,
                                                     'src').split(os.sep)
        args['-n'] = ','.join(namespaces)

        # Convert the debug option to a f4 argument
        if (args['-g']):
            args['-g'] = '-g'
        else:
            args['-g'] = ''

        # run the command
        load_command(args['<template>']).run(args, [args['<template>']] +
                                             args['<args>'])
Beispiel #3
0
def run( argv ):

    # Parse command line
    args = docopt(__doc__, version="0.1")

    # Get environment variable for where the arduino tools are located
    ARDUINO_TOOLS = os.environ.get( 'ARDUINO_TOOLS' )
    if ( ARDUINO_TOOLS == None ):
        print("The environment variable - ARDUINO_TOOLS - is NOT set.")
        sys.exit(1)
    ARDUINO_BSP_VER = os.environ.get( 'ARDUINO_BSP_VER' )
    if ( ARDUINO_BSP_VER == None ):
        print("The environment variable - ARDUINO_BSP_VER - is NOT set.")
        sys.exit(1)
    ARDUINO_NRF_UTIL_VER = os.environ.get( 'ARDUINO_NRF_UTIL_VER' )
    if ( ARDUINO_NRF_UTIL_VER == None ):
        print("The environment variable - ARDUINO_NRF_UTIL_VER - is NOT set.")
        sys.exit(1)

    # Default tool stuff
    nrfutil    = os.path.join(ARDUINO_TOOLS, 'hardware', 'nrf52', ARDUINO_BSP_VER, 'tools', ARDUINO_NRF_UTIL_VER, 'binaries', 'win32', 'nrfutil' )
            
    # Get hex file to program
    zipfile = get_default_zipfile_name();
    if ( args['<zipfile>'] ):
        zipfile = args['<zipfile>'] 
    if ( zipfile == None ):
        print("No ZIP file was specified OR multiple ZIP files exist in the default directory")
        sys.exit(1)

    # build options....
    verbose = ' --verbose ' if args['-v'] else ''
    comport = ' --port '+args['-p']
    baud    = ' -b '+args['-b']
    command = ''
    if (  not args['--nozip'] ):
        target  = ' dfu serial -pkg {}'.format(zipfile)
        command = target + comport + baud
    extra   = '' if not args['--extra'] else ' ' + args['--extra']
    options = verbose + command + extra
    
    # Run NRFUTIL
    printer = Printer()
    cmd = nrfutil + ' ' + options
    if ( args['-v'] ):
        print(cmd)
    if (utils.run_shell(printer, cmd, False) ):
        print()
        print('** A FAILURE occurred while attempting to run nrfutil')
        print()
        sys.exit(1)
Beispiel #4
0
def run(argv):

    # Parse command line
    args = docopt(__doc__, version="0.1")

    # Get environment variable for where the arduino tools are located
    ARDUINO_TOOLS = os.environ.get('ARDUINO_TOOLS')
    if (ARDUINO_TOOLS == None):
        print("The environment variable - ARDUINO_TOOLS - is NOT set.")
        sys.exit(1)

    # Default tool stuff
    avrdude = os.path.join(ARDUINO_TOOLS, 'hardware', 'tools', 'avr', 'bin',
                           'avrdude')
    dudeconfig = os.path.join(ARDUINO_TOOLS, 'hardware', 'tools', 'avr', 'etc',
                              'avrdude.conf')

    # Get hex file to program
    hexfile = get_default_hexfile_name()
    if (args['<hexfile>']):
        hexfile = args['<hexfile>']
    if (hexfile == None):
        print(
            "No HEX file was specified OR multiple HEX files exist in the default directory"
        )
        sys.exit(1)

    # build options....
    verbose = ' -v' if args['-v'] else ''
    comport = '' if not args['-p'] else ' -P ' + args['-p']
    baud = '' if not args['-b'] else ' -b ' + args['-b']
    config = ' -C ' + dudeconfig if not args[
        '-c'] else ' -C "' + args['-c'] + '"'
    mcu = ' -p ' + args['-m']
    target = '' if args['--nohex'] else '-U flash:w:{}:i'.format(hexfile)
    extra = '' if not args['--extra'] else ' ' + args['--extra']
    options = config + comport + verbose + mcu + ' -c arduino -D ' + target + extra

    # Run AVRDUDE
    printer = Printer()
    cmd = avrdude + ' ' + options
    if (args['-v']):
        print(cmd)
    if (utils.run_shell(printer, cmd, False)):
        print()
        print('** A FAILURE occurred while attempting to run avrdude')
        print()
        sys.exit(1)
Beispiel #5
0
def run(argv):
    # Process command line args...
    args = docopt(usage, version="0.0.1", options_first=True)

    # get the package root
    pkg = NQBP_PKG_ROOT()

    # setup excludes
    excludes = '--exclude=.*_0test.*  --exclude=^tests* --exclude-unreachable-branches'

    # Setup 'arc' excludes for C++ code (see https://gcovr.com/en/stable/faq.html)
    arcopt = ' --exclude-unreachable-branches'
    if (args['--all']):
        arcopt = ''

    # Generate summary
    if (args['rpt']):
        python = 'python'
        if (platform.system() == 'Windows'):
            python = 'py -3'

        cmd = '{} -m gcovr {} {} -j 8 -r {}{}src --object-directory . {}'.format(
            python, excludes, arcopt, pkg, os.sep,
            ' '.join(args['<args>']) if args['<args>'] else '')
        if (args['<args>']):
            first = args['<args>'][0]
            if (first == '-h' or first == '--help'):
                cmd = '{} -m gcovr --help'.format(python)
        run_shell(cmd, True)

    # Generate human readable .gcov files
    elif (args['-d']):
        cmd = 'gcov ' + args['-d']
        run_shell(cmd)

    # Search file
    elif (args['-m']):
        search(os.getcwd(), args['-m'], args['-w'])

    # Clean ALL
    elif (args['--clean']):
        clean(os.path.join(pkg, "projects"), ['*.gcov', '*.gcda', '*.gcno'])
        clean(os.path.join(pkg, "tests"), ['*.gcov', '*.gcda', '*.gcno'])

    # Clean just .gcov files
    elif (args['-c']):
        clean(os.getcwd(), ['*.gcov'])
Beispiel #6
0
def run( common_args, cmd_argv ):
    # Parse command line
    args = docopt(__doc__, argv=cmd_argv)
    
    # Get MSGS as comma seperated string
    msgs = ','.join( args['MSGS'] )
    
    # Get response class name
    rclass  = 'n/a'
    incResp = '0'
    if ( args['-r'] ):
        rclass  = args['-r']
        incResp = '1'
        
    # Create header file
    ofname     = args['<class>']+".h"
    cmd        = 'f4 itc_request.f4t -z --global //colony.core/resources/f4 -v {} -o {} map {} {} {} {} {}'.format( common_args['-g'], ofname, args['<class>'], rclass, common_args['-n'], incResp, msgs )
    rc, output = utils2.run_shell( cmd )
    utils2.verbose( cmd, output, common_args )
    if ( rc != 0 ):
        sys.exit( "ERROR: Failed to create output: {}.  Rerun using the '-v' for additional error information".format(ofname) )
Beispiel #7
0
def run(argv, copyright=None):
    global copyright_header

    # Process command line args...
    args = docopt(usage, version="0.0.1", options_first=True)
    sargs = ' '.join(args['<sinelabore>'])

    # Check the environment variables
    sinpath = os.environ.get("SINELABORE_PATH")
    if (sinpath == None):
        exit("ERROR: The SINELABORE_PATH environment variable is not set.")

    # Set copyright header (if specified)
    if (copyright != None):
        copyright_header = copyright

    # Convert namespace arg to list
    names = args['<namespaces>'].split('::')

    # Filenames
    fsmdiag = args['<basename>'] + ".cdd"
    base = args['<basename>'] + "Context_"
    evque = args['<basename>'] + "EventQueue_"
    fsm = args['<basename>']
    cfg = 'codegen.cfg'

    # Generated File names
    oldfsm = fsm + '.h'
    oldfsmcpp = fsm + '.cpp'
    oldevt = fsm + '_ext.h'
    oldtrace = fsm + '_trace.h'
    oldtrace2 = fsm + '_trace.java'
    newfsm = fsm + '_.h'
    newfsmcpp = fsm + '_.cpp'
    newevt = fsm + '_ext_.h'
    newtrace = fsm + '_trace_.h'

    # Delete 'optional' old/previous files
    utils.delete_file(evque + ".h")
    utils.delete_file(evque + ".cpp")

    # Create the config file for Sinelabore
    geneatedCodegenConfig(cfg, base, names)

    # Build Sinelabore command
    cmd = 'java -jar -Djava.ext.dirs={} {}/codegen.jar {} -p CADIFRA -doxygen -o {} -l cppx -Trace {}'.format(
        sinpath, sinpath, sargs, fsm, fsmdiag)
    cmd = utils.standardize_dir_sep(cmd)

    # Invoke Sinelabore command
    print(cmd)
    p = subprocess.Popen(cmd, shell=True)
    r = p.communicate()
    if (p.returncode != 0):
        exit("ERROR: Sinelabore encounterd an error or failed to run.")

    # Clean-up config file (don't want it being checked into version control)
    os.remove(cfg)

    # Mangle the event names so that I can have many FSMs in the same namespace with the same event names
    eventList = get_events_names(oldevt)
    mangle_event_names(oldevt, eventList, fsm, ' ')
    mangle_event_names(oldfsmcpp, eventList, fsm, '"', '0', '=')
    mangle_event_names(oldtrace, eventList, fsm, '"')
    cleanup_global_define(oldevt, fsm, names)

    # Generate Context/Base class
    actions, guards = getContextMethods(fsmdiag)
    generatedContextClass(base, names, getHeader(), actions, guards)

    # Generated event queuue class
    depth = args['-d'].strip()
    if (depth != '0'):
        generateEventClass(evque, names, fsm, newfsm, depth)

    # Post process the generated file(s) to work better with Doxygen
    cleanup_for_doxygen(fsm + ".h", args['<namespaces>'] + "::" + fsm)
    cleanup_for_doxygen(oldtrace)
    cleanup_for_doxygen(oldevt)

    # Post process the generated file(s)
    cleanup_trace(oldfsmcpp, names, fsm, oldfsm, oldtrace, newtrace)
    cleanup_includes(oldfsm, names, oldfsm, newfsm, oldevt, newevt,
                     base + '.h')
    cleanup_includes(oldfsmcpp, names, oldfsm, newfsm, oldevt, newevt,
                     base + '.h')

    # Housekeeping for naming convention
    utils.delete_file(newfsm)
    utils.delete_file(newfsmcpp)
    utils.delete_file(newevt)
    utils.delete_file(newtrace)
    utils.delete_file(oldtrace2)  # remove unwanted JAVA file
    os.rename(oldfsm, newfsm)
    os.rename(oldfsmcpp, newfsmcpp)
    os.rename(oldevt, newevt)
    os.rename(oldtrace, newtrace)
Beispiel #8
0
    # Build the project
    utils.push_dir(os.path.dirname(full_path_of_build_script))
    cmd = full_path_of_build_script + ' ' + " ".join(bldopts)
    print("BUILDING: " + cmd)
    if (config):
        cmd = utils.concatenate_commands(cfg, cmd)
    utils.run_shell2(cmd, verbose, f"ERROR: Build failure ({cmd})")
    utils.pop_dir()


#------------------------------------------------------------------------------
# BEGIN
if __name__ == '__main__':

    # Parse command line
    args = docopt(__doc__, version=BOB_VERSION, options_first=True)

    # Set quite & verbose modes
    utils.set_verbose_mode(args['-v'])

    # Default the projects/ dir path to the current working directory
    ppath = os.getcwd()

    # Project dir path is explicit set
    if (args['--path']):
        ppath = args['--path']

    # Set which build engine to use
    build_script = args['-x']

    # Get superset of projects to build