Kristian H. Kristensen | 7c45ef1 | 2021-04-06 21:54:57 +0000 | [diff] [blame] | 1 | extern crate wayland_scanner; |
Kristian H. Kristensen | 974c7cd | 2021-01-24 12:50:23 +0000 | [diff] [blame] | 2 | |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 3 | use std::env; |
Kristian H. Kristensen | 974c7cd | 2021-01-24 12:50:23 +0000 | [diff] [blame] | 4 | use std::path::Path; |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 5 | use std::path::PathBuf; |
Kristian H. Kristensen | b54da80 | 2021-09-09 12:35:09 +0000 | [diff] [blame] | 6 | use std::process::Command; |
Kristian H. Kristensen | 974c7cd | 2021-01-24 12:50:23 +0000 | [diff] [blame] | 7 | use wayland_scanner::*; |
| 8 | |
Kristian H. Kristensen | b54da80 | 2021-09-09 12:35:09 +0000 | [diff] [blame] | 9 | fn run_bindgen(header: &str, output: &str) { |
| 10 | let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); |
| 11 | |
Kristian H. Kristensen | 1cea60c | 2021-09-17 12:41:35 +0000 | [diff] [blame] | 12 | let sysroot = env::var("SYSROOT").unwrap_or("/".to_string()); |
| 13 | |
| 14 | let status = Command::new("bindgen") |
Kristian H. Kristensen | 129df19 | 2021-09-27 08:48:04 +0000 | [diff] [blame] | 15 | .args(&["-o", out_path.join(output).to_str().unwrap()]) |
| 16 | .arg("--no-doc-comments") |
| 17 | .arg("--no-layout-tests") |
| 18 | .args(&["--new-type-alias", "wl_fixed_t"]) |
| 19 | .args(&["--default-enum-style", "rust_non_exhaustive"]) |
| 20 | .args(&["--bitfield-enum", "weston_keyboard_modifier"]) |
| 21 | .args(&["--bitfield-enum", "wl_shell_surface_resize"]) |
Kristian H. Kristensen | e1d57ee | 2021-11-10 23:33:29 +0100 | [diff] [blame] | 22 | .args(&["--bitfield-enum", "weston_activate_flag"]) |
Kristian H. Kristensen | b7d5351 | 2021-11-12 14:24:17 +0100 | [diff] [blame] | 23 | .args(&["--no-copy", "shell_surface"]) |
Kristian H. Kristensen | 129df19 | 2021-09-27 08:48:04 +0000 | [diff] [blame] | 24 | .arg(header) |
| 25 | .arg("--") |
| 26 | .arg(format!("--sysroot={}", sysroot)) |
| 27 | .arg("-I/usr/include/pixman-1") |
Kristian H. Kristensen | 37e86ea | 2021-10-06 21:13:25 +0000 | [diff] [blame] | 28 | .arg("-I./weston/include") |
Kristian H. Kristensen | 129df19 | 2021-09-27 08:48:04 +0000 | [diff] [blame] | 29 | .arg("-I./bindgen/block") |
| 30 | .status() |
| 31 | .unwrap(); |
Kristian H. Kristensen | 1cea60c | 2021-09-17 12:41:35 +0000 | [diff] [blame] | 32 | |
| 33 | assert!(status.success()) |
Kristian H. Kristensen | b54da80 | 2021-09-09 12:35:09 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Kristian H. Kristensen | cad53c4 | 2021-03-08 16:19:24 +0000 | [diff] [blame] | 36 | fn main() { |
| 37 | let protocols = [ |
Kristian H. Kristensen | 7c45ef1 | 2021-04-06 21:54:57 +0000 | [diff] [blame] | 38 | "wayland", |
Kristian H. Kristensen | 999d840 | 2021-10-13 13:40:29 +0000 | [diff] [blame] | 39 | "xdg-shell", |
Kristian H. Kristensen | 73a22cf | 2021-10-11 12:09:18 +0000 | [diff] [blame] | 40 | "weston-screenshooter", |
Kristian H. Kristensen | 7c45ef1 | 2021-04-06 21:54:57 +0000 | [diff] [blame] | 41 | "linux-dmabuf-unstable-v1", |
| 42 | "croscomp", |
| 43 | "alpha-compositing-unstable-v1", |
| 44 | "aura-shell", |
| 45 | "cursor-shapes-unstable-v1", |
| 46 | "gaming-input-unstable-v2", |
| 47 | "keyboard-configuration-unstable-v1", |
| 48 | "keyboard-extension-unstable-v1", |
| 49 | "pointer-gestures-unstable-v1", |
| 50 | "remote-shell-unstable-v1", |
| 51 | "secure-output-unstable-v1", |
| 52 | "stylus-tools-unstable-v1", |
| 53 | "stylus-unstable-v2", |
| 54 | "vsync-feedback-unstable-v1", |
Kristian H. Kristensen | cad53c4 | 2021-03-08 16:19:24 +0000 | [diff] [blame] | 55 | ]; |
| 56 | |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 57 | let out_dir_str = env::var("OUT_DIR").unwrap(); |
Kristian H. Kristensen | 974c7cd | 2021-01-24 12:50:23 +0000 | [diff] [blame] | 58 | let out_dir = Path::new(&out_dir_str); |
Kristian H. Kristensen | cad53c4 | 2021-03-08 16:19:24 +0000 | [diff] [blame] | 59 | for e in &protocols { |
Kristian H. Kristensen | 7c45ef1 | 2021-04-06 21:54:57 +0000 | [diff] [blame] | 60 | let spec = Path::new("protocol").join(e).with_extension("xml"); |
| 61 | let out = out_dir.join(e).with_extension("rs"); |
| 62 | println!("cargo:rerun-if-changed={}", spec.to_str().unwrap()); |
Kristian H. Kristensen | 7c45ef1 | 2021-04-06 21:54:57 +0000 | [diff] [blame] | 63 | generate_code_with_destructor_events(spec, out, Side::Server, &[("wl_callback", "done")]); |
Kristian H. Kristensen | cad53c4 | 2021-03-08 16:19:24 +0000 | [diff] [blame] | 64 | } |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 65 | |
Kristian H. Kristensen | b54da80 | 2021-09-09 12:35:09 +0000 | [diff] [blame] | 66 | run_bindgen("/usr/include/linux/input.h", "input.rs"); |
Kristian H. Kristensen | 73599dc | 2021-10-07 20:05:00 +0000 | [diff] [blame] | 67 | run_bindgen("./weston/croscomp_weston.h", "croscomp_weston.rs"); |
Kristian H. Kristensen | 8cc818f | 2021-02-12 22:52:36 +0000 | [diff] [blame] | 68 | |
Kristian H. Kristensen | 37a41f8 | 2022-01-20 14:17:36 +0100 | [diff] [blame] | 69 | let lib_paths = ["libweston"]; |
Kristian H. Kristensen | 4cbd08f | 2021-04-06 18:15:54 +0000 | [diff] [blame] | 70 | |
Kristian H. Kristensen | 18c7e1e | 2021-11-11 17:03:03 +0100 | [diff] [blame] | 71 | let build_dir = |
| 72 | env::var("MESON_BUILD_DIR").unwrap_or(format!("{}/../../../weston", out_dir_str)); |
| 73 | |
Kristian H. Kristensen | 4cbd08f | 2021-04-06 18:15:54 +0000 | [diff] [blame] | 74 | for p in &lib_paths { |
Kristian H. Kristensen | 37e86ea | 2021-10-06 21:13:25 +0000 | [diff] [blame] | 75 | println!("cargo:rustc-flags=-L{}/{}", build_dir, p); |
Kristian H. Kristensen | 4cbd08f | 2021-04-06 18:15:54 +0000 | [diff] [blame] | 76 | } |
Kristian H. Kristensen | 7c45ef1 | 2021-04-06 21:54:57 +0000 | [diff] [blame] | 77 | |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 78 | println!("cargo:rustc-link-lib=weston-9"); |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 79 | println!("cargo:rustc-link-lib=input"); |
Kristian H. Kristensen | 37e86ea | 2021-10-06 21:13:25 +0000 | [diff] [blame] | 80 | println!("cargo:rustc-link-lib=evdev"); |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 81 | println!("cargo:rustc-link-lib=wayland-server"); |
| 82 | println!("cargo:rustc-link-lib=pixman-1"); |
Kristian H. Kristensen | 4dd859a | 2021-01-25 17:28:59 +0000 | [diff] [blame] | 83 | } |