Skip to content

Commit a7d7bbb

Browse files
author
bors-servo
authored
Auto merge of #3 - servo:silent-noop, r=jdm
Make the 'egl' cargo feature do nothing instead a build error on non-Windows
2 parents d474ab0 + 0f01f68 commit a7d7bbb

File tree

6 files changed

+16
-26
lines changed

6 files changed

+16
-26
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ before_install:
1717

1818
script:
1919
- cargo test --verbose
20+
- cargo test --verbose --features egl # Doesn’t do anything, but should still build
2021

2122
notifications:
2223
webhooks: http://build.servo.org:54856/travis

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mozangle"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
authors = ["The ANGLE Project Authors", "The Servo Project Developers"]
55
license = " BSD-3-Clause"
66
description = "Mozilla’s fork of Google ANGLE, repackaged as a Rust crate "
@@ -15,4 +15,4 @@ cc = { version = "1.0.5", features = ["parallel"] }
1515
gl_generator = { version = "0.9.0", optional = true }
1616

1717
[features]
18-
egl = ["gl_generator"] # Only supported on Windows
18+
egl = ["gl_generator"] # Only does anything on Windows

README.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,13 @@ Feature flags
3030
-------------
3131

3232
By default, this crate only compiles the shader translator.
33-
This should be cross-platform, and can be used with:
3433

35-
```toml
36-
[dependencies]
37-
mozangle = "0.1"
38-
```
39-
40-
The `egl` Cargo feature enables the EGL and OpenGL ES implementations.
41-
This is only supported on Windows, since the Direct3D 11 rendering backend is configured.
34+
In Windows, the `egl` Cargo feature enables the EGL and OpenGL ES implementations.
35+
Although upstream ANGLE supports more platforms,
36+
this crate only configures the Direct3D 11 rendering backend.
4237

4338
```toml
44-
[target.'cfg(windows)'.dependencies]
39+
[dependencies]
4540
mozangle = { version = "0.1", features = ["egl"] }
4641
```
4742

build.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,8 @@ fn main() {
1212
}
1313

1414
fn build_angle() {
15-
let egl = env::var("CARGO_FEATURE_EGL").is_ok();
1615
let target = env::var("TARGET").unwrap();
17-
if egl && !target.contains("windows") {
18-
println!("");
19-
println!("The `egl` feature is only supported on Windows.");
20-
println!("");
21-
println!("Consider specifying your dependency like this:");
22-
println!("");
23-
println!("[target.'cfg(windows)'.dependencies]");
24-
println!("mozangle = {{ version = \"0.1\" , features = [\"egl\"] }}");
25-
println!("");
26-
std::process::exit(1)
27-
}
16+
let egl = env::var("CARGO_FEATURE_EGL").is_ok() && target.contains("windows");
2817

2918
let data = if egl { build_data::EGL } else { build_data::TRANSLATOR };
3019

@@ -88,6 +77,11 @@ fn generate_bindings() {
8877
use gl_generator::{Registry, Api, Profile, Fallbacks};
8978
use std::fs::File;
9079

80+
let target = env::var("TARGET").unwrap();
81+
if !target.contains("windows") {
82+
return
83+
}
84+
9185
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
9286

9387
let mut file = File::create(&out_dir.join("egl_bindings.rs")).unwrap();

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
pub mod shaders;
44
#[cfg(test)] mod tests;
55

6-
#[cfg(feature = "egl")]
6+
#[cfg(all(windows, feature = "egl"))]
77
pub mod gles {
88
pub mod ffi {
99
include!(concat!(env!("OUT_DIR"), "/gles_bindings.rs"));
1010
}
1111
}
1212

13-
#[cfg(feature = "egl")]
13+
#[cfg(all(windows, feature = "egl"))]
1414
pub mod egl {
1515
use std::ffi::CString;
1616
use std::os::raw::c_void;

src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn test_linkage() {
1313
init();
1414
}
1515

16-
#[cfg(feature = "egl")]
16+
#[cfg(all(windows, feature = "egl"))]
1717
#[test]
1818
fn test_egl_linkage() {
1919
use egl::ffi;

0 commit comments

Comments
 (0)