示例#1
0
def get_properties(preprocessorHeader):
    cpp = shellutil.split(buildconfig.substs['CPP'])
    cpp += shellutil.split(buildconfig.substs['ACDEFINES'])
    cpp.append(preprocessorHeader)
    preprocessed = subprocess.check_output(cpp)
    properties = [{"name":p[0], "prop":p[1], "id":p[2],
                   "flags":p[3], "pref":p[4], "proptype":p[5]}
                  for (i, p) in enumerate(eval(preprocessed))]

    # Sort the list so that longhand and logical properties are intermingled
    # first, shorthand properties follow, then aliases appear last.  This matches
    # the order of the nsCSSProperty enum.

    def property_compare(x, y):
        property_order = {"longhand": 0, "logical": 0, "shorthand": 1, "alias": 2}
        return property_order[x["proptype"]] - property_order[y["proptype"]]

    properties = sorted(properties, cmp=property_compare)

    for i, p in enumerate(properties):
        p["index"] = i

    # Record each property's IDL name.
    for p in properties:
        if "CSS_PROPERTY_INTERNAL" in p["flags"]:
            p["idlname"] = None
        else:
            idl_name = p["prop"]
            if not idl_name.startswith("Moz"):
                idl_name = idl_name[0].lower() + idl_name[1:]
            p["idlname"] = idl_name

    return properties
示例#2
0
    def get_preferences(self):
        """Get all of the preferences associated with enabling and disabling a property."""
        # Build the command to run the preprocessor on PythonCSSProps.h
        headerPath = resolve_path(self.topsrcdir, 'layout/style/PythonCSSProps.h')

        cpp = self.substs['CPP']

        if not cpp:
            print("Unable to find the cpp program. Please do a full, nonartifact")
            print("build and try this again.")
            sys.exit(1)

        if type(cpp) is list:
            cmd = cpp
        else:
            cmd = shellutil.split(cpp)
        cmd += shellutil.split(self.substs['ACDEFINES'])
        cmd.append(headerPath)

        # The preprocessed list takes the following form:
        # [ (name, prop, id, flags, pref, proptype), ... ]
        preprocessed = eval(subprocess.check_output(cmd))

        # Map this list
        # (name, prop, id, flags, pref, proptype) => (name, pref)
        preferences = [
            (name, pref)
            for name, prop, id, flags, pref, proptype in preprocessed
            if 'CSS_PROPERTY_INTERNAL' not in flags and pref]

        return preferences
示例#3
0
def generate(output, idlFilename, preprocessorHeader):
    cpp = shellutil.split(buildconfig.substs['CPP'])
    cpp += shellutil.split(buildconfig.substs['ACDEFINES'])
    cpp.append(preprocessorHeader)
    preprocessed = subprocess.check_output(cpp)

    propList = eval(preprocessed)
    props = ""
    for [name, prop, id, flags, pref, proptype] in propList:
        if "CSS_PROPERTY_INTERNAL" in flags:
            continue
        # Unfortunately, even some of the getters here are fallible
        # (e.g. on nsComputedDOMStyle).
        extendedAttrs = ["Throws", "TreatNullAs=EmptyString"]
        if pref is not "":
            extendedAttrs.append('Pref="%s"' % pref)

        # webkit properties get a capitalized "WebkitFoo" accessor (added here)
        # as well as a camelcase "webkitFoo" accessor (added next).
        if (prop.startswith("Webkit")):
            props += generateLine(prop, extendedAttrs)

        # Generate a line with camelCase spelling of property-name (or capitalized,
        # for Moz-prefixed properties):
        if not prop.startswith("Moz"):
            prop = prop[0].lower() + prop[1:]
        props += generateLine(prop, extendedAttrs)

        # Per spec, what's actually supposed to happen here is that we're supposed
        # to have properties for:
        #
        # 1) Each supported CSS property name, camelCased.
        # 2) Each supported name that contains dashes but doesn't start with a
        #    dash, without any changes to the name.
        # 3) cssFloat
        #
        # Note that "float" will cause a property called "float" to exist due to (1)
        # in that list.
        #
        # In practice, cssFloat is the only case in which "name" doesn't contain
        # "-" but also doesn't match "prop".  So the above generatePropLine() call
        # covered (3) and all of (1) except "float".  If we now output attributes
        # for all the cases where "name" doesn't match "prop" and "name" doesn't
        # start with "-", that will cover "float" and (2).
        if prop != name and name[0] != "-":
            extendedAttrs.append('BinaryName="%s"' % prop)
            # Throw in a '_' before the attribute name, because some of these
            # property names collide with IDL reserved words.
            props += generateLine("_" + name, extendedAttrs)

    idlFile = open(idlFilename, "r")
    idlTemplate = idlFile.read()
    idlFile.close()

    output.write("/* THIS IS AN AUTOGENERATED FILE.  DO NOT EDIT */\n\n" +
                 string.Template(idlTemplate).substitute({"props": props}) +
                 '\n')
def generate(output, idlFilename, preprocessorHeader):
    cpp = shellutil.split(buildconfig.substs['CPP'])
    cpp += shellutil.split(buildconfig.substs['ACDEFINES'])
    cpp.append(preprocessorHeader)
    preprocessed = subprocess.check_output(cpp)

    propList = eval(preprocessed)
    props = ""
    for [name, prop, id, flags, pref, proptype] in propList:
        if "CSS_PROPERTY_INTERNAL" in flags:
            continue
        # Unfortunately, even some of the getters here are fallible
        # (e.g. on nsComputedDOMStyle).
        extendedAttrs = ["Throws", "TreatNullAs=EmptyString"]
        if pref is not "":
            extendedAttrs.append('Pref="%s"' % pref)

        # webkit properties get a capitalized "WebkitFoo" accessor (added here)
        # as well as a camelcase "webkitFoo" accessor (added next).
        if (prop.startswith("Webkit")):
            props += generateLine(prop, extendedAttrs)

        # Generate a line with camelCase spelling of property-name (or capitalized,
        # for Moz-prefixed properties):
        if not prop.startswith("Moz"):
            prop = prop[0].lower() + prop[1:]
        props += generateLine(prop, extendedAttrs)

        # Per spec, what's actually supposed to happen here is that we're supposed
        # to have properties for:
        #
        # 1) Each supported CSS property name, camelCased.
        # 2) Each supported name that contains dashes but doesn't start with a
        #    dash, without any changes to the name.
        # 3) cssFloat
        #
        # Note that "float" will cause a property called "float" to exist due to (1)
        # in that list.
        #
        # In practice, cssFloat is the only case in which "name" doesn't contain
        # "-" but also doesn't match "prop".  So the above generatePropLine() call
        # covered (3) and all of (1) except "float".  If we now output attributes
        # for all the cases where "name" doesn't match "prop" and "name" doesn't
        # start with "-", that will cover "float" and (2).
        if prop != name and name[0] != "-":
            extendedAttrs.append('BinaryName="%s"' % prop)
            # Throw in a '_' before the attribute name, because some of these
            # property names collide with IDL reserved words.
            props += generateLine("_" + name, extendedAttrs)


    idlFile = open(idlFilename, "r")
    idlTemplate = idlFile.read()
    idlFile.close()

    output.write("/* THIS IS AN AUTOGENERATED FILE.  DO NOT EDIT */\n\n" +
                 string.Template(idlTemplate).substitute({"props": props}) + '\n')
示例#5
0
def get_flags(topobjdir, make_dir, build_vars, name):
    flags = ['-isystem', '-I', '-include', '-MF']
    new_args = []
    path = os.path.join(topobjdir, make_dir)

    # Take case to handle things such as the following correctly:
    #   * -DMOZ_APP_VERSION='"40.0a1"'
    #   * -DR_PLATFORM_INT_TYPES='<stdint.h>'
    #   * -DAPP_ID='{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
    #   * -D__UNUSED__='__attribute__((unused))'
    args = shellutil.split(build_vars[name])

    for arg in list(args):
        if new_args and new_args[-1] in flags:
            arg = os.path.normpath(os.path.join(path, arg))
        else:
            flag = [(f, arg[len(f):]) for f in flags + ['--sysroot=']
                    if arg.startswith(f)]
            if flag:
                flag, val = flag[0]
                if val:
                    arg = flag + os.path.normpath(os.path.join(path, val))
        new_args.append(arg)

    return new_args
示例#6
0
    def run(self, binary, params, debug, debugger, debugger_args):
        try:
            binpath = self.get_binary_path("geckodriver")
        except Exception as e:
            print(
                "It looks like geckodriver isn't built. "
                "Add ac_add_options --enable-geckodrver to your mozconfig ",
                "and run |mach build| to build it.")
            print(e)
            return 1

        args = [binpath]

        if params:
            args.extend(params)

        if binary is None:
            binary = self.get_binary_path("app")

        args.extend(["--binary", binary])

        if debug or debugger or debugger_args:
            if "INSIDE_EMACS" in os.environ:
                self.log_manager.terminal_handler.setLevel(logging.WARNING)

            import mozdebug
            if not debugger:
                # No debugger name was provided. Look for the default ones on
                # current OS.
                debugger = mozdebug.get_default_debugger_name(
                    mozdebug.DebuggerSearch.KeepLooking)

            if debugger:
                self.debuggerInfo = mozdebug.get_debugger_info(
                    debugger, debugger_args)
                if not self.debuggerInfo:
                    print("Could not find a suitable debugger in your PATH.")
                    return 1

            # Parameters come from the CLI. We need to convert them before
            # their use.
            if debugger_args:
                from mozbuild import shellutil
                try:
                    debugger_args = shellutil.split(debugger_args)
                except shellutil.MetaCharacterException as e:
                    print(
                        "The --debugger-args you passed require a real shell to parse them."
                    )
                    print("(We can't handle the %r character.)" % e.char)
                    return 1

            # Prepend the debugger args.
            args = [self.debuggerInfo.path] + self.debuggerInfo.args + args

        return self.run_process(args=args,
                                ensure_exit_code=False,
                                pass_thru=True)
示例#7
0
    def run(self, binary, params, debug, debugger, debugger_args):
        try:
            binpath = self.get_binary_path("geckodriver")
        except Exception as e:
                print("It looks like geckodriver isn't built. "
                      "Add ac_add_options --enable-geckodrver to your mozconfig ",
                      "and run |mach build| to build it.")
                print(e)
                return 1

        args = [binpath]

        if params:
            args.extend(params)

        if binary is None:
            binary = self.get_binary_path("app")

        args.extend(["--binary", binary])

        if debug or debugger or debugger_args:
            if "INSIDE_EMACS" in os.environ:
                self.log_manager.terminal_handler.setLevel(logging.WARNING)

            import mozdebug
            if not debugger:
                # No debugger name was provided. Look for the default ones on
                # current OS.
                debugger = mozdebug.get_default_debugger_name(mozdebug.DebuggerSearch.KeepLooking)

            if debugger:
                self.debuggerInfo = mozdebug.get_debugger_info(debugger, debugger_args)
                if not self.debuggerInfo:
                    print("Could not find a suitable debugger in your PATH.")
                    return 1

            # Parameters come from the CLI. We need to convert them before
            # their use.
            if debugger_args:
                from mozbuild import shellutil
                try:
                    debugger_args = shellutil.split(debugger_args)
                except shellutil.MetaCharacterException as e:
                    print("The --debugger-args you passed require a real shell to parse them.")
                    print("(We can't handle the %r character.)" % e.char)
                    return 1

            # Prepend the debugger args.
            args = [self.debuggerInfo.path] + self.debuggerInfo.args + args

        return self.run_process(args=args, ensure_exit_code=False,
            pass_thru=True)
示例#8
0
文件: base.py 项目: layely/gecko-dev
 def extra_environment_variables(self):
     '''Some extra environment variables are stored in .mozconfig.mk.
     This functions extracts and returns them.'''
     from mozbuild import shellutil
     mozconfig_mk = os.path.join(self.topobjdir, '.mozconfig.mk')
     env = {}
     with open(mozconfig_mk) as fh:
         for line in fh:
             if line.startswith('export '):
                 exports = shellutil.split(line)[1:]
                 for e in exports:
                     if '=' in e:
                         key, value = e.split('=')
                         env[key] = value
     return env
示例#9
0
 def extra_environment_variables(self):
     '''Some extra environment variables are stored in .mozconfig.mk.
     This functions extracts and returns them.'''
     from mozbuild import shellutil
     mozconfig_mk = os.path.join(self.topobjdir, '.mozconfig.mk')
     env = {}
     with open(mozconfig_mk) as fh:
         for line in fh:
             if line.startswith('export '):
                 exports = shellutil.split(line)[1:]
                 for e in exports:
                     if '=' in e:
                         key, value = e.split('=')
                         env[key] = value
     return env
$NetBSD: patch-mozilla_layout_style_GenerateCSSPropsGenerated.py,v 1.1 2017/08/18 23:55:07 ryoon Exp $

--- mozilla/layout/style/GenerateCSSPropsGenerated.py.orig	2017-07-07 05:28:56.000000000 +0000
+++ mozilla/layout/style/GenerateCSSPropsGenerated.py
@@ -10,7 +10,7 @@ import buildconfig
 from mozbuild import shellutil
 
 def get_properties(preprocessorHeader):
-    cpp = list(buildconfig.substs['CPP'])
+    cpp = shellutil.split(buildconfig.substs['CPP'])
     cpp += shellutil.split(buildconfig.substs['ACDEFINES'])
     cpp.append(preprocessorHeader)
     preprocessed = subprocess.check_output(cpp)