Skip to content

Commit

Permalink
servo: Merge #19316 - Fix Stylo tests to pass on both Stable and Nigh…
Browse files Browse the repository at this point in the history
…tly Rust (from servo:stylo-size-of); r=emilio

This is on top of servo/servo#19285.

Rust Nightly has new enum memory layout optimizations: rust-lang/rust#45225

Source-Repo: https://github.com/servo/servo
Source-Revision: 17e97b9320fdb7cdb33bbc5f4d0fde0653bbf2e4

UltraBlame original commit: 6de571030d5d998dcadbd3dac602fa006395165c
  • Loading branch information
marco-c committed Oct 2, 2019
1 parent fd96606 commit 11f54f6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
10 changes: 10 additions & 0 deletions servo/components/style/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ fn generate_properties() {
.arg(&script)
.arg(product)
.arg("style-crate")
.envs(if std::mem::size_of::<Option<bool>>() == 1 {





vec![("RUSTC_HAS_PR45225", "1")]
} else {
vec![]
})
.status()
.unwrap();
if !status.success() {
Expand Down
3 changes: 2 additions & 1 deletion servo/components/style/properties/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def main():

properties = data.PropertiesData(product=product)
template = os.path.join(BASE, "properties.mako.rs")
rust = render(template, product=product, data=properties, __file__=template)
rust = render(template, product=product, data=properties, __file__=template,
RUSTC_HAS_PR45225=os.environ.get("RUSTC_HAS_PR45225"))
if output == "style-crate":
write(os.environ["OUT_DIR"], "properties.rs", rust)
if product == "gecko":
Expand Down
2 changes: 1 addition & 1 deletion servo/components/style/properties/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def casted_constant_name(self, value, cast_type):
def arg_to_bool(arg):
if isinstance(arg, bool):
return arg
assert arg in ["True", "False"]
assert arg in ["True", "False"], "Unexpected value for boolean arguement: " + repr(arg)
return arg == "True"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ${helpers.predefined_type(
"stroke-width", "SVGWidth",
"::values::computed::NonNegativeLength::new(1.).into()",
products="gecko",
boxed="True",
boxed=not RUSTC_HAS_PR45225,
animation_value_type="::values::computed::SVGWidth",
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeWidth")}

Expand Down Expand Up @@ -101,7 +101,7 @@ ${helpers.predefined_type(
"stroke-dashoffset", "SVGLength",
"Au(0).into()",
products="gecko",
boxed="True",
boxed=not RUSTC_HAS_PR45225,
animation_value_type="ComputedValue",
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing")}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ ${helpers.predefined_type(
"Either::Second(Auto)",
spec="https://drafts.csswg.org/css-ui/#caret-color",
animation_value_type="Either<AnimatedColor, Auto>",
boxed=True,
boxed=not RUSTC_HAS_PR45225,
ignored_when_colors_disabled=True,
products="gecko",
)}
5 changes: 5 additions & 0 deletions servo/tests/unit/stylo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ use std::io::{BufRead, BufReader, Write};
use std::path::Path;

fn main() {
if std::mem::size_of::<Option<bool>>() == 1 {

println!("cargo:rustc-cfg=rustc_has_pr45225")
}

let root_path = Path::new("../../../");
let bindings_file = root_path.join("components/style/gecko/generated/bindings.rs");
let glue_file = root_path.join("ports/geckolib/glue.rs");
Expand Down
6 changes: 4 additions & 2 deletions servo/tests/unit/stylo/size_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@ size_of_test!(test_size_of_specified_image, specified::image::Image, 40);



size_of_test!(test_size_of_computed_image_layer, computed::image::ImageLayer, 48);
size_of_test!(test_size_of_specified_image_layer, specified::image::ImageLayer, 48);
size_of_test!(test_size_of_computed_image_layer, computed::image::ImageLayer,
if cfg!(rustc_has_pr45225) { 40 } else { 48 });
size_of_test!(test_size_of_specified_image_layer, specified::image::ImageLayer,
if cfg!(rustc_has_pr45225) { 40 } else { 48 });

0 comments on commit 11f54f6

Please sign in to comment.