stylo: Allow regenerating atoms as part of the normal generation of bindings.

This configures the regeneration of atoms as part of the normal generation of
bindings, so it stops being a whole different process.

This also adds a generated file to components/style/generated with a convenience
macro invocation for pseudo-elements, which comes handy in order to avoid
duplication.
This commit is contained in:
Emilio Cobos Álvarez 2016-08-09 21:30:17 -07:00
parent 54b92015cb
commit 12fcb7a2e7
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 226 additions and 79 deletions

View file

@ -13,6 +13,8 @@ import copy
import subprocess
import tempfile
import regen_atoms
DESCRIPTION = 'Regenerate the rust version of the structs or the bindings file.'
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
COMMON_BUILD_KEY = "__common__"
@ -38,6 +40,7 @@ COMPILATION_TARGETS = {
},
# Generation of style structs.
"structs": {
"target_dir": "../gecko_bindings",
"test": True,
"flags": [
"-ignore-functions",
@ -108,6 +111,7 @@ COMPILATION_TARGETS = {
},
# Generation of the ffi bindings.
"bindings": {
"target_dir": "../gecko_bindings",
"raw_lines": [
"use heapsize::HeapSizeOf;",
],
@ -140,6 +144,10 @@ COMPILATION_TARGETS = {
"void_types": [
"nsINode", "nsIDocument", "nsIPrincipal", "nsIURI",
],
},
"atoms": {
"custom_build": regen_atoms.build,
}
}
@ -212,6 +220,17 @@ def build(objdir, target_name, kind_name=None,
assert ((kind_name is None and "build_kinds" not in current_target) or
(kind_name in current_target["build_kinds"]))
if "custom_build" in current_target:
print("[CUSTOM] {}::{} in \"{}\"... ".format(target_name, kind_name, objdir), end='')
sys.stdout.flush()
ret = current_target["custom_build"](objdir, verbose=True)
if ret != 0:
print("FAIL")
else:
print("OK")
return ret
if bindgen is None:
bindgen = os.path.join(TOOLS_DIR, "rust-bindgen")
@ -221,18 +240,23 @@ def build(objdir, target_name, kind_name=None,
else:
bindgen = [bindgen]
if output_filename is None:
filename = "{}.rs".format(target_name)
if kind_name is not None:
filename = "{}_{}.rs".format(target_name, kind_name)
output_filename = "{}/../{}".format(TOOLS_DIR, filename)
if kind_name is not None:
current_target = copy.deepcopy(current_target)
extend_object(current_target, current_target["build_kinds"][kind_name])
target_dir = None
if output_filename is None and "target_dir" in current_target:
target_dir = current_target["target_dir"]
if output_filename is None:
output_filename = "{}.rs".format(target_name)
if kind_name is not None:
output_filename = "{}_{}.rs".format(target_name, kind_name)
if target_dir:
output_filename = "{}/{}".format(target_dir, output_filename)
print("[BINDGEN] {}::{} in \"{}\"... ".format(target_name, kind_name, objdir), end='')
sys.stdout.flush()