mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Generate code into OUT_DIR.
This is necessary to ensure Cargo knows when to rebuild. Normally .gitignore would be enough to exclude these from Cargo's freshness calculation, but https://github.com/rust-lang/cargo/issues/1729 prevents this currently. This is the new, correct way to do these thigns, just like the style crate does.
This commit is contained in:
parent
e1b28d893e
commit
07d95627ca
5 changed files with 64 additions and 51 deletions
13
.gitignore
vendored
13
.gitignore
vendored
|
@ -1,19 +1,11 @@
|
||||||
|
/.servo
|
||||||
/.cargo
|
/.cargo
|
||||||
/Cargo.lock
|
/.servobuild
|
||||||
/target
|
/target
|
||||||
/components/servo/target
|
|
||||||
/ports/gonk/target
|
|
||||||
/ports/cef/target
|
|
||||||
/ports/android/bin
|
/ports/android/bin
|
||||||
/ports/android/libs
|
/ports/android/libs
|
||||||
/ports/android/local.properties
|
/ports/android/local.properties
|
||||||
/ports/android/obj
|
/ports/android/obj
|
||||||
/components/script/dom/bindings/codegen/*.rs
|
|
||||||
/components/script/dom/bindings/codegen/_cache
|
|
||||||
/components/script/dom/bindings/codegen/Bindings
|
|
||||||
/components/script/dom/bindings/codegen/test/*.rs
|
|
||||||
/.servobuild
|
|
||||||
/.servo
|
|
||||||
/tests/wpt/_virtualenv
|
/tests/wpt/_virtualenv
|
||||||
*~
|
*~
|
||||||
*#
|
*#
|
||||||
|
@ -34,4 +26,3 @@ Servo.app
|
||||||
.config.mk.last
|
.config.mk.last
|
||||||
parser.out
|
parser.out
|
||||||
/glfw
|
/glfw
|
||||||
|
|
||||||
|
|
|
@ -1429,25 +1429,26 @@ class CGImports(CGWrapper):
|
||||||
"""
|
"""
|
||||||
Generates the appropriate import/use statements.
|
Generates the appropriate import/use statements.
|
||||||
"""
|
"""
|
||||||
def __init__(self, child, descriptors, callbacks, imports):
|
def __init__(self, child, descriptors, callbacks, imports, ignored_warnings=None):
|
||||||
"""
|
"""
|
||||||
Adds a set of imports.
|
Adds a set of imports.
|
||||||
"""
|
"""
|
||||||
ignored_warnings = [
|
if ignored_warnings is None:
|
||||||
# Allow unreachable_code because we use 'break' in a way that
|
ignored_warnings = [
|
||||||
# sometimes produces two 'break's in a row. See for example
|
# Allow unreachable_code because we use 'break' in a way that
|
||||||
# CallbackMember.getArgConversions.
|
# sometimes produces two 'break's in a row. See for example
|
||||||
'unreachable_code',
|
# CallbackMember.getArgConversions.
|
||||||
'non_camel_case_types',
|
'unreachable_code',
|
||||||
'non_upper_case_globals',
|
'non_camel_case_types',
|
||||||
'unused_parens',
|
'non_upper_case_globals',
|
||||||
'unused_imports',
|
'unused_parens',
|
||||||
'unused_variables',
|
'unused_imports',
|
||||||
'unused_unsafe',
|
'unused_variables',
|
||||||
'unused_mut',
|
'unused_unsafe',
|
||||||
'unused_assignments',
|
'unused_mut',
|
||||||
'dead_code',
|
'unused_assignments',
|
||||||
]
|
'dead_code',
|
||||||
|
]
|
||||||
|
|
||||||
def componentTypes(type):
|
def componentTypes(type):
|
||||||
if type.nullable():
|
if type.nullable():
|
||||||
|
@ -1496,7 +1497,9 @@ class CGImports(CGWrapper):
|
||||||
|
|
||||||
imports += ['dom::types::%s' % getIdentifier(t).name for t in types if isImportable(t)]
|
imports += ['dom::types::%s' % getIdentifier(t).name for t in types if isImportable(t)]
|
||||||
|
|
||||||
statements = ['#![allow(%s)]' % ','.join(ignored_warnings)]
|
statements = []
|
||||||
|
if len(ignored_warnings) > 0:
|
||||||
|
statements.append('#![allow(%s)]' % ','.join(ignored_warnings))
|
||||||
statements.extend('use %s;' % i for i in sorted(set(imports)))
|
statements.extend('use %s;' % i for i in sorted(set(imports)))
|
||||||
|
|
||||||
CGWrapper.__init__(self, child,
|
CGWrapper.__init__(self, child,
|
||||||
|
@ -1815,7 +1818,7 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
|
||||||
CGUnionConversionStruct(t, provider)
|
CGUnionConversionStruct(t, provider)
|
||||||
])
|
])
|
||||||
|
|
||||||
return CGImports(CGList(SortedDictValues(unionStructs), "\n\n"), [], [], imports)
|
return CGImports(CGList(SortedDictValues(unionStructs), "\n\n"), [], [], imports, ignored_warnings=[])
|
||||||
|
|
||||||
|
|
||||||
class Argument():
|
class Argument():
|
||||||
|
@ -5415,7 +5418,7 @@ class GlobalGenRoots():
|
||||||
'js::jsapi::JSContext',
|
'js::jsapi::JSContext',
|
||||||
'js::jsapi::JSObject',
|
'js::jsapi::JSObject',
|
||||||
'libc',
|
'libc',
|
||||||
])
|
], ignored_warnings=[])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def InterfaceTypes(config):
|
def InterfaceTypes(config):
|
||||||
|
@ -5438,8 +5441,7 @@ class GlobalGenRoots():
|
||||||
def InheritTypes(config):
|
def InheritTypes(config):
|
||||||
|
|
||||||
descriptors = config.getDescriptors(register=True, isCallback=False)
|
descriptors = config.getDescriptors(register=True, isCallback=False)
|
||||||
allprotos = [CGGeneric("#![allow(unused_imports)]\n"),
|
allprotos = [CGGeneric("use dom::types::*;\n"),
|
||||||
CGGeneric("use dom::types::*;\n"),
|
|
||||||
CGGeneric("use dom::bindings::js::{JS, JSRef, LayoutJS, Rootable, Temporary};\n"),
|
CGGeneric("use dom::bindings::js::{JS, JSRef, LayoutJS, Rootable, Temporary};\n"),
|
||||||
CGGeneric("use dom::bindings::trace::JSTraceable;\n"),
|
CGGeneric("use dom::bindings::trace::JSTraceable;\n"),
|
||||||
CGGeneric("use dom::bindings::utils::Reflectable;\n"),
|
CGGeneric("use dom::bindings::utils::Reflectable;\n"),
|
||||||
|
|
|
@ -155,11 +155,30 @@ pub mod codegen {
|
||||||
// FIXME(#5853) we shouldn't need to
|
// FIXME(#5853) we shouldn't need to
|
||||||
// allow moved_no_move here
|
// allow moved_no_move here
|
||||||
#[allow(unrooted_must_root, moved_no_move)]
|
#[allow(unrooted_must_root, moved_no_move)]
|
||||||
pub mod Bindings;
|
pub mod Bindings {
|
||||||
pub mod InterfaceTypes;
|
include!(concat!(env!("OUT_DIR"), "/Bindings/mod.rs"));
|
||||||
pub mod InheritTypes;
|
}
|
||||||
pub mod PrototypeList;
|
pub mod InterfaceTypes {
|
||||||
pub mod RegisterBindings;
|
include!(concat!(env!("OUT_DIR"), "/InterfaceTypes.rs"));
|
||||||
pub mod UnionTypes;
|
}
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
pub mod InheritTypes {
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/InheritTypes.rs"));
|
||||||
|
}
|
||||||
|
pub mod PrototypeList {
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/PrototypeList.rs"));
|
||||||
|
}
|
||||||
|
#[allow(unreachable_code, non_camel_case_types, non_upper_case_globals, unused_parens,
|
||||||
|
unused_imports, unused_variables, unused_unsafe, unused_mut, unused_assignments,
|
||||||
|
dead_code)]
|
||||||
|
pub mod RegisterBindings {
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/RegisterBindings.rs"));
|
||||||
|
}
|
||||||
|
#[allow(unreachable_code, non_camel_case_types, non_upper_case_globals, unused_parens,
|
||||||
|
unused_imports, unused_variables, unused_unsafe, unused_mut, unused_assignments,
|
||||||
|
dead_code)]
|
||||||
|
pub mod UnionTypes {
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/UnionTypes.rs"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,8 +190,9 @@ pub mod macros;
|
||||||
|
|
||||||
pub mod bindings;
|
pub mod bindings;
|
||||||
|
|
||||||
#[path="bindings/codegen/InterfaceTypes.rs"]
|
pub mod types {
|
||||||
pub mod types;
|
include!(concat!(env!("OUT_DIR"), "/InterfaceTypes.rs"));
|
||||||
|
}
|
||||||
|
|
||||||
pub mod activation;
|
pub mod activation;
|
||||||
pub mod attr;
|
pub mod attr;
|
||||||
|
|
|
@ -8,38 +8,38 @@ BINDINGS_SRC = $(shell pwd)/dom/bindings/codegen
|
||||||
WEBIDLS_SRC = $(shell pwd)/dom/webidls
|
WEBIDLS_SRC = $(shell pwd)/dom/webidls
|
||||||
WEBIDLS = $(call rwildcard,$(WEBIDLS_SRC),*.webidl)
|
WEBIDLS = $(call rwildcard,$(WEBIDLS_SRC),*.webidl)
|
||||||
BINDINGS = $(patsubst %.webidl,%Binding.rs,$(WEBIDLS))
|
BINDINGS = $(patsubst %.webidl,%Binding.rs,$(WEBIDLS))
|
||||||
AUTOGEN_SRC = $(foreach var,$(BINDINGS),$(subst $(WEBIDLS_SRC),$(BINDINGS_SRC)/Bindings,$(var)))
|
AUTOGEN_SRC = $(foreach var,$(BINDINGS),$(subst $(WEBIDLS_SRC),$(OUT_DIR)/Bindings,$(var)))
|
||||||
|
|
||||||
CACHE_DIR = $(BINDINGS_SRC)/_cache
|
CACHE_DIR = $(OUT_DIR)/_cache
|
||||||
|
|
||||||
bindinggen_dependencies := $(addprefix $(BINDINGS_SRC)/,BindingGen.py Bindings.conf Configuration.py CodegenRust.py parser/WebIDL.py ParserResults.pkl Bindings/.done)
|
bindinggen_dependencies := $(addprefix $(BINDINGS_SRC)/,BindingGen.py Bindings.conf Configuration.py CodegenRust.py parser/WebIDL.py) $(OUT_DIR)/ParserResults.pkl $(OUT_DIR)/Bindings/.done
|
||||||
|
|
||||||
globalgen_dependencies := $(addprefix $(BINDINGS_SRC)/,GlobalGen.py Bindings.conf Configuration.py CodegenRust.py parser/WebIDL.py) $(CACHE_DIR)/.done $(BINDINGS_SRC)/Bindings/.done
|
globalgen_dependencies := $(addprefix $(BINDINGS_SRC)/,GlobalGen.py Bindings.conf Configuration.py CodegenRust.py parser/WebIDL.py) $(CACHE_DIR)/.done $(OUT_DIR)/Bindings/.done
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(AUTOGEN_SRC)
|
all: $(AUTOGEN_SRC)
|
||||||
|
|
||||||
$(BINDINGS_SRC)/Bindings/.done:
|
$(OUT_DIR)/Bindings/.done:
|
||||||
mkdir -p $(BINDINGS_SRC)/Bindings
|
mkdir -p $(OUT_DIR)/Bindings
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
$(CACHE_DIR)/.done:
|
$(CACHE_DIR)/.done:
|
||||||
mkdir -p $(CACHE_DIR)
|
mkdir -p $(CACHE_DIR)
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
$(BINDINGS_SRC)/ParserResults.pkl: $(globalgen_dependencies) $(WEBIDLS)
|
$(OUT_DIR)/ParserResults.pkl: $(globalgen_dependencies) $(WEBIDLS)
|
||||||
$(PYTHON) $(BINDINGS_SRC)/pythonpath.py \
|
$(PYTHON) $(BINDINGS_SRC)/pythonpath.py \
|
||||||
-I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \
|
-I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \
|
||||||
-D$(BINDINGS_SRC) \
|
-D$(OUT_DIR) \
|
||||||
$(BINDINGS_SRC)/GlobalGen.py $(BINDINGS_SRC)/Bindings.conf . \
|
$(BINDINGS_SRC)/GlobalGen.py $(BINDINGS_SRC)/Bindings.conf . \
|
||||||
--cachedir=$(CACHE_DIR) \
|
--cachedir=$(CACHE_DIR) \
|
||||||
$(WEBIDLS)
|
$(WEBIDLS)
|
||||||
|
|
||||||
$(AUTOGEN_SRC): $(BINDINGS_SRC)/Bindings/%Binding.rs: $(bindinggen_dependencies) \
|
$(AUTOGEN_SRC): $(OUT_DIR)/Bindings/%Binding.rs: $(bindinggen_dependencies) \
|
||||||
$(addprefix $(WEBIDLS_SRC)/,%.webidl)
|
$(addprefix $(WEBIDLS_SRC)/,%.webidl)
|
||||||
$(PYTHON) $(BINDINGS_SRC)/pythonpath.py \
|
$(PYTHON) $(BINDINGS_SRC)/pythonpath.py \
|
||||||
-I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \
|
-I$(BINDINGS_SRC)/parser -I$(BINDINGS_SRC)/ply \
|
||||||
-D$(BINDINGS_SRC) \
|
-D$(OUT_DIR) \
|
||||||
$(BINDINGS_SRC)/BindingGen.py \
|
$(BINDINGS_SRC)/BindingGen.py \
|
||||||
$(BINDINGS_SRC)/Bindings.conf Bindings/$*Binding $(addprefix $(WEBIDLS_SRC)/,$*.webidl)
|
$(BINDINGS_SRC)/Bindings.conf Bindings/$*Binding $(addprefix $(WEBIDLS_SRC)/,$*.webidl)
|
||||||
touch $@
|
touch $@
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue