Esempio n. 1
0
def get_build_from_file (platform, file_name, name):
    gub_name = file_name.replace (os.getcwd () + '/', '')
    logging.verbose ('reading spec: %(gub_name)s\n' % locals ())
    # Ugh, FIXME
    # This loads gub/specs/darwin/python.py in PYTHON. namespace,
    # overwriting the PYTHON. namespace from gub/specs/python.py
    # Current workaround: always/also use __darwin etc. postfixing
    # of class names, also in specs/darwin/ etc.
    warnings.filterwarnings ('ignore', '''Parent module 'python-2' ''')
    module = misc.load_module (file_name, name)
    # cross/gcc.py:Gcc will be called: cross/Gcc.py,
    # to distinguish from specs/gcc.py:Gcc.py
    base = os.path.basename (name)
    class_name = ((base[0].upper () + base[1:])
                  .replace ('-', '_')
                  .replace ('.', '_')
                  .replace ('++', '_xx_')
                  .replace ('+', '_x_')
                  + ('-' + platform).replace ('-', '__'))
    logging.debug ('LOOKING FOR: %(class_name)s\n' % locals ())
    cls = misc.most_significant_in_dict (module.__dict__, class_name, '__')
    if (platform == 'tools32'
        and (not cls or issubclass (cls, target.AutoBuild))):
        cls = misc.most_significant_in_dict (module.__dict__, class_name.replace ('tools32', 'tools'), '__')
    if ((platform == 'tools' or platform == 'tools32')
        and (issubclass (cls, target.AutoBuild)
             and not issubclass (cls, tools.AutoBuild)
             and not issubclass (cls, tools32.AutoBuild))):
        cls = None
    return cls
Esempio n. 2
0
File: cross.py Progetto: cneira/gub
def get_cross_module (settings):
    platform = settings.platform
    if platform in cross_module_cache:
        return cross_module_cache[platform]

    base = re.sub ('[-0-9].*', '', platform)
    gubdir = settings.gubdir
    for name in platform, base:
        file_name = '%(gubdir)s/gub/%(name)s.py' % locals ()
        if os.path.exists (file_name):
            break

    gub_log.info ('module name: ' + name + '\n')
    module = misc.load_module (file_name, base)

    cross_module_checksums[platform] = md5.md5 (open (file_name).read ()).hexdigest ()
    cross_module_cache[platform] = module
    return module
Esempio n. 3
0
def get_cross_module(settings):
    platform = settings.platform
    if platform in cross_module_cache:
        return cross_module_cache[platform]

    base = re.sub('[-0-9].*', '', platform)
    gubdir = settings.gubdir
    for name in platform, base:
        file_name = '%(gubdir)s/gub/%(name)s.py' % locals()
        if os.path.exists(file_name):
            break

    logging.info('module name: ' + name + '\n')
    module = misc.load_module(file_name, base)

    cross_module_checksums[platform] = md5.md5(
        open(file_name).read()).hexdigest()
    cross_module_cache[platform] = module
    return module
Esempio n. 4
0
def get_build_from_file (platform, file_name, name):
    gub_name = file_name.replace (os.getcwd () + '/', '')
    logging.verbose ('reading spec: %(gub_name)s\n' % locals ())
    # Ugh, FIXME
    # This loads gub/specs/darwin/python.py in PYTHON. namespace,
    # overwriting the PYTHON. namespace from gub/specs/python.py
    # Current workaround: always/also use __darwin etc. postfixing
    # of class names, also in specs/darwin/ etc.
    module = misc.load_module (file_name, name)
    # cross/gcc.py:Gcc will be called: cross/Gcc.py,
    # to distinguish from specs/gcc.py:Gcc.py
    base = os.path.basename (name)
    class_name = ((base[0].upper () + base[1:])
                  .replace ('-', '_')
                  .replace ('.', '_')
                  .replace ('++', '_xx_')
                  .replace ('+', '_x_')
                  + ('-' + platform).replace ('-', '__'))
    logging.debug ('LOOKING FOR: %(class_name)s\n' % locals ())
    return misc.most_significant_in_dict (module.__dict__, class_name, '__')