Esempio n. 1
0
def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None):
    '''generate a vscript file for our public libraries'''
    if abi_directory:
        source = bld.path.ant_glob('%s/%s-[0-9]*.sigs' %
                                   (abi_directory, libname))

        def abi_file_key(path):
            return version_key(path[:-len(".sigs")].rsplit("-")[-1])

        source = sorted(source.split(), key=abi_file_key)
    else:
        source = ''

    libname = os.path.basename(libname)
    version = os.path.basename(version)
    libname = libname.replace("-", "_").replace("+", "_").upper()
    version = version.replace("-", "_").replace("+", "_").upper()

    t = bld.SAMBA_GENERATOR(vscript,
                            rule=abi_build_vscript,
                            source=source,
                            group='vscripts',
                            target=vscript)
    if abi_match is None:
        abi_match = ["*"]
    else:
        abi_match = samba_utils.TO_LIST(abi_match)
    t.env.ABI_MATCH = abi_match
    t.env.VERSION = version
    t.env.LIBNAME = libname
    t.vars = ['LIBNAME', 'VERSION', 'ABI_MATCH']
Esempio n. 2
0
def parse_sigs(sigs, abi_match):
    '''parse ABI signatures file'''
    abi_match = samba_utils.TO_LIST(abi_match)
    ret = {}
    a = sigs.split('\n')
    for s in a:
        if s.find(':') == -1:
            continue
        sa = s.split(':')
        if abi_match:
            matched = False
            negative = False
            for p in abi_match:
                if p[0] == '!' and fnmatch.fnmatch(sa[0], p[1:]):
                    negative = True
                    break
                elif fnmatch.fnmatch(sa[0], p):
                    matched = True
                    break
            if (not matched) and negative:
                continue
        Logs.debug("%s -> %s" % (sa[1], normalise_signature(sa[1])))
        ret[sa[0]] = normalise_signature(sa[1])
    return ret
Esempio n. 3
0
def replace_refill_task_list(self):
    '''replacement for refill_task_list() that deletes stale files'''

    iit = old_refill_task_list(self)
    bld = self.bld

    if not getattr(bld, 'new_rules', False):
        # we only need to check for stale files if the build rules changed
        return iit

    if Options.options.compile_targets:
        # not safe when --target is used
        return iit

    # execute only once
    if getattr(self, 'cleanup_done', False):
        return iit
    self.cleanup_done = True

    def group_name(g):
        tm = self.bld.task_manager
        return [x for x in tm.groups_names
                if id(tm.groups_names[x]) == id(g)][0]

    bin_base = bld.bldnode.abspath()
    bin_base_len = len(bin_base)

    # paranoia
    if bin_base[-4:] != '/bin':
        raise Utils.WafError("Invalid bin base: %s" % bin_base)

    # obtain the expected list of files
    expected = []
    for i in range(len(bld.task_manager.groups)):
        g = bld.task_manager.groups[i]
        tasks = g.tasks_gen
        for x in tasks:
            try:
                if getattr(x, 'target'):
                    tlist = samba_utils.TO_LIST(getattr(x, 'target'))
                    ttype = getattr(x, 'samba_type', None)
                    task_list = getattr(x, 'compiled_tasks', [])
                    if task_list:
                        # this gets all of the .o files, including the task
                        # ids, so foo.c maps to foo_3.o for idx=3
                        for tsk in task_list:
                            for output in tsk.outputs:
                                objpath = os.path.normpath(
                                    output.abspath(bld.env))
                                expected.append(objpath)
                    for t in tlist:
                        if ttype in ['LIBRARY', 'MODULE']:
                            t = samba_utils.apply_pattern(
                                t, bld.env.shlib_PATTERN)
                        if ttype == 'PYTHON':
                            t = samba_utils.apply_pattern(
                                t, bld.env.pyext_PATTERN)
                        p = os.path.join(x.path.abspath(bld.env), t)
                        p = os.path.normpath(p)
                        expected.append(p)
                for n in x.allnodes:
                    p = n.abspath(bld.env)
                    if p[0:bin_base_len] == bin_base:
                        expected.append(p)
            except:
                pass

    for root, dirs, files in os.walk(bin_base):
        for f in files:
            p = root + '/' + f
            if os.path.islink(p):
                link = os.readlink(p)
                if link[0:bin_base_len] == bin_base:
                    p = link
            if f in ['config.h']:
                continue
            (froot, fext) = os.path.splitext(f)
            if fext not in ['.c', '.h', '.so', '.o']:
                continue
            if f[-7:] == '.inst.h':
                continue
            if p.find("/.conf") != -1:
                continue
            if not p in expected and os.path.exists(p):
                Logs.warn("Removing stale file: %s" % p)
                os.unlink(p)
    return iit