Example #1
0
def Building(target, sobjs, env=None):
    if (env is None):
        env = Env
    if (GetOption('splint')):
        splint(objs, env)
    bdir = 'build/%s' % (target)
    objs = []
    xmls = []
    ofs = []
    arxml = None

    for obj in sobjs:
        if (str(obj)[-6:] == '.arxml'):
            if (arxml is None):
                arxml = obj
            else:
                raise Exception('too much arxml specified! [%s %s]' %
                                (arxml, obj))
        elif (str(obj)[-4:] == '.xml'):
            xmls.append(obj)
        elif (str(obj)[-3:] == '.of'):
            ofs.append(obj)
        else:
            objs.append(obj)
    cfgdir = '%s/config' % (bdir)
    cfgdone = '%s/config.done' % (cfgdir)
    if (((not os.path.exists(cfgdone)) and (not env.GetOption('clean')))
            or env.GetOption('force')):
        MKDir(cfgdir)
        RMFile(cfgdone)
        for xml in xmls:
            MKSymlink(str(xml), '%s/%s' % (cfgdir, os.path.basename(str(xml))))
        MKSymlink(str(arxml), '%s/%s' % (cfgdir, os.path.basename(str(arxml))))
        xcc.XCC(cfgdir, env)
        argen.ArGen.ArGenMain(str(arxml), cfgdir)
        MKFile(cfgdone)
    if ('studio' in COMMAND_LINE_TARGETS):
        studio = os.path.abspath(
            '../../com/as.tool/config.infrastructure.system/')
        assert (arxml)
        pd = os.path.abspath(cfgdir)
        RunCommand('cd %s && %s studio.py %s' % (studio, env['python3'], pd))
        exit(0)

    objs += Glob('%s/*.c' % (cfgdir))
    env.Append(CPPPATH=['%s' % (cfgdir)])
    env.Append(ASFLAGS='-I%s' % (cfgdir))
    env.Append(CCFLAGS=['--include', '%s/asmconfig.h' % (cfgdir)])

    if (env.GetOption('clean')):
        RMDir(cfgdir)
        RunCommand('rm -fv *.s19')

    BuildOFS(ofs)
    env.Program(target, objs)

    if (IsPlatformWindows()): target += '.exe'
    #env['POSTACTION'].append('readelf -l %s'%(target))
    for action in env['POSTACTION']:
        env.AddPostAction(target, action)
Example #2
0
def menuconfig(env):
    import time
    kconfig = '%s/com/as.tool/kconfig-frontends/kconfig-mconf'%(env['ASROOT'])
    if(IsPlatformWindows()):
        kconfig += '.exe'
        cmd2  = 'cd %s/com/as.tool/kconfig-frontends'%(env['ASROOT'])
        kurl = 'http://distortos.org/files/kconfig-frontends-3.12.0-windows.7z'
        cmd2 += ' && curl -O %s'%(kurl)
        for disk in ['C:/','D:/','E:/','F:/']:
            for prg in ['Program Files (x86)','Program Files','ProgramData']:
                _7z = os.path.join(disk, prg, '7-Zip/7z.exe')
                if(os.path.exists(_7z)): break
            if(os.path.exists(_7z)): break
        if(not os.path.exists(_7z)):
            raise Exception('Please Install 7z(https://www.7-zip.org/download.html)')
        cmd2 += ' && "%s" e kconfig-frontends-3.12.0-windows.7z'%(_7z)
        if(not os.path.exists(kconfig)):
            RunCommand(cmd2)
        if(not os.path.exists(kconfig)):
            raise Exception('please download %s and extract it as %s'%(kurl, kconfig))
        cmd = 'set BOARD=%s && set ASROOT=%s && '%(env['BOARD'],env['ASROOT'])
    else:
        cmd = 'export BOARD=%s && export ASROOT=%s && '%(env['BOARD'],env['ASROOT'])
    if(not os.path.exists(kconfig)):
        RunCommand('cd %s/com/as.tool/kconfig-frontends && make'%(env['ASROOT']))
    if(os.path.exists(kconfig)):
        assert(os.path.exists('Kconfig'))
        cmd += kconfig + ' Kconfig'

        fn = '.config'
        if(os.path.isfile(fn)):
            mtime = os.path.getmtime(fn)
        else:
            mtime = -1
        rtt = '%s/com/as.infrastructure/system/kernel/rtthread/rt-thread'%(env['ASROOT'])
        if(not os.path.exists(rtt)):
            MKDir(rtt)
            MKFile(rtt+'/Kconfig', '')
        if(IsPlatformWindows()):
            cmd = '@echo off\n'+cmd.replace(' && ','\n')
            MKFile('menuconfig.bat', cmd)
            cmd = 'menuconfig.bat'
        RunCommand(cmd)
        if(os.path.isfile(fn)):
            mtime2 = os.path.getmtime(fn)
        else:
            mtime2 = -1
        if(mtime != mtime2):
            GetConfig(fn,env)
            if('RTTHREAD' in env['MODULES']):
                mk_rtconfig(fn)
            cfgdir = 'build/%s/config'%(env['BOARD'])
            MKDir(cfgdir)
            xcc.XCC(cfgdir,env)
        exit(0)
    else:
        raise Exception("can't find out %s"%(kconfig))
Example #3
0
def menuconfig(env):
    import time
    kconfig = '%s/com/as.tool/kconfig-frontends/kconfig-mconf' % (
        env['ASROOT'])
    cmd = ''
    if (os.name == 'nt'):
        kconfig += '.exe'
        cmd += 'set BOARD=%s && set ASROOT=%s && start cmd /C ' % (
            env['BOARD'], env['ASROOT'])
    else:
        cmd += 'export BOARD=%s && export ASROOT=%s && ' % (env['BOARD'],
                                                            env['ASROOT'])
    if (not os.path.exists(kconfig)):
        RunCommand('cd %s/com/as.tool/kconfig-frontends && make' %
                   (env['ASROOT']))
    if (os.path.exists(kconfig)):
        assert (os.path.exists('Kconfig'))
        cmd += kconfig + ' Kconfig'

        fn = '.config'
        if (os.path.isfile(fn)):
            mtime = os.path.getmtime(fn)
        else:
            mtime = -1
        RunCommand(cmd)
        print('press Ctrl+C to exit!')
        if (os.name == 'nt'):
            while (True):
                time.sleep(1)
                if (os.path.isfile(fn)):
                    mtime2 = os.path.getmtime(fn)
                else:
                    mtime2 = -1
                if (mtime != mtime2):
                    break
        if (os.path.isfile(fn)):
            mtime2 = os.path.getmtime(fn)
        else:
            mtime2 = -1
        if (mtime != mtime2):
            GetConfig(fn, env)
            if ('RTTHREAD' in env['MODULES']):
                mk_rtconfig(fn)
            cfgdir = 'build/%s/config' % (env['BOARD'])
            MKDir(cfgdir)
            xcc.XCC(cfgdir, env)
        exit(0)
    else:
        raise Exception("can't find out %s" % (kconfig))
Example #4
0
def Building(target, sobjs, env=None):
    import xcc
    import argen
    if (env is None):
        env = Env
    if (GetOption('splint')):
        splint(objs, env)
    bdir = 'build/%s' % (target)
    objs = []
    xmls = []
    ofs = []
    swcs = []
    dts = []
    arxml = None

    cfgdir = '%s/config' % (bdir)
    env.Append(CPPPATH=['%s' % (cfgdir)])
    env.Append(ASFLAGS='-I%s' % (cfgdir))
    if ('gcc' in env['CC']):
        env.Append(CCFLAGS=['--include', '%s/asmconfig.h' % (cfgdir)])

    if ('PACKAGES' in env):
        for p in env['PACKAGES']:
            pkg = Package(p)
            pbdir = '%s/packages/%s' % (bdir, os.path.basename(pkg))
            sobjs += SConscript('%s/SConscript' % (pkg),
                                variant_dir=pbdir,
                                duplicate=0)

    for obj in sobjs:
        if (str(obj)[-6:] == '.arxml'):
            if (arxml is None):
                arxml = obj
            else:
                raise Exception('too much arxml specified! [%s %s]' %
                                (arxml, obj))
        elif (str(obj)[-4:] == '.xml'):
            xmls.append(obj)
        elif (str(obj)[-3:] == '.of'):
            ofs.append(obj)
        elif (str(obj)[-3:] == '.py'):
            swcs.append(obj)
        elif (str(obj)[-4:] == '.dts'):
            dts.append(obj)
        else:
            objs.append(obj)

    AppendPythonPath([cfgdir])
    os.environ['ARXML'] = str(arxml)
    cfgdone = '%s/config.done' % (cfgdir)
    if (((not os.path.exists(cfgdone)) and (not GetOption('clean')))
            or GetOption('force')):
        MKDir(cfgdir)
        RMFile(cfgdone)
        xcc.XCC(cfgdir, env, True)
        arxmlR = PreProcess(cfgdir, str(arxml))
        for xml in xmls:
            MKSymlink(str(xml), '%s/%s' % (cfgdir, os.path.basename(str(xml))))
        xcc.XCC(cfgdir)
        argen.ArGen.ArGenMain(arxmlR, cfgdir)
        MKFile(cfgdone)
    if ('studio' in COMMAND_LINE_TARGETS):
        studio = os.path.abspath(
            '../../com/as.tool/config.infrastructure.system/')
        assert (arxml)
        pd = os.path.abspath(cfgdir)
        RunCommand('cd %s && %s studio.py %s' % (studio, env['python3'], pd))
        exit(0)

    objs += Glob('%s/*.c' % (cfgdir))

    if (GetOption('clean')):
        RMDir(cfgdir)
        RunCommand('rm -fv *.s19')

    BuildDTS(dts, bdir)
    BuildOFS(ofs)
    BuildingSWCS(swcs)
    env.Program(target, objs)

    if (IsPlatformWindows()): target += '.exe'
    if (GetOption('memory')):
        MemoryUsage(target, env.Object(objs))
    #env['POSTACTION'].append('readelf -l %s'%(target))
    for action in env['POSTACTION']:
        env.AddPostAction(target, action)