Exemplo n.º 1
0
    def generateXpcomXpt(self, config, targetPath, files, cache_dir):
        if not self.targetNeedBuild(targetPath):
            return
        xpts = []
        includePaths = [mozpath.join(config.topobjdir, 'dist/idl'),
            mozpath.join(self.libxul_sdk, 'idl')]

        import xpidl
        import xpt
        import typelib
        deps = set()
        p = xpidl.IDLParser(outputdir=cache_dir)
        for f in files:
            idl_data = open(f).read()
            filename =  mozpath.join('../../../dist/idl', os.path.basename(f))

            idl = p.parse(idl_data, filename = filename)
            idl.resolve(includePaths, p)
            xptIo = io.BytesIO()
            typelib.write_typelib(idl, xptIo, filename = filename)
            xptIo.seek(0)
            xpts.append(xptIo)

            self.updateIdlDeps(config, idl.deps, deps)

        print("Generating %s" % targetPath)
        xpt.xpt_link(xpts).write(targetPath)
        self.addDependencies(targetPath, deps)
        self.addDependencies(targetPath, [targetPath])
Exemplo n.º 2
0
def process(input_dir, cache_dir, header_dir, xpt_dir, deps_dir, module, stems):
    p = IDLParser(outputdir=cache_dir)

    xpts = {}
    deps = set()

    # Write out dependencies for Python modules we import. If this list isn't
    # up to date, we will not re-process XPIDL files if the processor changes.
    for imported in ('header', 'typelib', 'xpidl', 'xpt'):
        path = sys.modules[imported].__file__

        if path.endswith('.pyc'):
            path = path[0:-1]

        deps.add(path)

    for stem in stems:
        path = os.path.join(input_dir, '%s.idl' % stem)
        idl_data = open(path).read()

        idl = p.parse(idl_data, filename=path)
        idl.resolve([input_dir], p)

        header_path = os.path.join(header_dir, '%s.h' % stem)
        deps_path = os.path.join(deps_dir, '%s.pp' % stem)

        xpt = BytesIO()
        write_typelib(idl, xpt, path)
        xpt.seek(0)
        xpts[stem] = xpt

        deps |= set(dep.replace('\\', '/') for dep in idl.deps)

        with FileAvoidWrite(header_path) as fh:
            print_header(idl, fh, path)

    # TODO use FileAvoidWrite once it supports binary mode.
    xpt_path = os.path.join(xpt_dir, '%s.xpt' % module)
    xpt_link(xpts.values()).write(xpt_path)

    deps_path = os.path.join(deps_dir, '%s.pp' % module)
    with FileAvoidWrite(deps_path) as fh:
        # Need output to be consistent to avoid rewrites.
        s_deps = sorted(deps)
        fh.write('%s: %s\n' % (xpt_path, ' '.join(s_deps)))
        for dep in s_deps:
            fh.write('%s:\n' % dep)
Exemplo n.º 3
0
def process(input_dir, cache_dir, header_dir, xpt_dir, deps_dir, module,
            stems):
    p = IDLParser(outputdir=cache_dir)

    xpts = {}
    mk = Makefile()
    rule = mk.create_rule()

    # Write out dependencies for Python modules we import. If this list isn't
    # up to date, we will not re-process XPIDL files if the processor changes.
    rule.add_dependencies(iter_modules_in_path(topsrcdir))

    for stem in stems:
        path = os.path.join(input_dir, '%s.idl' % stem)
        idl_data = open(path).read()

        idl = p.parse(idl_data, filename=path)
        idl.resolve([input_dir], p)

        header_path = os.path.join(header_dir, '%s.h' % stem)
        deps_path = os.path.join(deps_dir, '%s.pp' % stem)

        xpt = BytesIO()
        write_typelib(idl, xpt, path)
        xpt.seek(0)
        xpts[stem] = xpt

        rule.add_dependencies(idl.deps)

        with FileAvoidWrite(header_path) as fh:
            print_header(idl, fh, path)

    # TODO use FileAvoidWrite once it supports binary mode.
    xpt_path = os.path.join(xpt_dir, '%s.xpt' % module)
    xpt_link(xpts.values()).write(xpt_path)

    rule.add_targets([xpt_path])
    deps_path = os.path.join(deps_dir, '%s.pp' % module)
    with FileAvoidWrite(deps_path) as fh:
        mk.dump(fh)
Exemplo n.º 4
0
def process(input_dir, inc_paths, cache_dir, header_dir, xpt_dir, deps_dir, module, stems):
    p = IDLParser(outputdir=cache_dir)

    xpts = {}
    mk = Makefile()
    rule = mk.create_rule()

    # Write out dependencies for Python modules we import. If this list isn't
    # up to date, we will not re-process XPIDL files if the processor changes.
    rule.add_dependencies(iter_modules_in_path(topsrcdir))

    for stem in stems:
        path = os.path.join(input_dir, "%s.idl" % stem)
        idl_data = open(path).read()

        idl = p.parse(idl_data, filename=path)
        idl.resolve([input_dir] + inc_paths, p)

        header_path = os.path.join(header_dir, "%s.h" % stem)
        deps_path = os.path.join(deps_dir, "%s.pp" % stem)

        xpt = BytesIO()
        write_typelib(idl, xpt, path)
        xpt.seek(0)
        xpts[stem] = xpt

        rule.add_dependencies(idl.deps)

        with FileAvoidWrite(header_path) as fh:
            print_header(idl, fh, path)

    # TODO use FileAvoidWrite once it supports binary mode.
    xpt_path = os.path.join(xpt_dir, "%s.xpt" % module)
    xpt_link(xpts.values()).write(xpt_path)

    rule.add_targets([xpt_path])
    deps_path = os.path.join(deps_dir, "%s.pp" % module)
    with FileAvoidWrite(deps_path) as fh:
        mk.dump(fh)