Beispiel #1
0
def main():
    usage = "Usage: %s [ servo | gecko ] [ style-crate | html ]" % sys.argv[0]
    if len(sys.argv) < 3:
        abort(usage)
    product = sys.argv[1]
    output = sys.argv[2]

    if product not in ["servo", "gecko"
                       ] or output not in ["style-crate", "geckolib", "html"]:
        abort(usage)

    properties = data.PropertiesData(product=product)
    template = os.path.join(BASE, "properties.mako.rs")
    rust = render(template,
                  product=product,
                  data=properties,
                  __file__=template)
    if output == "style-crate":
        write(os.environ["OUT_DIR"], "properties.rs", rust)
        if product == "gecko":
            template = os.path.join(BASE, "gecko.mako.rs")
            rust = render(template, data=properties)
            write(os.environ["OUT_DIR"], "gecko_properties.rs", rust)
    elif output == "html":
        write_html(properties)
Beispiel #2
0
def main():
    usage = (
        "Usage: %s [ servo | gecko ] [ style-crate | geckolib <template> | html ]"
        % sys.argv[0])
    if len(sys.argv) < 3:
        abort(usage)
    product = sys.argv[1]
    output = sys.argv[2]

    if product not in ["servo", "gecko"
                       ] or output not in ["style-crate", "geckolib", "html"]:
        abort(usage)

    properties = data.PropertiesData(product=product)
    files = {}
    for kind in ["longhands", "shorthands"]:
        files[kind] = {}
        for struct in STYLE_STRUCT_LIST:
            file_name = os.path.join(BASE, kind, "{}.mako.rs".format(struct))
            if kind == "shorthands" and not os.path.exists(file_name):
                files[kind][struct] = ""
                continue
            files[kind][struct] = render(
                file_name,
                product=product,
                data=properties,
            )
    properties_template = os.path.join(BASE, "properties.mako.rs")
    files["properties"] = render(
        properties_template,
        product=product,
        data=properties,
        __file__=properties_template,
        OUT_DIR=OUT_DIR,
    )
    if output == "style-crate":
        write(OUT_DIR, "properties.rs", files["properties"])
        for kind in ["longhands", "shorthands"]:
            for struct in files[kind]:
                write(
                    os.path.join(OUT_DIR, kind),
                    "{}.rs".format(struct),
                    files[kind][struct],
                )

        if product == "gecko":
            template = os.path.join(BASE, "gecko.mako.rs")
            rust = render(template, data=properties)
            write(OUT_DIR, "gecko_properties.rs", rust)
    elif output == "geckolib":
        if len(sys.argv) < 4:
            abort(usage)
        template = sys.argv[3]
        header = render(template, data=properties)
        sys.stdout.write(header)
    elif output == "html":
        write_html(properties)
Beispiel #3
0
def main():
    usage = (
        "Usage: %s [ servo-2013 | servo-2020 | gecko ] [ style-crate | geckolib <template> | html ]"
        % sys.argv[0])
    if len(sys.argv) < 3:
        abort(usage)
    engine = sys.argv[1]
    output = sys.argv[2]

    if engine not in ["servo-2013", "servo-2020", "gecko"] or output not in [
            "style-crate",
            "geckolib",
            "html",
    ]:
        abort(usage)

    properties = data.PropertiesData(engine=engine)
    files = {}
    for kind in ["longhands", "shorthands"]:
        files[kind] = {}
        for struct in STYLE_STRUCT_LIST:
            file_name = os.path.join(BASE, kind, "{}.mako.rs".format(struct))
            if kind == "shorthands" and not os.path.exists(file_name):
                files[kind][struct] = ""
                continue
            files[kind][struct] = render(
                file_name,
                engine=engine,
                data=properties,
            )
    properties_template = os.path.join(BASE, "properties.mako.rs")
    files["properties"] = render(
        properties_template,
        engine=engine,
        data=properties,
        __file__=properties_template,
        OUT_DIR=OUT_DIR,
    )
    if output == "style-crate":
        write(OUT_DIR, "properties.rs", files["properties"])
        for kind in ["longhands", "shorthands"]:
            for struct in files[kind]:
                write(
                    os.path.join(OUT_DIR, kind),
                    "{}.rs".format(struct),
                    files[kind][struct],
                )

        if engine == "gecko":
            template = os.path.join(BASE, "gecko.mako.rs")
            rust = render(template, data=properties)
            write(OUT_DIR, "gecko_properties.rs", rust)

        if engine in ["servo-2013", "servo-2020"]:
            if engine == "servo-2013":
                pref_attr = "servo_2013_pref"
            if engine == "servo-2020":
                pref_attr = "servo_2020_pref"
            properties_dict = {
                kind: {
                    p.name: {
                        "pref": getattr(p, pref_attr)
                    }
                    for prop in properties_list if prop.enabled_in_content()
                    for p in [prop] + prop.aliases
                }
                for kind, properties_list in [
                    ("longhands", properties.longhands),
                    ("shorthands", properties.shorthands),
                ]
            }
            as_html = render(os.path.join(BASE, "properties.html.mako"),
                             properties=properties_dict)
            as_json = json.dumps(properties_dict, indent=4, sort_keys=True)
            doc_servo = os.path.join(BASE, "..", "..", "..", "target", "doc",
                                     "servo")
            write(doc_servo, "css-properties.html", as_html)
            write(doc_servo, "css-properties.json", as_json)
            write(OUT_DIR, "css-properties.json", as_json)
    elif output == "geckolib":
        if len(sys.argv) < 4:
            abort(usage)
        template = sys.argv[3]
        header = render(template, data=properties)
        sys.stdout.write(header)