build.rs (2161B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 use std::process::Command; 6 use std::env; 7 use std::fs; 8 9 extern crate pkg_config; 10 11 fn main() { 12 let out_dir = env::var("OUT_DIR").unwrap(); 13 14 fs::create_dir_all(&format!("{}/include", out_dir)).unwrap(); 15 Command::new("wayland-scanner") 16 .args(&["client-header", "/usr/share/wayland-protocols/stable/viewporter/viewporter.xml"]) 17 .arg(&format!("{}/include/viewporter-client-protocol.h", out_dir)) 18 .status().unwrap(); 19 20 Command::new("wayland-scanner") 21 .args(&["public-code", "/usr/share/wayland-protocols/stable/viewporter/viewporter.xml"]) 22 .arg(&format!("{}/viewporter-protocol.c", out_dir)) 23 .status().unwrap(); 24 25 Command::new("wayland-scanner") 26 .args(&["client-header", "/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml"]) 27 .arg(&format!("{}/include/xdg-shell-client-protocol.h", out_dir)) 28 .status().unwrap(); 29 30 Command::new("wayland-scanner") 31 .args(&["public-code", "/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml"]) 32 .arg(&format!("{}/xdg-shell-protocol.c", out_dir)) 33 .status().unwrap(); 34 35 cc::Build::new() 36 .include(&format!("{}/include", out_dir)) 37 .file("src/lib.cpp") 38 .file(&format!("{}/viewporter-protocol.c", out_dir)) 39 .file(&format!("{}/xdg-shell-protocol.c", out_dir)) 40 .compile("wayland"); 41 42 println!("cargo:rustc-link-lib=dylib=stdc++"); 43 44 pkg_config::Config::new() 45 .atleast_version("1") 46 .probe("egl") 47 .unwrap(); 48 pkg_config::Config::new() 49 .atleast_version("1") 50 .probe("gl") 51 .unwrap(); 52 pkg_config::Config::new() 53 .atleast_version("1") 54 .probe("wayland-client") 55 .unwrap(); 56 pkg_config::Config::new() 57 .atleast_version("1") 58 .probe("wayland-egl") 59 .unwrap(); 60 61 println!("cargo:rerun-if-changed=src/lib.rs"); 62 println!("cargo:rerun-if-changed=src/lib.cpp"); 63 }