Esempio n. 1
0
def generate_interface_example(config, interfaceName):
    """
    |config| Is the configuration object.
    |interfaceName| is the name of the interface we're generating an example for.
    """

    root = CGExampleRoot(config, interfaceName)
    exampleHeader = interfaceName + "-example.h"
    exampleImpl = interfaceName + "-example.cpp"
    replaceFileIfChanged(exampleHeader, root.declare())
    replaceFileIfChanged(exampleImpl, root.define())
Esempio n. 2
0
def generate_interface_example(config, interfaceName):
    """
    |config| Is the configuration object.
    |interfaceName| is the name of the interface we're generating an example for.
    """

    root = CGExampleRoot(config, interfaceName)
    exampleHeader = interfaceName + "-example.h"
    exampleImpl = interfaceName + "-example.cpp"
    replaceFileIfChanged(exampleHeader, root.declare())
    replaceFileIfChanged(exampleImpl, root.define())
Esempio n. 3
0
def generate_binding_files(config, outputprefix, srcprefix, webidlfile,
                           generatedEventsWebIDLFiles):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    depsname = ".deps/" + outputprefix + ".pp"
    root = CGBindingRoot(config, outputprefix, webidlfile)
    replaceFileIfChanged(outputprefix + ".h", root.declare())
    replaceFileIfChanged(outputprefix + ".cpp", root.define())

    if webidlfile in generatedEventsWebIDLFiles:
        eventName = webidlfile[:-len(".webidl")]
        generatedEvent = CGEventRoot(config, eventName)
        replaceFileIfChanged(eventName + ".h", generatedEvent.declare())
        replaceFileIfChanged(eventName + ".cpp", generatedEvent.define())

    mk = Makefile()
    # NOTE: it's VERY important that we output dependencies for the FooBinding
    # file here, not for the header or generated cpp file.  These dependencies
    # are used later to properly determine changedDeps and prevent rebuilding
    # too much.  See the comment explaining $(binding_dependency_trackers) in
    # Makefile.in.
    rule = mk.create_rule([outputprefix])
    rule.add_dependencies(
        os.path.join(srcprefix, x) for x in sorted(root.deps()))
    rule.add_dependencies(iter_modules_in_path(topsrcdir))
    with open(depsname, 'w') as f:
        mk.dump(f)
Esempio n. 4
0
def generate_binding_files(config, outputprefix, srcprefix, webidlfile,
                           generatedEventsWebIDLFiles):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    depsname = ".deps/" + outputprefix + ".pp"
    root = CGBindingRoot(config, outputprefix, webidlfile)
    replaceFileIfChanged(outputprefix + ".h", root.declare())
    replaceFileIfChanged(outputprefix + ".cpp", root.define())

    if webidlfile in generatedEventsWebIDLFiles:
        eventName = webidlfile[:-len(".webidl")]
        generatedEvent = CGEventRoot(config, eventName)
        replaceFileIfChanged(eventName + ".h", generatedEvent.declare())
        replaceFileIfChanged(eventName + ".cpp", generatedEvent.define())

    mk = Makefile()
    # NOTE: it's VERY important that we output dependencies for the FooBinding
    # file here, not for the header or generated cpp file.  These dependencies
    # are used later to properly determine changedDeps and prevent rebuilding
    # too much.  See the comment explaining $(binding_dependency_trackers) in
    # Makefile.in.
    rule = mk.create_rule([outputprefix])
    rule.add_dependencies(os.path.join(srcprefix, x) for x in root.deps())
    rule.add_dependencies(iter_modules_in_path(topsrcdir))
    with open(depsname, 'w') as f:
        mk.dump(f)
Esempio n. 5
0
def generate_binding_files(config, outputprefix, srcprefix, webidlfile):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    depsname = ".deps/" + outputprefix + ".pp"
    root = CGBindingRoot(config, outputprefix, webidlfile)
    replaceFileIfChanged(outputprefix + ".h", root.declare())
    replaceFileIfChanged(outputprefix + ".cpp", root.define())

    with open(depsname, 'wb') as f:
        # Sort so that our output is stable
        f.write("\n".join(outputprefix + ": " + os.path.join(srcprefix, x) for
                          x in sorted(root.deps())))
Esempio n. 6
0
def generate_binding_files(config, outputprefix, srcprefix, webidlfile):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    depsname = ".deps/" + outputprefix + ".pp"
    root = CGBindingRoot(config, outputprefix, webidlfile)
    replaceFileIfChanged(outputprefix + ".h", root.declare())
    replaceFileIfChanged(outputprefix + ".cpp", root.define())

    with open(depsname, 'wb') as f:
        # Sort so that our output is stable
        f.write("\n".join(outputprefix + ": " + os.path.join(srcprefix, x)
                          for x in sorted(root.deps())))
def generate_binding_files(config, outputprefix, srcprefix, webidlfile):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    depsname = ".deps/" + outputprefix + ".pp"
    root = CGBindingRoot(config, outputprefix, webidlfile)
    replaceFileIfChanged(outputprefix + ".h", root.declare())
    replaceFileIfChanged(outputprefix + ".cpp", root.define())

    mk = Makefile()
    rule = mk.create_rule([outputprefix + '.h', outputprefix + '.cpp'])
    rule.add_dependencies(os.path.join(srcprefix, x) for x in root.deps())
    rule.add_dependencies(iter_modules_in_path(topsrcdir))
    with open(depsname, 'w') as f:
        mk.dump(f)
Esempio n. 8
0
def generate_binding_files(config, outputprefix, srcprefix, webidlfile):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    depsname = ".deps/" + outputprefix + ".pp"
    root = CGBindingRoot(config, outputprefix, webidlfile)
    replaceFileIfChanged(outputprefix + ".h", root.declare())
    replaceFileIfChanged(outputprefix + ".cpp", root.define())

    mk = Makefile()
    rule = mk.create_rule([outputprefix + ".h", outputprefix + ".cpp"])
    rule.add_dependencies(os.path.join(srcprefix, x) for x in root.deps())
    rule.add_dependencies(iter_modules_in_path(topsrcdir))
    with open(depsname, "w") as f:
        mk.dump(f)
Esempio n. 9
0
def generate_binding_header(config, outputprefix, webidlfile):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    filename = outputprefix + ".h"
    root = CGBindingRoot(config, outputprefix, webidlfile)
    if replaceFileIfChanged(filename, root.declare()):
        print "Generating binding header: %s" % (filename)
Esempio n. 10
0
def generate_binding_cpp(config, outputprefix, webidlfile):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    filename = outputprefix + ".cpp"
    root = CGBindingRoot(config, outputprefix, webidlfile)
    if replaceFileIfChanged(filename, root.define()):
        print "Generating binding implementation: %s" % (filename)
Esempio n. 11
0
def generate_file(config, name, action):

    root = getattr(GlobalGenRoots, name)(config)
    if action is 'declare':
        filename = name + '.h'
        code = root.declare()
    else:
        assert action is 'define'
        filename = name + '.cpp'
        code = root.define()

    if replaceFileIfChanged(filename, code):
        print "Generating %s" % (filename)
    else:
        print "%s hasn't changed - not touching it" % (filename)
Esempio n. 12
0
def generate_file(config, name, action):

    root = getattr(GlobalGenRoots, name)(config)
    if action is 'declare':
        filename = name + '.h'
        code = root.declare()
    else:
        assert action is 'define'
        filename = name + '.cpp'
        code = root.define()

    if replaceFileIfChanged(filename, code):
        print "Generating %s" % (filename)
    else:
        print "%s hasn't changed - not touching it" % (filename)