diff --git a/.travis.yml b/.travis.yml index 637c9e153ce..6eff0a73343 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,12 +60,8 @@ before_install: # Do not run bors builds against the nightly compiler. # We want to find out about nightly bugs, so they're done in master, but we don't block on them. - if [[ $TRAVIS_RUST_VERSION == "nightly" && $TRAVIS_BRANCH == "staging" ]]; then exit; fi - # Extract SDL2 .deb into a cached directory (see cache section above and LIBRARY_PATH exports below) - # Will no longer be needed when Trusty build environment goes out of beta at Travis CI - # (assuming it will have libsdl2-dev and Rust by then) - # see https://docs.travis-ci.com/user/trusty-ci-environment/ - - if [[ $TRAVIS_OS_NAME == "linux" ]]; then make travis-sdl2 && export CXX=g++-5; fi - - if [[ $TRAVIS_OS_NAME == "osx" ]]; then brew update && brew install sdl2; fi + - if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-5; fi + - if [[ $TRAVIS_OS_NAME == "osx" ]]; then brew update; fi - if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install make; fi - rustup self update - rustup target add $TARGET; true diff --git a/Makefile b/Makefile index 0a048f70b39..1db1dd0dc1c 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,9 @@ RUST_BACKTRACE:=1 EXCLUDES:= -FEATURES_EXTRA:=mint serialize FEATURES_HAL:= FEATURES_HAL2:= FEATURES_HAL3:= -SDL2_DEST=$(HOME)/deps -SDL2_CONFIG=$(SDL2_DEST)/usr/bin/sdl2-config -SDL2_PPA=http://ppa.launchpad.net/zoogie/sdl2-snapshots/ubuntu/pool/main/libs/libsdl2 - ifeq (,$(TARGET)) CHECK_TARGET_FLAG= else @@ -44,7 +39,7 @@ else endif -.PHONY: all check quad quad-wasm test doc reftests benches travis-sdl2 +.PHONY: all check quad quad-wasm test doc reftests benches shader-binaries all: check test @@ -69,6 +64,7 @@ doc: reftests: cd src/warden && cargo run --bin reftest --features "$(FEATURES_HAL) $(FEATURES_HAL2)" -- local #TODO: gl + benches: cd src/warden && cargo run --release --bin bench --features "$(FEATURES_HAL) $(FEATURES_HAL2)" -- blit @@ -82,14 +78,10 @@ quad: quad-wasm: cd examples && cargo +nightly build --target wasm32-unknown-unknown --features gl --bin quad && wasm-bindgen ../target/wasm32-unknown-unknown/debug/quad.wasm --out-dir ../examples/generated-wasm --web -travis-sdl2: - #TODO - #if [ -e $(SDL2_CONFIG) ]; then exit 1; fi - #mkdir -p $(SDL2_DEST) - #test -f $(SDL2_DEST)/dev.deb || curl -sLo $(SDL2_DEST)/dev.deb $(SDL2_PPA)/libsdl2-dev_2.0.3+z4~20140315-8621-1ppa1precise1_amd64.deb - #test -f $(SDL2_DEST)/bin.deb || curl -sLo $(SDL2_DEST)/bin.deb $(SDL2_PPA)/libsdl2_2.0.3+z4~20140315-8621-1ppa1precise1_amd64.deb - #dpkg-deb -x $(SDL2_DEST)/bin.deb . - #dpkg-deb -x $(SDL2_DEST)/dev.deb . - #sed -e s,/usr,$(SDL2_DEST),g $(SDL2_CONFIG) > $(SDL2_CONFIG).new - #mv $(SDL2_CONFIG).new $(SDL2_CONFIG) - #chmod a+x $(SDL2_CONFIG) +shader-binaries: +ifeq ($(UNAME_S),Darwin) + cd ./src/backend/metal/shaders && \ + xcrun -sdk macosx metal -c *.metal -mmacosx-version-min=10.11 && \ + xcrun -sdk macosx metallib *.air -o gfx_shaders.metallib && \ + rm *.air +endif diff --git a/src/backend/metal/build.rs b/src/backend/metal/build.rs deleted file mode 100644 index 737581bfdbc..00000000000 --- a/src/backend/metal/build.rs +++ /dev/null @@ -1,87 +0,0 @@ -// Compiles the shaders used internally by some commands - -use std::env; -use std::ffi::OsStr; -use std::fs; -use std::path::{Path, PathBuf}; -use std::process::Command; - -fn main() { - let pd = env::var("CARGO_MANIFEST_DIR").unwrap(); - let target = env::var("TARGET").unwrap(); - let os = if target.ends_with("ios") { - "ios" - } else if target.ends_with("darwin") { - "darwin" - } else { - panic!("unsupported target {}", target) - }; - let arch = &target[.. target.chars().position(|c| c == '-').unwrap()]; - - let (sdk_name, platform_args): (_, &[_]) = match (os, arch) { - ("ios", "aarch64") => ("iphoneos", &["-mios-version-min=8.0"]), - ("ios", "x86_64") => ("iphonesimulator", &["-mios-simulator-version-min=8.0"]), - ("ios", "armv7s") | ("ios", "armv7") => panic!("32-bit iOS does not have metal support"), - ("ios", "i386") => panic!("32-bit iOS simulator does not have metal support"), - ("darwin", _) => ("macosx", &["-mmacosx-version-min=10.11"]), - _ => panic!("unsupported target {}", target), - }; - - let project_dir = Path::new(&pd); - let shader_dir = project_dir.join("shaders"); - println!("cargo:rerun-if-changed={}", shader_dir.to_str().unwrap()); - - let od = env::var("OUT_DIR").unwrap(); - let out_dir = Path::new(&od); - let out_lib = out_dir.join("gfx_shaders.metallib"); - - // Find all .metal files _at the top level only_ - let shader_files = fs::read_dir(&shader_dir) - .expect("could not open shader directory") - .filter_map(|entry| { - let entry = entry.expect("error reading shader directory entry"); - let path = entry.path(); - match path.extension().and_then(OsStr::to_str) { - Some("metal") => Some(path), - _ => None, - } - }); - - // Compile all the metal files into OUT_DIR - let mut compiled_shader_files: Vec = Vec::new(); - for shader_path in shader_files.into_iter() { - println!("cargo:rerun-if-changed={}", shader_path.to_str().unwrap()); - - let mut out_path = out_dir.join(shader_path.file_name().unwrap()); - out_path.set_extension("air"); - - let status = Command::new("xcrun") - .args(&["-sdk", sdk_name, "metal", "-c"]) - .arg(shader_path.as_os_str()) - .arg("-o") - .arg(out_path.as_os_str()) - .args(platform_args) - .status() - .expect("failed to execute metal compiler"); - - if !status.success() { - // stdout is linked to parent, so more detailed message will have been output from `metal` - panic!("shader compilation failed"); - } - - compiled_shader_files.push(out_path); - } - - // Link all the compiled files into a single library - let status = Command::new("xcrun") - .args(&["-sdk", sdk_name, "metallib"]) - .args(compiled_shader_files.iter().map(|p| p.as_os_str())) - .arg("-o") - .arg(out_lib.as_os_str()) - .status() - .expect("failed to execute metal library builder"); - - if !status.success() { - panic!("shader library build failed"); - } -} diff --git a/src/backend/metal/shaders/gfx_shaders.metallib b/src/backend/metal/shaders/gfx_shaders.metallib new file mode 100644 index 00000000000..b446e8f695a Binary files /dev/null and b/src/backend/metal/shaders/gfx_shaders.metallib differ diff --git a/src/backend/metal/src/internal.rs b/src/backend/metal/src/internal.rs index 66a6d0e6193..2246e8b3325 100644 --- a/src/backend/metal/src/internal.rs +++ b/src/backend/metal/src/internal.rs @@ -451,7 +451,7 @@ pub struct ServicePipes { impl ServicePipes { pub fn new(device: &metal::DeviceRef) -> Self { - let data = include_bytes!(concat!(env!("OUT_DIR"), "/gfx_shaders.metallib")); + let data = include_bytes!("./../shaders/gfx_shaders.metallib"); let library = device.new_library_with_data(data).unwrap(); let copy_buffer = Self::create_copy_buffer(&library, device);