Exemplo n.º 1
0
    def get_env(self, **kwargs):
        c_flags = ['-ffunction-sections', '-fdata-sections', '-fno-exceptions',
                   '-funsigned-char', '-funsigned-bitfields', '-fpack-struct',
                   '-fshort-enums', '-Os', '-Wall', '-mmcu=%s' % self.MCU]

        # Add some missing paths to CFLAGS
        # Workaround for /usr/libexec/gcc/avr/ld:
        #     cannot open linker script file ldscripts/avr5.x: No such file or directory
        # Workaround for /usr/libexec/gcc/avr/ld:
        #     crtm168.o: No such file: No such file or directory
        extra_cflags = ['-L/usr/x86_64-pc-linux-gnu/avr/lib/',
                        '-B/usr/avr/lib/avr5/', ]
        c_flags += extra_cflags

        if self.ARDUINO_BOARD == "leonardo":
            c_flags += ["-DUSB_VID=" + self.get_board_conf('build.vid')]
            c_flags += ["-DUSB_PID=" + self.get_board_conf('build.pid')]

        env_defaults = dict(CC='"' + self.AVR_BIN_PREFIX + 'gcc"',
                            CXX='"' + self.AVR_BIN_PREFIX + 'g++"',
                            AS='"' + self.AVR_BIN_PREFIX + 'gcc"',
                            CPPPATH=[self.core_root],
                            CPPDEFINES={'F_CPU': self.F_CPU, 'ARDUINO':
                                        self.ARDUINO_VER},
                            CFLAGS=c_flags + ['-std=gnu99'], CCFLAGS=c_flags,
                            ASFLAGS=['-assembler-with-cpp','-mmcu=%s' %
                                     self.MCU], TOOLS=['gcc','g++', 'as'])

        hw_variant = os.path.join(self.ARDUINO_HOME,
                                  'hardware/arduino/variants',
                                  self.get_board_conf('build.variant', ''))
        if hw_variant:
            env_defaults['CPPPATH'].append(hw_variant)

        for k, v in six.iteritems(kwargs):
            print('processing kwarg: %s->%s' % (k, v))
            if k in env_defaults and isinstance(env_defaults[k], dict)\
                    and isinstance(v, dict):
                env_defaults[k].update(v)
                print('  update dict')
            elif k in env_defaults and isinstance(env_defaults[k], list):
                env_defaults[k].append(v)
                print('  append to list')
            else:
                env_defaults[k] = v
                print('  set value')
        print('kwargs:', kwargs)
        print('env_defaults:', env_defaults)
        env_arduino = Environment(**env_defaults)
        # Add Arduino Processing, Elf, and Hex builders to environment
        for builder_name in ['Processing', 'CompressCore', 'Elf', 'Hex',
                             'BuildInfo']:
            env_arduino.Append(BUILDERS={builder_name: getattr(self,
                                                               'get_%s_builder'
                                                               % builder_name
                                                               .lower())()})
        return env_arduino
Exemplo n.º 2
0
def getEnvironment():
    import utils
    environment = Environment(ENV=os.environ)
    environment['PAINTOWN_PLATFORM'] = ['wii', 'sdl']
    peg_color = 'light-cyan'
    environment['PAINTOWN_BACKEND'] = 'sdl'
    environment['PAINTOWN_USE_PRX'] = False
    environment['PAINTOWN_TESTS'] = {'CheckPython': checkPython}
    environment['PAINTOWN_COLORIZE'] = utils.colorize
    environment['PAINTOWN_NETWORKING'] = False
    environment['LIBS'] = []
    environment['PEG_MAKE'] = "%s %s" % (utils.colorize(
        'Creating peg parser',
        peg_color), utils.colorize('$TARGET', 'light-blue'))
    environment.Append(BUILDERS={'Peg': utils.pegBuilder(environment)})
    environment.Append(CPPPATH=['#src', '#src/util/network/hawknl'])
    environment.Append(CPPDEFINES=['USE_SDL'])

    return utils.lessVerbose(wii(environment))
Exemplo n.º 3
0
def getEnvironment():
    import utils
    environment = Environment(ENV=os.environ)
    peg_color = 'light-cyan'
    environment['MUGEN_PLATFORM'] = ['unix']
    environment['MUGEN_USE_PRX'] = False
    environment['MUGEN_TESTS'] = {'CheckPython': checkPython}
    environment['MUGEN_COLORIZE'] = utils.colorize
    environment['MUGEN_NETWORKING'] = True
    environment['LIBS'] = []
    environment['PEG_MAKE'] = "%s %s" % (utils.colorize(
        'Creating peg parser',
        peg_color), utils.colorize('$TARGET', 'light-blue'))
    environment.Append(BUILDERS={'Peg': utils.pegBuilder(environment)})
    environment.Append(CPPPATH=['#src', '#src/util/network/hawknl'])
    environment[
        'LINKCOM'] = '$CXX $LINKFLAGS $SOURCES -Wl,--start-group $ARCHIVES $_LIBDIRFLAGS $_LIBFLAGS -Wl,--end-group -o $TARGET'

    # Default preference for a graphics renderer / input system
    backends = ['SDL', 'Allegro4', 'Allegro5']

    if utils.useAllegro4():
        backends = ['Allegro4', 'SDL', 'Allegro5']

    if utils.useAllegro5():
        backends = ['Allegro5', 'SDL', 'Allegro4']

    environment.ParseConfig('freetype-config --libs --cflags')
    environment.ParseConfig('libpng-config --libs --cflags')

    if utils.useLLVM():
        llvm(environment)

    custom_tests = {
        "CheckCompiler": utils.checkCompiler,
        "CheckSDL": checkSDL,
        "CheckAllegro4": checkAllegro4,
        "CheckAllegro5": checkAllegro5
    }

    return utils.configure_backend(environment, backends, custom_tests)
Exemplo n.º 4
0
 def get_env(self, **kwargs):
     cFlags = [
         '-ffunction-sections', '-fdata-sections', '-fno-exceptions',
         '-funsigned-char', '-funsigned-bitfields', '-fpack-struct',
         '-fshort-enums', '-Os',
         '-mmcu=%s' % self.MCU
     ]
     env_defaults = dict(CC='"%s"' % (self.AVR_BIN_PREFIX + 'gcc'),
                         CXX='"%s"' % (self.AVR_BIN_PREFIX + 'g++'),
                         CPPPATH=[self.core_root],
                         CPPDEFINES={
                             'F_CPU': self.F_CPU,
                             'ARDUINO': self.ARDUINO_VER,
                             'AVR': None,
                         },
                         CFLAGS=cFlags + ['-std=gnu99'],
                         CCFLAGS=cFlags,
                         TOOLS=['gcc', 'g++'])
     for k, v in kwargs.iteritems():
         print 'processing kwarg: %s->%s' % (k, v)
         if k in env_defaults and isinstance(env_defaults[k], dict)\
                 and isinstance(v, dict):
             env_defaults[k].update(v)
             print '  update dict'
         elif k in env_defaults and isinstance(env_defaults[k], list):
             env_defaults[k].append(v)
             print '  append to list'
         else:
             env_defaults[k] = v
             print '  set value'
     print 'kwargs:', kwargs
     print 'env_defaults:', env_defaults
     envArduino = Environment(**env_defaults)
     # Add Arduino Processing, Elf, and Hex builders to environment
     for builder_name in ['Processing', 'Elf', 'Hex']:
         envArduino.Append(
             BUILDERS={
                 builder_name:
                 getattr(self, 'get_%s_builder' % builder_name.lower())()
             })
     return envArduino
Exemplo n.º 5
0
def build(appname, sources):

    global opts

    help = """
    Options:
    lib=0|1 [1] build an OclWrapper library
    plat=AMD|NVIDIA|Intel [NVIDIA]
    dev=CPU|GPU [GPU] device
    kernel=<number> [1]   
    w=<number> [1024]   matrix width
    ref=0|1|2 [1]     reference 2=ref only
    v=0|1 [1]         verbose
    mode=0|1|2   COPY|COPY+ALLOC|USE 
    info=0|1
    gpu=-1|0|1 [-1, means automatic selection]
    dbg=0|1 [0]
    nruns= [1]
    D=[comma-sep list of macros]
    """

    if commands.getoutput("uname") == "Darwin":
        OSX = 1
        OSFLAG = '-DOSX'
    else:
        OSX = 0
        OSFLAG = '-D__LINUX__'

    OPENCL_DIR = '.'  #os.environ['OPENCL_DIR']
    opts = Variables()

    args = sys.argv[1:]
    for arg in args:
        if re.match("(\w+)=(\w+)", arg):
            (k, v) = arg.split('=')
            opts.args[k] = v
    buildLibrary = getOpt('lib', 'buildLibrary', '0')
    if appname == '' and buildLibrary == '0':
        buildLibrary = '1'
    dev = getOpt('dev', 'Device', 'GPU')
    plat = getOpt('plat', 'Platform', 'NVIDIA')
    if plat == 'AMD':
        AMD_SDK_PATH = os.environ['AMDAPPSDKROOT']
    elif plat == 'Intel':
        INTEL_SDK_PATH = os.environ['INTELOCLSDKROOT']
    else:
        NVIDIA_SDK_PATH = os.environ['NVSDKCUDA_ROOT']
        if os.environ['OPENCL_GPU'] != 'NVIDIA':
            print 'No NVIDIA platform, defaulting to AMD CPU'
            if os.environ['OPENCL_CPU'] == 'AMD':
                AMD_SDK_PATH = os.environ['AMDAPPSDKROOT']
                plat = 'AMD'
            elif os.environ['OPENCL_CPU'] == 'Intel':
                INTEL_SDK_PATH = os.environ['INTELOCLSDKROOT']
                plat = 'Intel'
            else:
                print 'No OpenCL-capable GPU found, giving up'
                exit
            dev = 'CPU'


#        else:
#            print 'NVIDIA'

    gpu = getOpt('gpu', 'GPU', '-1')
    devidxflag = '-DDEVIDX=' + gpu
    if gpu != '-1':
        dev = 'GPU'

    kernel = getOpt('kernel', 'Kernel', '1')
    nruns = getOpt('nruns', 'Number of runs', '1')
    width = getOpt('w', 'Width', '1024')
    ref = getOpt('ref', 'Reference', '1')
    refflag = '-DREF'
    verbose = getOpt('v', 'Verbose', '0')
    vflag = '-DVERBOSE'
    if verbose == '0':
        vflag = ''
    dbg = getOpt('dbg', 'Debug', '0')
    dbgflag = '-g'
    if dbg == '0':
        dbgflag = ''
    mode = getOpt('mode', 'Mode', '1')
    memreadflag = '-DMRMODE=' + mode
    devinfo = getOpt('info', 'DeviceInfo', '0')
    devinfoflag = ''
    platinfoflag = ''
    if devinfo == '1':
        devinfoflag = '-DDEVINFO'
        platinfoflag = '-DPLATINFO'

    defs = getOpt('D', 'Defines', None)
    defflags = []
    if defs != None:
        deflist = defs.split(',')
        defflags = map(lambda s: '-D' + s, deflist)

    DEVFLAGS = [
        '-D' + dev, devidxflag, '-DKERNEL=' + kernel, '-DNRUNS=' + nruns,
        '-DWIDTH=' + width, '-DREF=' + ref, vflag, memreadflag, devinfoflag,
        platinfoflag
    ] + defflags
    if commands.getoutput("uname") == "Darwin":
        DEVFLAGS += ['-DOSX']

    oclsources = map(
        lambda s: OPENCL_DIR + '/' + s,
        ['Timing.cc', 'DeviceInfo.cc', 'PlatformInfo.cc', 'OclWrapper.cc'])

    env = Environment(CC='g++', CXXFLAGS=['-Wall', dbgflag, '-O3', DEVFLAGS])
    env.Help(help)

    if OSX == 1:
        env['FRAMEWORKS'] = ['OpenCL']
        env.Append(CPPPATH=[OPENCL_DIR])
    else:
        env.Append(LIBS=['OpenCL'])
        if plat == 'AMD':
            env['CPPPATH'] = [
                OPENCL_DIR, AMD_SDK_PATH + '/include', '/usr/include/CL'
            ]
            env['LIBPATH'] = [AMD_SDK_PATH + '/lib/x86_64']
        elif plat == 'Intel':
            env['CPPPATH'] = [OPENCL_DIR, INTEL_SDK_PATH + '/include/CL']
            env['LIBPATH'] = [INTEL_SDK_PATH + '/lib64']
        else:
            env['CPPPATH'] = [
                OPENCL_DIR, OPENCL_DIR + '/CL',
                NVIDIA_SDK_PATH + '/OpenCL/common/inc'
            ]
    if buildLibrary == '1':
        env.Library('OclWrapper', oclsources)
    else:
        env.Append(CPPPATH='./OpenCLIntegration/')
        env.Append(LIBPATH='./OpenCLIntegration/')
        env.Append(LIBS='OclWrapper')
        env.SConscript('OpenCLIntegration/SConstruct')
        env.Program(appname + '_' + dev + '_' + plat + '_' + kernel, sources)
Exemplo n.º 6
0
def getStaticEnvironment():
    environment = Environment(ENV=os.environ)
    peg_color = 'light-cyan'
    environment['PAINTOWN_PLATFORM'] = ['osx']
    environment['PAINTOWN_USE_PRX'] = False
    environment['PAINTOWN_TESTS'] = {'CheckPython': checkPython}
    environment['PAINTOWN_COLORIZE'] = utils.colorize
    environment['PAINTOWN_NETWORKING'] = True
    environment['PAINTOWN_NETWORKING'] = True
    environment.Append(CPPDEFINES=['HAVE_NETWORKING'])
    environment.Append(CPPDEFINES=['MACOSX'])
    environment['LIBS'] = []
    environment['PEG_MAKE'] = "%s %s" % (utils.colorize(
        'Creating peg parser',
        peg_color), utils.colorize('$TARGET', 'light-blue'))
    environment.Append(BUILDERS={'Peg': utils.pegBuilder(environment)})
    environment.Append(CPPPATH=['#src', '#src/util/network/hawknl'])
    # environment.Append(CCFLAGS = Split("-arch i386 -arch x86_64"))
    # print environment['CCCOM']
    # I don't know why appending -arch to ccflags doesn't work, but whatever
    environment[
        'CCCOM'] = '$CC -arch i386 -arch x86_64 $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES -c -o $TARGET'
    environment[
        'CXXCOM'] = '$CXX -arch i386 -arch x86_64 -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
    environment[
        'LINKCOM'] = '$CXX $LINKFLAGS -arch i386 -arch x86_64 $SOURCES $_FRAMEWORKS -Wl,-all_load $ARCHIVES $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET'

    # Default preference for a graphics renderer / input system
    backends = ['SDL', 'Allegro4', 'Allegro5']

    if utils.useAllegro4():
        backends = ['Allegro4', 'SDL', 'Allegro5']

    if utils.useAllegro5():
        backends = ['Allegro5', 'SDL', 'Allegro4']

    #environment.ParseConfig('freetype-config --libs --cflags')
    #environment.ParseConfig('libpng-config --libs --cflags')

    if utils.useLLVM():
        llvm(environment)

    custom_tests = {
        "CheckCompiler": utils.checkCompiler,
        "CheckSDL": checkStaticSDL,
        "CheckOgg": checkStaticOgg,
        "CheckFreetype": checkStaticFreetype,
        "CheckMalloc": checkMallocH,
        "CheckZ": checkStaticZ,
        "CheckPng": checkStaticPng,
        "CheckMpg123": checkStaticMpg123,
        "CheckAllegro4": checkStaticAllegro4,
        "CheckAllegro5": checkStaticAllegro5
    }

    config = environment.Configure(custom_tests=custom_tests)
    config.CheckZ()
    config.CheckOgg()
    config.CheckMpg123()
    config.CheckFreetype()
    config.CheckPng()
    # config.CheckMalloc()
    environment = config.Finish()

    return utils.configure_backend(environment, backends, custom_tests)
Exemplo n.º 7
0
def initOcl(*envt):
    if envt == ():
        env = Environment()
    else:
        env = envt[0]

    global opts, dev, plat, kernel, kopts, kernel_opts, useF, useDyn, mcModel, OPENCL_DIR, useOclWrapper

    help = """
    Options:
     lib=0|1 [1] build an OclWrapper library
    *dyn=0|1 [0] build a dynamic Library             OclBuilder.useDyn
    *mcm=s|m|l [s] mcmodel flag for gcc/gfortran
    *plat=AMD|NVIDIA|Intel|Altera|MIC [NVIDIA]
    *dev=CPU|GPU|ACC|FPGA [GPU] device
     gpu=-1|0|1 [-1, means automatic selection]
     acc=-1|0|1 [-1, means automatic selection]
     O=[gcc -O flag] [3]
     F=0|1 [0] use the functional (non-OO) interface OclBuilder.useF
     V=1.1|1.2 [1.2] OpenCL C++ API version
     info=0|1                                        (DEVINFO, PLATINFO)
    *oclwrapper=0|1 [1] use the OclWrapper API       OclBuilder.useOclWrapper

    The following flags can be used to define macros in your code, they are passed on to the OpenCL kernel as well.
     kernel=<number> [1]                             KERNEL   
     sel=<number> [1] generic selection flag         SELECT
     w=<number> [1024] width, e.g. for matrix        WIDTH 
     wx,wy,wz=<number> [128,128,64] x/y/z dimensions WX,WY,WZ
     nth=<number> [1] number of threads per core     NTH
     ngroups=<number> [0] number of workgroups		 NGROUPS
     order=<number> [1] loop order			        LOOP_ORDER 
     ref=0|1|2 [1]     reference 2=ref only          REF
     v=0|1 [1]         verbose                       VERBOSE 
     warn=0|1 [1]      warnings                      WARNINGS
     mode=0|1|2   COPY|COPY+ALLOC|USE 
     dbg=0|1 [0]                                     OCLDBG
     nruns= [1]                                      NRUNS
    *kopts=<string> kernel options, can only be a single alphanumeric string 
                    if you need complex options, put them in the Scons script
                    For example, to add a path for kernel includes:
                    OclBuilder.kopts='-I/abs/path/to/includes'

    D=[comma-sep list of macros, without values]

    The options marked with * can be set as OclBuilder.OPTION=VALUE in the SCons script
    The macros controlled by the other options are listed on the right
    The directory for the OclWrapper can be accessed via OclBuilder.OPENCL_DIR
    """
    # by default, use the OclWrapper.
    if not 'useOclWrapper' in globals():
        useOclWrapper = True

    if commands.getoutput("uname") == "Darwin":
        OSX = 1
        OSFLAG = '-DOSX'
    else:
        OSX = 0
        OSFLAG = '-D__LINUX__'

    OPENCL_DIR = os.environ['OPENCL_DIR']
    opts = Variables()
    CWD = os.environ['PWD']
    args = sys.argv[1:]
    for arg in args:
        if re.match("(\w+)=(\w+)", arg):
            (k, v) = arg.split('=')
            opts.args[k] = v

    oclwrapper = getOpt('oclwrapper', 'OclWrapper', '1')
    if oclwrapper != '1':
        useOclWrapper = False

    dev = getOpt('dev', 'Device', 'GPU')
    plat = getOpt('plat', 'Platform', 'NVIDIA')
    #    print "PLAT:"+plat
    if OSX == 1:
        plat = 'Apple'
    if plat == 'AMD':
        AMD_SDK_PATH = os.environ['AMDAPPSDKROOT']
    elif plat == 'Intel':
        INTEL_SDK_PATH = os.environ['INTELOCLSDKROOT']
    elif plat == 'MIC':
        INTEL_SDK_PATH = os.environ['INTELOCLSDKROOT']
        dev = 'ACC'
    elif plat == 'Altera':
        ALTERA_SDK_PATH = os.environ['ALTERAOCLSDKROOT']
        dev = 'ACC'
    else:
        if plat != 'Apple':
            NVIDIA_SDK_PATH = os.environ['NVSDKCUDA_ROOT']
            if os.environ['OPENCL_GPU'] != 'NVIDIA':
                #                print 'No NVIDIA platform, defaulting to AMD CPU'
                if os.environ['OPENCL_CPU'] == 'AMD':
                    AMD_SDK_PATH = os.environ['AMDAPPSDKROOT']
                    plat = 'AMD'
                    dev = 'CPU'
                elif os.environ['OPENCL_ACC'] == 'Intel':
                    INTEL_SDK_PATH = os.environ['INTELOCLSDKROOT']
                    plat = 'MIC'
                    dev = 'ACC'
                elif os.environ['OPENCL_ACC'] == 'Altera':
                    ALTERA_SDK_PATH = os.environ['ALTERAOCLSDKROOT']
                    plat = 'Altera'
                    dev = 'FPGA'
                elif os.environ['OPENCL_CPU'] == 'Intel':
                    INTEL_SDK_PATH = os.environ['INTELOCLSDKROOT']
                    plat = 'Intel'
                    dev = 'CPU'
                else:
                    print 'No OpenCL-capable GPU found'
                    exit
#        else:
#            print 'NVIDIA'
    env['KERNEL_OPTS'] = []
    gpu = getOpt('gpu', 'GPU', '-1')
    acc = getOpt('acc', 'ACC', '-1')
    devidxflag = '-DDEVIDX=-1'
    if gpu != '-1':
        devidxflag = '-DDEVIDX=' + gpu
        dev = 'GPU'

    if acc != '-1':
        devidxflag = '-DDEVIDX=' + acc
        dev = 'ACC'

    kernel = getOpt('kernel', 'KERNEL', '1')
    sel = getOpt('sel', 'SELECT', '1')
    nth = getOpt('nth', '#threads', '1')
    ngroups = getOpt('ngroups', '#workgroups', '0')
    loop_order = getOpt('order', 'loop order', '1')
    if not 'kopts' in globals():
        kopts = getOpt(
            'kopts',
            'OpenCL kernel compilation options. Can only be a single alphanumeric string.',
            '-cl-fast-relaxed-math')
    nruns = getOpt('nruns', 'Number of runs', '1')
    width = getOpt('w', 'Width', '1024')
    wx = getOpt('wx', 'X-width', '128')
    wy = getOpt('wy', 'Y-width', '128')
    wz = getOpt('wz', 'Z-width', '64')
    env.Append(KERNEL_OPTS=['-DKERNEL=' + kernel])
    env.Append(KERNEL_OPTS=['-DSELECT=' + sel])
    env.Append(KERNEL_OPTS=['-DNTH=' + nth])
    env.Append(KERNEL_OPTS=['-DWIDTH=' + width])
    env.Append(KERNEL_OPTS=['-DWX=' + wx])
    env.Append(KERNEL_OPTS=['-DWY=' + wy])
    env.Append(KERNEL_OPTS=['-DWZ=' + wz])
    env.Append(KERNEL_OPTS=['-DLOOP_ORDER=' + loop_order])
    ref = getOpt('ref', 'Reference', '1')
    refflag = '-DREF'

    verbose = getOpt('v', 'Verbose', '0')
    vflag = '-DVERBOSE'
    if verbose == '0':
        vflag = ''

    warnings = getOpt('warn', 'Warnings', '1')
    wflag = '-Wall'
    if warnings == '0':
        vflag = ''

    version = getOpt('V', 'Version',
                     '1.2')  # FIXME! V1.2 is broken on most platforms
    verflag = ''
    if version == '1.2':
        verflag = '-DOCLV2'

    dbg = getOpt('dbg', 'Debug', '0')
    dbgflag = '-g'
    dbgmacro = '-DOCLDBG=1'
    if dbg == '0':
        dbgmacro = ''
        dbgflag = ''

    useF = getOpt('F', 'Functional', 0)
    if 'useF' in env:
        if env['useF'] == 1:
            useF = '1'

    useDyn = getOpt('dyn', 'Dynamic Library', 0)
    if 'useDyn' in env:
        if env['useDyn'] == 1:
            useDyn = '1'

    mcModel = getOpt('mcm', 'GCC Code Model Flag', 's')

    optim = getOpt('O', 'Optimisation', '2')
    optflag = '-O' + optim
    mode = getOpt('mode', 'Mode', '1')
    memreadflag = '-DMRMODE=' + mode
    devinfo = getOpt('info', 'DeviceInfo', '0')
    devinfoflag = ''
    platinfoflag = ''
    if devinfo == '1':
        devinfoflag = '-DDEVINFO'
        platinfoflag = '-DPLATINFO'

    defs = getOpt('D', 'Defines', None)
    defflags = []
    if defs != None:
        deflist = defs.split(',')
        defflags = map(lambda s: '-D' + s, deflist)

    DEVFLAGS = ['-DDEV_' + dev, devidxflag] + env['KERNEL_OPTS'] + [
        '-DNRUNS=' + nruns, '-DNGROUPS=' + ngroups, '-DREF=' + ref, vflag,
        verflag, memreadflag, devinfoflag, platinfoflag
    ] + defflags
    if plat == 'Altera':
        DEVFLAGS += ['-DFPGA']
    if dev == 'CPU':
        dbg_dev = dbgmacro + ' '
    else:
        dbg_dev = ''
    kernel_opts = '\\"' + kopts + ' -DEXT_DEFS ' + dbg_dev + (' '.join(
        env['KERNEL_OPTS'])) + '\\"'
    KERNEL_OPTS = ['-DKERNEL_OPTS=' + kernel_opts + '']
    if commands.getoutput("uname") == "Darwin":
        DEVFLAGS += ['-DOSX']
    if useOclWrapper:
        oclsources = map(
            lambda s: OPENCL_DIR + '/OpenCLIntegration/' + s,
            ['Timing.cc', 'DeviceInfo.cc', 'PlatformInfo.cc', 'OclWrapper.cc'])
        env['OCLSOURCES'] = oclsources
    if plat == 'Altera':
        oclsources += [
            OPENCL_DIR + '/OpenCLIntegration/libstdcxx-compatibility.cpp'
        ]
    if OSX == 1 and 'ROOTSYS' in os.environ:
        print 'Setting CXX to g++-4.2 for CERN ROOT on OS X'
        env['CXX'] = [
            'g++-4.2'
        ]  # FIXME: because any higher g++ results in ERROR: malloc: *** error for object 0x7fff7064c500: pointer being freed was not allocated
    elif 'CXX_COMPILER' in os.environ:
        env['CXX'] = [os.environ['CXX_COMPILER']]
    elif 'CXX' in os.environ:
        env['CXX'] = [os.environ['CXX']]
    if True or plat != 'Altera':
        env.Append(CXXFLAGS=['-std=c++11', wflag, dbgflag, dbgmacro, optflag] +
                   DEVFLAGS + KERNEL_OPTS)
    else:
        env.Append(CXXFLAGS=[wflag, dbgflag, dbgmacro, optflag] + DEVFLAGS +
                   KERNEL_OPTS)
    env.Append(CFLAGS=[wflag, dbgflag, optflag] + DEVFLAGS + KERNEL_OPTS)
    env['MACROS'] = DEVFLAGS
    #env.Append(CXXFLAGS = ['-mcmodel=large']

    env.Help(help)
    #if useOclWrapper:
    #env.Append(CPPPATH=[OPENCL_DIR,OPENCL_DIR+'/OpenCLIntegration'])
    env.Append(CPPPATH=[OPENCL_DIR + '/OpenCLIntegration'])
    #   else:
    #       env.Append(CPPPATH=[OPENCL_DIR])
    if OSX == 1:
        env.Append(FRAMEWORKS=['OpenCL'])
#        if useDyn=='1' and useF=='1':
#            env.Append(LIBPATH=['.'])
#            env.Append(LIBS=['OclWrapper'])
    else:
        if plat != 'Altera':
            env.Append(LIBS=['OpenCL'])
        if plat == 'AMD':
            env.Append(CPPPATH=[
                AMD_SDK_PATH + '/include/', AMD_SDK_PATH +
                '/include/CL', '/usr/include/CL'
            ])
            env.Append(LIBPATH=[AMD_SDK_PATH + '/lib/x86_64'])
        elif plat == 'Intel':
            env.Append(CPPPATH=[
                INTEL_SDK_PATH + '/include/', INTEL_SDK_PATH + '/include/CL'
            ])
            env.Append(LIBPATH=[INTEL_SDK_PATH + '/lib64'])
        elif plat == 'MIC':
            env.Append(CPPPATH=[INTEL_SDK_PATH + '/include/'])
            env.Append(LIBPATH=[INTEL_SDK_PATH + '/lib64'])
        elif plat == 'Altera':
            env.Append(CPPPATH=map(lambda s: ALTERA_SDK_PATH + s, [
                '/host/include/', '/common/inc', '/board/nalla_pcie/include'
            ]))
            env.Append(
                LIBPATH=[
                    ALTERA_SDK_PATH + '/host/linux64/lib',
                    ALTERA_SDK_PATH + '/board/nalla_pcie/linux64/lib'
                ]
            )  #,ALTERA_SDK_PATH+'/'+os.environ['AOCL_BOARD_PACKAGE_ROOT']+'/linux64/lib'])
            env.Append(LIBS=[
                'alteracl', 'dl', 'acl_emulator_kernel_rt', 'alterahalmmd',
                'nalla_pcie_mmd', 'elf', 'rt', 'stdc++'
            ])
            env.Append(CXXFLAGS=['-fPIC'])
        else:  # means NVIDIA
            env.Append(CPPPATH=[
                NVIDIA_SDK_PATH + '/OpenCL/common/inc', NVIDIA_SDK_PATH +
                '/OpenCL/common/inc/CL'
            ])

    if useF == '1':
        if 'FORTRAN_COMPILER' in os.environ:
            env['FORTRAN'] = os.environ['FORTRAN_COMPILER']
            env['F95'] = os.environ['FORTRAN_COMPILER']
        if 'FC' in os.environ:
            env['FORTRAN'] = os.environ['FC']
            env['F95'] = os.environ['FC']
        if ('GFORTRAN' in os.environ
                and env['FORTRAN'] == os.environ['GFORTRAN']):
            env['FORTRANFLAGS'] = env['CFLAGS']
            if OSX == 1:
                env['LINKFLAGS'] = ['-Wl,-stack_size,0x40000000'
                                    ]  # Give OS X 1G stack
            env.Append(FORTRANFLAGS=[
                '-Wno-aliasing', '-Wno-unused', '-Wno-unused-dummy-argument',
                '-cpp', '-m64', '-ffree-form', '-ffree-line-length-0',
                '-fconvert=big-endian'
            ])
            #env.Append(FORTRANFLAGS=['-mcmodel=large'])
            #env['F95FLAGS']=['-Wno-aliasing','-Wno-unused','-Wno-unused-dummy-argument','-cpp','-m64','-mcmodel=medium','-ffree-form','-ffree-line-length-0','-fconvert=big-endian']
            env['F95FLAGS'] = [
                '-Wno-aliasing', '-Wno-unused', '-Wno-unused-dummy-argument',
                '-cpp', '-m64', '-ffree-form', '-ffree-line-length-0',
                '-fconvert=big-endian'
            ]
            env.Append(F95FLAGS=env['CFLAGS'])
        else:
            env['CFLAGS'].pop(0)
            env['CFLAGS'].pop(0)
            env['CFLAGS'].pop(0)
            env['FORTRANFLAGS'] = env['CFLAGS']
            env.Append(FORTRANFLAGS=['-m64', '-fast', '-Mipa=fast'])
        if useOclWrapper:
            if useDyn == '1':
                flib = env.SharedLibrary('OclWrapperF', [
                    oclsources,
                    OPENCL_DIR + '/OpenCLIntegration/OclWrapperF.cc'
                ])
            else:
                flib = env.Library('OclWrapperF', [
                    oclsources,
                    OPENCL_DIR + '/OpenCLIntegration/OclWrapperF.cc'
                ])
            fflib = env.Object(
                'oclWrapper.o',
                OPENCL_DIR + '/OpenCLIntegration/oclWrapper.f95')
#    else:
    if useOclWrapper:
        if useDyn == '1':
            lib = env.Library('OclWrapper', oclsources)
        else:
            lib = env.Library('OclWrapper', oclsources)
        env.Append(LIBPATH=['.', OPENCL_DIR + '/OpenCLIntegration/'])
    else:
        env.Append(LIBPATH=['.'])

    if useOclWrapper:
        if useF:
            #env.Append(LIBS=['OclWrapperF','stdc++'])
            env.Append(LIBS=['stdc++'])
            env.Install(OPENCL_DIR + '/OpenCLIntegration/lib', flib)
            env.Alias('installf', OPENCL_DIR + '/OpenCLIntegration/lib', flib)


#    else:
        env.Append(LIBS=['OclWrapper'])
        env.Install(OPENCL_DIR + '/OpenCLIntegration/lib', lib)
        env.Alias('install', OPENCL_DIR + '/OpenCLIntegration/lib', lib)
    return env
Exemplo n.º 8
0
class subst_pathTestCase(unittest.TestCase):
    def setUp(self):
        class FakeEnvironment(object):
            def __init__(self, **kw):
                self.kw = kw

            def subst(self, s, target=None, source=None, conv=lambda x: x):
                if s[0] == '$':
                    s = s[1:]
                    if s == 'target':
                        s = target
                    elif s == 'source':
                        s = source
                    else:
                        s = self.kw[s]
                return s

        self.env = FakeEnvironment(AAA='aaa', NULL='')
        from SCons.Environment import Environment
        self.env = Environment(AAA='aaa', NULL='')

    def test_node(self):
        """Test the subst_path() method on a Node
        """

        import SCons.Node

        class A(object):
            pass

        n = SCons.Node.Node()

        pl = SCons.PathList.PathList((n, ))

        result = pl.subst_path(self.env, 'y', 'z')

        assert result == (n, ), result

    def test_object(self):
        """Test the subst_path() method on a non-Node object
        """
        class A(object):
            def __str__(self):
                return '<object A>'

        a = A()

        pl = SCons.PathList.PathList((a, ))

        result = pl.subst_path(self.env, 'y', 'z')

        assert result == ('<object A>', ), result

    def test_object_get(self):
        """Test the subst_path() method on an object with a get() method
        """
        class B(object):
            def get(self):
                return 'b'

        b = B()

        pl = SCons.PathList.PathList((b, ))

        result = pl.subst_path(self.env, 'y', 'z')

        assert result == ('b', ), result

    def test_string(self):
        """Test the subst_path() method on a non-substitution string
        """

        self.env.subst = lambda s, target, source, conv: 'NOT THIS STRING'

        pl = SCons.PathList.PathList(('x', ))

        result = pl.subst_path(self.env, 'y', 'z')

        assert result == ('x', ), result

    def test_subst(self):
        """Test the subst_path() method on substitution strings
        """

        pl = SCons.PathList.PathList(('$AAA', '$NULL'))

        result = pl.subst_path(self.env, 'y', 'z')

        assert result == ('aaa', ), result

    def test_list_of_lists(self):
        """Test the subst_path() method on substitution of nested lists.
        """
        pl = SCons.PathList.PathList((['$AAA', '$AAA'], '$NULL'))
        result = pl.subst_path(self.env, 'y', 'z')
        assert result == ('aaa', 'aaa'), result

    def test_subst_nested(self):
        """Test the subst_path() method on nested substitution of strings.
        """
        self.env.Append(L1=['a', 'b'], L2=['c', 'd'], L3=['$L2'])
        pl = SCons.PathList.PathList(['$L1'])
        result = pl.subst_path(self.env, 'y', 'z')
        assert result == ('a', 'b'), result
        self.env.Append(L1=['$L2'])
        pl = SCons.PathList.PathList(['$L1'])
        result = pl.subst_path(self.env, 'y', 'z')
        assert result == ('a', 'b', 'c', 'd'), result
        self.env.Append(L1=['$L3'])
        pl = SCons.PathList.PathList(['$L1'])
        result = pl.subst_path(self.env, 'y', 'z')
        assert result == ('a', 'b', 'c', 'd', 'c', 'd'), result

    def test_another_env(self):
        """Test the subst_path does lazy evaluation.
        """
        pl = SCons.PathList.PathList(('$AAA', '$NULL'))
        result = pl.subst_path(self.env, 'y', 'z')
        assert result == ('aaa', ), result
        e = self.env.Clone(AAA='bbb')
        result = pl.subst_path(e, 'y', 'z')
        assert result == ('bbb', ), result
Exemplo n.º 9
0
Arquivo: msp430.py Projeto: kivhift/pu
def IAREnvironment(ew_version = '*', core = '430', data_model = None,
        part = None, double_size = None, hw_mult = None, optimization = None,
        listing_dir = None, fill = None, msp430_txt = False, includes = None):
    """Produce an SCons Environment tailored around IAR's MSP430 tools.

    Most of the arguments are passed through to the underlying IAR tools.  Here
    are the available options:
        - `ew_version`: ``*`` or the specific version number
        - `core`: ``430`` or ``430X``
        - `data_model`: if ``430X`` is given for `core`, then `data_model` must
          be one of ``s``, ``m`` or ``l`` for a small, medium or large data
          model
        - `part`: the MSP430 part number; e.g., ``fr5969``
        - `double_size`: 32 or 64
        - `hw_mult`: one of ``mult``, ``mult32`` or ``mult32_alt``
        - `optimization`: one of ``n``, ``l``, ``m``, ``h``, ``hs`` or ``hz``
        - `listing_dir`: directory to output listings to
        - `fill`: hex value to fill unused memory with; e.g., ``3fff``
        - `msp430_txt`: set to `True` to also output MSP430 text
        - `includes`: list of directories to add to include path

    Only `ew_version` and `core` must be specified.  If the rest of the
    arguments aren't specified, then the feature is not enabled or the default
    value is used if needed.
    """

    # The SCons stuff isn't normally importable.  (It's taken care of when
    # building.)  So, import the stuff here so as to allow the module to be
    # imported normally (i.e., via the REPL, Sphinx, etc.).
    from SCons.Defaults import ASAction
    from SCons.Environment import Environment

    candidates = glob(
        r'C:\Program Files\IAR Systems\Embedded Workbench ' + ew_version)
    if not candidates: raise ValueError('Embedded workbench not found.')
    candidates.sort()
    ewb = candidates[-1]
    def join_ewb(*a): return join(ewb, *a)
    def base_quoted(*a): return list2cmdline((join_ewb(*a),))
    binp = join(*'430 bin'.split())
    a430 = base_quoted(binp, 'a430')
    icc430 = base_quoted(binp, 'icc430')
    xlink = base_quoted(binp, 'xlink')
    clib = '430 lib clib cl'

    e = Environment(
        AS = a430,
        ASFLAGS = [],
        CC = icc430,
        CCCOM = '$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES',
        CFLAGS = [],
        CPPPATH = [],
        INCPREFIX = '-I ',
        LINK = xlink,
        LINKCOM = (
            '$LINK -o $TARGET $_LIBDIRFLAGS $_LIBFLAGS $LINKFLAGS $SOURCES '),
        LINKFLAGS = [],
        OBJSUFFIX = '.r43',
        PROGSUFFIX = '.d43',
        TOOLS = ['as', 'cc', 'link']
    )

    # SCons doesn't know about this extension for assembly files.
    e['BUILDERS']['Object'].add_action('.s43', ASAction)

    # Set up the base arguments to be augmented by the given arguments below.
    aflags = '-M() -s+ -t8 -ws -r'.split()
    cflags = '''--clib --diag_suppress Pa050 --warnings_are_errors -r
        --char_is_unsigned --require_prototypes
        --macro_positions_in_diagnostics'''.split()
    lflags = '''-r'''.split()
    afe, cfe, lfe = aflags.extend, cflags.extend, lflags.extend

    core = core.lower()
    clib += core
    if '430' == core:
        afe(['-v0'])
        cfe(['--core=430'])
    elif '430x' == core:
        if not data_model: data_model = 's'
        clib += data_model
        afe(['-v1'])
        cfe(['--core=430X', '--data_model={}'.format(
            dict(s = 'small', m = 'medium', l = 'large')[data_model])])
    else:
        raise ValueError('Invalid core specification: {}'.format(core))

    cfg_dir = join(*'430 config'.split())
    if part:
        # In the IAR-supplied files, the stack size and heap size aren't
        # defined so we'll need to include them.  The linker also needs to be
        # told that the library-supplied boot code is in __program_start().
        lfe('''-D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80
            -s __program_start -f'''.split())
        lfe([join_ewb(cfg_dir, 'lnk430{}.xcl'.format(part))])
    else:
        lfe(['-cmsp430'])

    if not double_size: double_size = 32
    clib += {32 : 'f', 64 : 'd'}[double_size] + '.r43'
    cfe(['--double={}'.format(double_size)])

    if hw_mult:
        lfe(['-f', join_ewb(join(cfg_dir, dict(
            mult = 'multiplier.xcl',
            mult32 = 'multiplier32.xcl',
            mult32_alt = 'multiplier32_loc2.xcl')[hw_mult]))])
        cfe(['--multiplier={}'.format(
            32 if hw_mult.startswith('mult32') else 16)])

    if optimization:
        cfe(['-O{}'.format(optimization)])

    if listing_dir:
        afe('-L{} -cM'.format(listing_dir).split())
        cfe('-lA {0} -lC {0}'.format(listing_dir).split())
        lfe('-L -xeims'.split())

    if fill:
        lfe(['-H{}'.format(fill)])

    if msp430_txt:
        lfe(['-Omsp430_txt'])

    if includes:
        e.Append(CPPPATH = includes)
        afe(['-I{}'.format(p) for p in includes])

    # Make sure that clib is given after our objects so that library
    # replacements are possible.  Otherwise, the library code is found first
    # and linked.
    e['LINKCOM'] += base_quoted(*clib.split())
    e.Append(ASFLAGS = aflags, CFLAGS = cflags, LINKFLAGS = lflags)

    return e
Exemplo n.º 10
0
def GetBuildEnvironment(targets,arguments):
  env = Environment();
  env.EnsurePythonVersion(2,3)
  env.EnsureSConsVersion(0,96)
  env.SetOption('implicit_cache',1)
  env.TargetSignatures('build')
  if 'mode' in arguments:
    buildname = arguments['mode']
  else:
    buildname = 'default'
  options_file = '.' + buildname + '_options'
  if not exists(options_file):
    opts = Options('.options_cache',arguments)
  else:
    opts = Options(options_file,arguments)
  opts.AddOptions(
    BoolOption('assertions','Include assertions in the code',1),
    BoolOption('debug','Build with debug options turned on',1),
    BoolOption('inline','Cause inline code to be inline',0),
    BoolOption('optimize','Build object files with optimization',0),
    BoolOption('profile','Generate profiling aware code',0),
    BoolOption('small','Generate smaller code rather than faster',0),
    BoolOption('strip','Strip executables of their symbols',0),
  )
  opts.Add('confpath','Specify additional configuration dirs to search','')
  opts.Add('prefix','Specify where to install HLVM','/usr/local')
  opts.Add('suites','Specify a list of test suites to run')
  opts.Add('with_llvm','Specify where LLVM is located','/usr/local')
  opts.Add('with_apr','Specify where apr is located','/usr/local/apr')
  opts.Add('with_apru','Specify where apr-utils is located','/usr/local/apr')
  opts.Add('with_libxml2','Specify where LibXml2 is located','/usr/local')
  opts.Add('with_gxx','Specify where the GCC C++ compiler is located',
           '/usr/local/bin/g++')
  opts.Add('with_llc','Specify where the LLVM compiler is located',
           '/usr/local/bin/llc')
  opts.Add('with_llvm_ld','Specify where the LLVM GCC Linker is located',
           '/usr/local/bin/llvm-ld')
  opts.Add('with_llvmdis','Specify where the LLVM disassembler is located',
           '/usr/local/bin/llvm-dis')
  opts.Add('with_llvmas','Specify where the LLVM assembler is located',
           '/usr/local/bin/llvm-as')
  opts.Add('with_llvmgcc','Specify where the LLVM C compiler is located',
           '/usr/local/bin/llvm-gcc')
  opts.Add('with_llvmgxx','Specify where the LLVM C++ compiler is located',
           '/usr/local/bin/llvm-g++')
  opts.Add('with_llvmar','Specify where the LLVM bytecode archiver is located',
           '/usr/local/bin/llvm-g++')
  opts.Add('with_llvm2cpp','Specify where the LLVM llvm2cpp program is located',
           '/usr/local/bin/llvm2cpp')
  opts.Add('with_gperf','Specify where the gperf program is located',
           '/usr/local/bin/gperf')
  opts.Add('with_runtest','Specify where DejaGnu runtest program is located',
           '/usr/local/bin/runtest')
  opts.Add('with_doxygen','Specify where the doxygen program is located',
           '/usr/local/bin/doxygen')
  opts.Add('with_xsltproc','Specify where the XSLT processor is located',
           '/usr/local/bin/xsltproc')
  opts.Add('with_pod2html','Specify where the POD to HTML generator is located',
           '/usr/local/bin/pod2html')
  opts.Add('with_pod2man','Specify where the POD to MAN generator is located',
           '/usr/local/bin/pod2man')
  opts.Add('with_xmllint','Specify where the xmllint program is located',
           '/usr/local/bin/xmllint')
  opts.Update(env)
  env['HLVM_Copyright'] = 'Copyright (c) 2006 Reid Spencer'
  env['HLVM_Maintainer'] = 'Reid Spencer <rspencer@reidspencer>'
  env['HLVM_Version'] = '0.2svn'
  env['HLVM_SO_CURRENT'] = '0'
  env['HLVM_SO_REVISION'] = '1'
  env['HLVM_SO_AGE'] = '0'
  env['HLVM_SO_VERSION'] = env['HLVM_SO_CURRENT']+':'+env['HLVM_SO_REVISION']
  env['HLVM_SO_VERSION'] += ':' + env['HLVM_SO_AGE']
  env['CCFLAGS']  = ' -pipe -Wall -Wcast-align -Wpointer-arith -Wno-long-long'
  env['CCFLAGS'] += ' -pedantic'
  env['CXXFLAGS'] = ' -pipe -Wall -Wcast-align -Wpointer-arith -Wno-deprecated'
  env['CXXFLAGS']+= ' -Wold-style-cast -Woverloaded-virtual -Wno-unused'
  env['CXXFLAGS']+= ' -Wno-long-long -pedantic -fno-operator-names -ffor-scope'
  env['CXXFLAGS']+= ' -fconst-strings'
  env['CPPDEFINES'] = { '__STDC_LIMIT_MACROS':None, '_GNU_SOURCE':None }
  VariantName=''
  if env['small'] == 1:
    VariantName='S'
    env.Append(CCFLAGS=' -Os')
    env.Append(CXXFLAGS=' -Os')
  else :
    VariantName='s'

  if env['profile'] == 1:
    VariantName+='P'
    env.Append(CCFLAGS=' -pg')
    env.Append(CXXFLAGS=' -pg')
  else :
    VariantName+='p'

  if env['assertions'] == 1:
    VariantName+='A'
    env.Append(CPPDEFINES={'HLVM_ASSERT':None})
  else :
    VariantName+='a'

  if env['debug'] == 1 :
    VariantName += 'D'
    env.Append(CCFLAGS=' -ggdb')
    env.Append(CXXFLAGS=' -ggdb')
    env.Append(CPPDEFINES={'HLVM_DEBUG':None})
    env.Append(LINKFLAGS='-ggdb')
  else :
    VariantName+='d'

  if env['inline'] == 1:
    VariantName+='I'
  else :
    VariantName+='i'
    env.Append(CXXFLAGS=' -fno-inline')

  if env['optimize'] == 1 :
    VariantName+='O'
    env.Append(CCFLAGS=' -O3')
    env.Append(CXXFLAGS=' -O3')
    env.Append(LINKFLAGS='-O3')
  else :
    VariantName+='o'

  if env['strip']:
    VariantName +='T'
    env['LINKFLAGS'] += ' -s'
  else:
    VariantName += 't'

  BuildDir = buildname 
  env['Variant'] = VariantName
  env['BuildDir'] = BuildDir
  env['AbsObjRoot'] = env.Dir('#' + BuildDir).abspath
  env['AbsSrcRoot'] = env.Dir('#').abspath
  env.Prepend(CPPPATH=[pjoin('#',BuildDir)])
  env.Prepend(CPPPATH=['#'])
  env['LIBPATH'] = []
  env['BINPATH'] = []
  env['LLVMASFLAGS'] = ''
  env['LLVM2CPPFLAGS'] = ''
  env['LLVMGXXFLAGS'] = ''
  env['LLVMGCCFLAGS'] = ''
  env.BuildDir(BuildDir,'#',duplicate=0)
  env.SConsignFile(pjoin(BuildDir,'sconsign'))
  if 'install' in COMMAND_LINE_TARGETS:
    env.Alias('install',[
      env.Dir(pjoin(env['prefix'],'bin')),
      env.Dir(pjoin(env['prefix'],'lib')),
      env.Dir(pjoin(env['prefix'],'include')),
      env.Dir(pjoin(env['prefix'],'docs'))
    ])

  env.Help("""
HLVM Build Environment

Usage Examples:: 
  scons             - to do a normal build
  scons --clean     - to remove all derived (built) objects
  scons check       - to run the DejaGnu test suite
  scons install     - to install HLVM to a target directory
  scons docs        - to generate the doxygen documentation

Options:
""" + opts.GenerateHelpText(env,sort=cmp))
  print "HLVM BUILD MODE: " + VariantName + " (" + buildname + ")"
  ConfigureHLVM(env)
  now = datetime.datetime.utcnow();
  env['HLVM_ConfigTime'] = now.ctime();
  opts.Save(options_file,env)
  return env
Exemplo n.º 11
0
class bcolors:
    CYAN = '\033[36m'
    LRED = '\033[91m'
    LGREEN = '\033[92m'
    LYELLOW = '\033[93m'
    LBLUE = '\033[94m'
    LMAGENTA = '\033[95m'
    LCYAN = '\033[96m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'


# Replace long comment for short version
if ARGUMENTS.get('verbose') != '1':
    env.Append(
        CCCOMSTR=[bcolors.CYAN + 'Compiling ' + bcolors.ENDC + '$TARGET'])
    env.Append(
        CXXCOMSTR=[bcolors.CYAN + 'Compiling ' + bcolors.ENDC + '$TARGET'])
    env.Append(
        ARCOMSTR=[bcolors.LCYAN + 'Archiving ' + bcolors.ENDC + '$TARGET'])
    env.Append(
        LINKCOMSTR=[bcolors.LBLUE + 'Linking ' + bcolors.ENDC + '$TARGET'])

# Run PocoDir.py for configuration
SConscript('config/PocoDir.py')
PocoBase = env['POCOBASE']

# Get current path
WGCProjectBase = [os.getcwd()]
env.Append(CPPPATH=WGCProjectBase)
Exemplo n.º 12
0
def iphoneEnvironment():
    base = Environment(ENV=os.environ)
    gccversion = '4.2'
    iostarget = '4.3'
    osxtarget = '10.5'
    platform_phone = 'iPhoneOS'
    arch_phone = 'armv6'
    phone_bin_dir = '/Developer/Platforms/%s.platform/Developer/usr/bin' % platform_phone
    base.PrependENVPath('PATH', phone_bin_dir)
    sdkroot_phone = '/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk' % (
        platform_phone, platform_phone, iostarget)
    postfix = '-%s' % gccversion

    def setup(x, post):
        return '%s%s' % (x, post)

    # only the compiler can have different versions
    base['CC'] = setup('gcc', postfix)
    base['CXX'] = setup('g++', postfix)

    def stringify(array):
        str = ''
        for item in array:
            str += item + ' '
        return [str.split(" ")]

    cflags_phone = [
        '-std=gnu99', '-fobjc-legacy-dispatch', '-fobjc-abi-version=2'
    ]
    ccflags_phone = [
        '-arch %s' % arch_phone, '-pipe', '-mdynamic-no-pic',
        '-fvisibility=hidden',
        '-isysroot %s' % sdkroot_phone
    ] + Split(
        """-g -O2 -gdwarf-2 -mthumb -Wall -Wmissing-prototypes -ffast-math -fno-strict-aliasing -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -gdwarf-2 -Wall -fno-strict-aliasing"""
    )
    ldflags_phone = [
        '-arch %s' % arch_phone,
        '-isysroot %s' % sdkroot_phone, '-Wl,-dead_strip',
        '-Xlinker -objc_abi_version', '-Xlinker 2', '-Wl,-search_paths_first',
        '-Wl,-headerpad_max_install_names'
    ]
    frameworks = Split(
        """OpenGLES CoreGraphics QuartzCore UIKit Foundation CoreFoundation OpenAL"""
    )

    # ldflags_phone = ['-arch %s' % arch_phone, '-framework OpenGLES']
    defines_phone = Split("""__IPHONE_OS_VERSION_MIN_REQUIRED=40300""")
    cppflags = Split("")

    def setFlags(includes, cflags, ccflags, cppflags, ldflags, defines, env):
        env.Append(CPATH=includes)
        env.Append(CPPPATH=includes)
        env.Append(CFLAGS=cflags)
        env.Append(CCFLAGS=ccflags)
        env.Append(CPPFLAGS=cppflags)
        env.Append(LINKFLAGS=ldflags)
        env.Append(CPPDEFINES=defines)

    # base.Append(LIBS = ['allegro-phone'])
    base.Append(FRAMEWORKS=frameworks)
    base['LIBS'] = [
        'allegro', 'allegro_acodec', 'allegro_audio', 'allegro_image',
        'allegro_memfile', 'allegro_primitives', 'allegro_ttf', 'allegro_font'
    ]
    base.ParseConfig(
        'misc/allegro-iphone/install/phone/bin/freetype-config --cflags --libs'
    )
    base.Append(LIBPATH=['#misc/allegro-iphone/install/phone/lib'])
    includes = [
        sdkroot_phone, '#misc/allegro-iphone/allegro/include/allegro5/'
    ]
    #  + ['%s/usr/include/c++/4.2.1' % sdkroot_phone] + ['%s/usr/include/c++/4.2.1/i686-apple-darwin10' % sdkroot_phone]
    setFlags(includes + ['%s/usr/include' % sdkroot_phone],
             stringify(cflags_phone), stringify(ccflags_phone), cppflags,
             stringify(ldflags_phone), defines_phone, base)

    return base