Files
tubestation/third_party/rust/arrayvec-0.4.11/build.rs
Dzmitry Malyshau 3d97c29cf1 Bug 1575008 - WebGPU implementation basis r=webidl,baku
This change vendors `wgpu` library in-tree and hooks up the initialization bits. It implements adapter and device initialization and adds a simple test.

Current status:
  - [x] Architecture
    - [x] figure out the IPC story
    - [ ] move wgpu crates into a dedicated folder (let's follow up with this)
  - [x] Review
    - [x] WebIDL changes by DOM peers
  - [x] Linux
    - [x] avoid depending on spirv_cross - https://github.com/gfx-rs/wgpu/pull/371
  - [x] macOS
    - [x] due to cross-compiling shaders - https://github.com/gfx-rs/gfx/pull/3047
    - [x] need the dependency update
    - [x] stop using gcc - https://github.com/SSheldon/rust-objc-exception/pull/5
    - [x] unexpected SSL header collision - https://phabricator.services.mozilla.com/D51148
    - [x] undefined Metal symbols
    - [x] missing webrtc headers for IPDL magic - https://phabricator.services.mozilla.com/D51558
  - [x] Windows
    - [x] due to "ipc-channel" not supporting Windows yet - https://github.com/servo/ipc-channel/pull/233~~
    - [x] due to some exceptional stuff - https://github.com/grovesNL/spirv_cross/issues/121
    - [x] undefined symbol: `D3D12CreateDevice`
    - [x] d3d12.dll is not found, dxgi1_4 doesn't present
    - [x] d3d11.dll and dxgi.dll need to be explicitly loaded on win32 mingw - https://github.com/gfx-rs/gfx/pull/3076
    - [x] libbacktrace fails to link on win32 mingw
    - [x] cc mislinking C++ standard library - https://github.com/alexcrichton/cc-rs/pull/455
  - [x] Android
    - [x] spirv-cross fails to build - https://github.com/KhronosGroup/SPIRV-Cross/pull/1193

Update-1:
We decided to go with IPDL mechanism instead of Rust based ipc-channel (or any alternatives), which unblocks Windows build.

Update-2:
It appears that WebGPUThreading isn't needed any more as the child thread (and its event loop) is now managed by IPDL infrastructure. This PR removes it 🎉 .

Update-3:
InstanceProvider is also removed.

Update-4:
All set, the try is green, waiting for dependent changes to go in.

Differential Revision: https://phabricator.services.mozilla.com/D49458
2019-11-05 19:51:15 +00:00

91 lines
2.3 KiB
Rust

use std::env;
use std::io::Write;
use std::process::{Command, Stdio};
fn main() {
// we need to output *some* file to opt out of the default
println!("cargo:rerun-if-changed=build.rs");
detect_maybe_uninit();
}
fn detect_maybe_uninit() {
let has_stable_maybe_uninit = probe(&stable_maybe_uninit());
if has_stable_maybe_uninit {
println!("cargo:rustc-cfg=has_stable_maybe_uninit");
return;
}
let has_unstable_union_with_md = probe(&maybe_uninit_code(true));
if has_unstable_union_with_md {
println!("cargo:rustc-cfg=has_manually_drop_in_union");
println!("cargo:rustc-cfg=has_union_feature");
}
}
// To guard against changes in this currently unstable feature, use
// a detection tests instead of a Rustc version and/or date test.
fn stable_maybe_uninit() -> String {
let code = "
#![allow(warnings)]
use std::mem::MaybeUninit;
fn main() { }
";
code.to_string()
}
// To guard against changes in this currently unstable feature, use
// a detection tests instead of a Rustc version and/or date test.
fn maybe_uninit_code(use_feature: bool) -> String {
let feature = if use_feature { "#![feature(untagged_unions)]" } else { "" };
let code = "
#![allow(warnings)]
use std::mem::ManuallyDrop;
#[derive(Copy)]
pub union MaybeUninit<T> {
empty: (),
value: ManuallyDrop<T>,
}
impl<T> Clone for MaybeUninit<T> where T: Copy
{
fn clone(&self) -> Self { *self }
}
fn main() {
let value1 = MaybeUninit::<[i32; 3]> { empty: () };
let value2 = MaybeUninit { value: ManuallyDrop::new([1, 2, 3]) };
}
";
[feature, code].concat()
}
/// Test if a code snippet can be compiled
fn probe(code: &str) -> bool {
let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
let out_dir = env::var_os("OUT_DIR").expect("environment variable OUT_DIR");
let mut child = Command::new(rustc)
.arg("--out-dir")
.arg(out_dir)
.arg("--emit=obj")
.arg("-")
.stdin(Stdio::piped())
.spawn()
.expect("rustc probe");
child
.stdin
.as_mut()
.expect("rustc stdin")
.write_all(code.as_bytes())
.expect("write rustc stdin");
child.wait().expect("rustc probe").success()
}