Kristian H. Kristensen | 974c7cd | 2021-01-24 12:50:23 +0000 | [diff] [blame] | 1 | extern crate wayland_scanner; |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 2 | extern crate bindgen; |
Kristian H. Kristensen | 974c7cd | 2021-01-24 12:50:23 +0000 | [diff] [blame] | 3 | |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 4 | use std::env; |
Kristian H. Kristensen | 974c7cd | 2021-01-24 12:50:23 +0000 | [diff] [blame] | 5 | use std::path::Path; |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 6 | use std::path::PathBuf; |
Kristian H. Kristensen | 974c7cd | 2021-01-24 12:50:23 +0000 | [diff] [blame] | 7 | use wayland_scanner::*; |
| 8 | |
Kristian H. Kristensen | cad53c4 | 2021-03-08 16:19:24 +0000 | [diff] [blame] | 9 | fn main() { |
| 10 | let protocols = [ |
| 11 | "wayland", |
| 12 | "linux-dmabuf-unstable-v1", |
| 13 | "croscomp", |
| 14 | "alpha-compositing-unstable-v1", |
| 15 | "aura-shell", |
| 16 | "cursor-shapes-unstable-v1", |
| 17 | "gaming-input-unstable-v2", |
| 18 | "keyboard-configuration-unstable-v1", |
| 19 | "keyboard-extension-unstable-v1", |
| 20 | "pointer-gestures-unstable-v1", |
| 21 | "remote-shell-unstable-v1", |
| 22 | "secure-output-unstable-v1", |
| 23 | "stylus-tools-unstable-v1", |
| 24 | "stylus-unstable-v2", |
| 25 | "vsync-feedback-unstable-v1", |
| 26 | ]; |
| 27 | |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 28 | let out_dir_str = env::var("OUT_DIR").unwrap(); |
Kristian H. Kristensen | 974c7cd | 2021-01-24 12:50:23 +0000 | [diff] [blame] | 29 | let out_dir = Path::new(&out_dir_str); |
Kristian H. Kristensen | cad53c4 | 2021-03-08 16:19:24 +0000 | [diff] [blame] | 30 | for e in &protocols { |
| 31 | let spec = Path::new("protocol").join(e).with_extension("xml"); |
| 32 | let out = out_dir.join(e).with_extension("rs"); |
| 33 | println!("cargo:rerun-if-changed={}", spec.to_str().unwrap()); |
| 34 | println!("// out: {}", out.to_str().unwrap()); |
| 35 | generate_code_with_destructor_events( |
| 36 | spec, |
| 37 | out, |
| 38 | Side::Server, |
| 39 | &[("wl_callback", "done")], |
| 40 | ); |
| 41 | } |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 42 | |
| 43 | let bindings = bindgen::Builder::default() |
| 44 | .clang_arg("-I/usr/include/pixman-1") |
| 45 | .clang_arg("-I./subprojects/weston/include") |
| 46 | .clang_arg("-I./bindgen/block") |
| 47 | .header("./subprojects/weston/include/libweston/backend-drm.h") |
Kristian H. Kristensen | a37cf3f | 2021-02-08 12:03:50 +0000 | [diff] [blame] | 48 | .header("./subprojects/weston/desktop-shell/shell.h") |
| 49 | .header("./subprojects/weston/compositor/weston.h") |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 50 | .generate_comments(false) |
Kristian H. Kristensen | ebc5e8e | 2021-02-26 14:32:24 +0000 | [diff] [blame] | 51 | .new_type_alias("wl_fixed_t") |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 52 | .default_enum_style(bindgen::EnumVariation::Rust{non_exhaustive: true}) |
Kristian H. Kristensen | 8038f50 | 2021-02-08 12:05:45 +0000 | [diff] [blame] | 53 | .bitfield_enum("weston_keyboard_modifier") |
Kristian H. Kristensen | 3ec9249 | 2021-02-22 12:16:13 +0000 | [diff] [blame] | 54 | .bitfield_enum("wl_shell_surface_resize") |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 55 | .layout_tests(false) |
| 56 | .parse_callbacks(Box::new(bindgen::CargoCallbacks)) |
| 57 | .generate() |
| 58 | .expect("Unable to generate bindings"); |
| 59 | |
| 60 | let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); |
| 61 | bindings |
| 62 | .write_to_file(out_path.join("bindings.rs")) |
| 63 | .expect("Couldn't write bindings!"); |
| 64 | |
Kristian H. Kristensen | 8cc818f | 2021-02-12 22:52:36 +0000 | [diff] [blame] | 65 | let bindings = bindgen::Builder::default() |
| 66 | .header("/usr/include/linux/input.h") |
| 67 | .generate_comments(false) |
| 68 | .generate() |
| 69 | .expect("Unable to generate input.h bindings"); |
| 70 | |
| 71 | let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); |
| 72 | bindings |
| 73 | .write_to_file(out_path.join("input.rs")) |
| 74 | .expect("Couldn't write bindings!"); |
| 75 | |
Kristian H. Kristensen | 4cbd08f | 2021-04-06 18:15:54 +0000 | [diff] [blame^] | 76 | let lib_paths = [ |
| 77 | "weston/compositor", |
| 78 | "weston/desktop-shell", |
| 79 | "weston/libweston", |
| 80 | "libinput", |
| 81 | "libevdev" |
| 82 | ]; |
| 83 | |
| 84 | let chost = env::var("CHOST").unwrap(); |
| 85 | for p in &lib_paths { |
| 86 | println!("cargo:rustc-flags=-Ltarget/{}/debug/meson/subprojects/{}", chost, p); |
| 87 | } |
| 88 | |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 89 | println!("cargo:rustc-link-lib=exec_weston"); |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 90 | println!("cargo:rustc-link-lib=desktop-shell"); |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 91 | println!("cargo:rustc-link-lib=weston-9"); |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 92 | println!("cargo:rustc-link-lib=input"); |
Kristian H. Kristensen | e8d3b4d | 2021-02-05 16:39:09 +0000 | [diff] [blame] | 93 | println!("cargo:rustc-link-lib=evdev-fdo"); |
| 94 | println!("cargo:rustc-link-lib=wayland-server"); |
| 95 | println!("cargo:rustc-link-lib=pixman-1"); |
Kristian H. Kristensen | 4dd859a | 2021-01-25 17:28:59 +0000 | [diff] [blame] | 96 | } |