Skip to content

Commit

Permalink
Update atoms when build geckolib with gecko
Browse files Browse the repository at this point in the history
  • Loading branch information
upsuper committed Dec 16, 2016
1 parent 6c952e1 commit 3633384
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
25 changes: 15 additions & 10 deletions components/style/binding_tools/regen_atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ def msvc32_symbolify(source, ident):

class GkAtomSource:
PATTERN = re.compile('^GK_ATOM\((?P<ident>.+),\s*"(?P<value>.*)"\)', re.M)
FILE = "dist/include/nsGkAtomList.h"
FILE = "include/nsGkAtomList.h"
CLASS = "nsGkAtoms"
TYPE = "nsIAtom"


class CSSPseudoElementsAtomSource:
PATTERN = re.compile('^CSS_PSEUDO_ELEMENT\((?P<ident>.+),\s*"(?P<value>.*)",', re.M)
FILE = "dist/include/nsCSSPseudoElementList.h"
FILE = "include/nsCSSPseudoElementList.h"
CLASS = "nsCSSPseudoElements"
# NB: nsICSSPseudoElement is effectively the same as a nsIAtom, but we need
# this for MSVC name mangling.
Expand All @@ -50,14 +50,14 @@ class CSSPseudoElementsAtomSource:

class CSSAnonBoxesAtomSource:
PATTERN = re.compile('^CSS_ANON_BOX\((?P<ident>.+),\s*"(?P<value>.*)"\)', re.M)
FILE = "dist/include/nsCSSAnonBoxList.h"
FILE = "include/nsCSSAnonBoxList.h"
CLASS = "nsCSSAnonBoxes"
TYPE = "nsICSSAnonBoxPseudo"


class CSSPropsAtomSource:
PATTERN = re.compile('^CSS_PROP_[A-Z]+\(\s*(?P<value>[^,]+),\s*(?P<ident>[^,]+)', re.M)
FILE = "dist/include/nsCSSPropList.h"
FILE = "include/nsCSSPropList.h"
CLASS = "nsCSSProps"
TYPE = "nsICSSProperty"

Expand Down Expand Up @@ -232,10 +232,15 @@ def write_pseudo_element_helper(atoms, target_filename):
f.write("}\n")


if len(sys.argv) != 2:
print("Usage: {} objdir".format(sys.argv[0]))
exit(2)
def generate_atoms(dist):
style_path = os.path.dirname(os.path.dirname(__file__))
atoms = collect_atoms(dist)
write_atom_macro(atoms, os.path.join(style_path, "gecko_string_cache/atom_macro.rs"))
write_pseudo_element_helper(atoms, os.path.join(style_path, "gecko/generated/gecko_pseudo_element_helper.rs"))

atoms = collect_atoms(sys.argv[1])
write_atom_macro(atoms, "../gecko_string_cache/atom_macro.rs")
write_pseudo_element_helper(atoms, "../gecko/generated/gecko_pseudo_element_helper.rs")

if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: {} objdir".format(sys.argv[0]))
exit(2)
generate_atoms(os.path.join(sys.argv[1], "dist"))
8 changes: 8 additions & 0 deletions python/servo/build_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,14 @@ def build_geckolib(self, with_gecko=None, jobs=None, verbose=False, release=Fals
if release:
opts += ["--release"]

if with_gecko is not None:
print("Generating atoms data...")
run_file = path.join(self.context.topdir, "components",
"style", "binding_tools", "regen_atoms.py")
run_globals = {"__file__": run_file}
execfile(run_file, run_globals)
run_globals["generate_atoms"](env["MOZ_DIST"])

build_start = time()
with cd(path.join("ports", "geckolib")):
ret = call(["cargo", "build"] + opts, env=env, verbose=verbose)
Expand Down

0 comments on commit 3633384

Please sign in to comment.