summaryrefslogtreecommitdiffstats
path: root/gfx/wr/example-compositor/compositor-wayland/build.rs
blob: ab418b94c79a58fd324a816b8dca0d5e770c3649 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use std::process::Command;
use std::env;
use std::fs;

extern crate pkg_config;

fn main() {
    let out_dir = env::var("OUT_DIR").unwrap();

    fs::create_dir_all(&format!("{}/include", out_dir)).unwrap();
    Command::new("wayland-scanner")
        .args(&["client-header", "/usr/share/wayland-protocols/stable/viewporter/viewporter.xml"])
        .arg(&format!("{}/include/viewporter-client-protocol.h", out_dir))
        .status().unwrap();

    Command::new("wayland-scanner")
        .args(&["public-code", "/usr/share/wayland-protocols/stable/viewporter/viewporter.xml"])
        .arg(&format!("{}/viewporter-protocol.c", out_dir))
        .status().unwrap();

    Command::new("wayland-scanner")
        .args(&["client-header", "/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml"])
        .arg(&format!("{}/include/xdg-shell-client-protocol.h", out_dir))
        .status().unwrap();

    Command::new("wayland-scanner")
        .args(&["public-code", "/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml"])
        .arg(&format!("{}/xdg-shell-protocol.c", out_dir))
        .status().unwrap();

    cc::Build::new()
        .include(&format!("{}/include", out_dir))
        .file("src/lib.cpp")
        .file(&format!("{}/viewporter-protocol.c", out_dir))
        .file(&format!("{}/xdg-shell-protocol.c", out_dir))
        .compile("wayland");

    println!("cargo:rustc-link-lib=dylib=stdc++");

    pkg_config::Config::new()
        .atleast_version("1")
        .probe("egl")
        .unwrap();
    pkg_config::Config::new()
        .atleast_version("1")
        .probe("gl")
        .unwrap();
    pkg_config::Config::new()
        .atleast_version("1")
        .probe("wayland-client")
        .unwrap();
    pkg_config::Config::new()
        .atleast_version("1")
        .probe("wayland-egl")
        .unwrap();

    println!("cargo:rerun-if-changed=src/lib.rs");
    println!("cargo:rerun-if-changed=src/lib.cpp");
}