blob: 523602f72b922415773e86bfb931464a927cdec8 [file] [log] [blame]
// Copyright 2019 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Minijail's build script invoked by cargo.
/// This script prefers linking against a pkg-config provided libminijail, but will fall back to
/// building libminijail statically.
use std::env;
use std::fs::remove_file;
use std::io;
use std::path::Path;
use std::process::Command;
fn bindings_generation() -> io::Result<()> {
let bindgen = which::which("bindgen").unwrap();
let out_dir = env::var("OUT_DIR").unwrap();
let gen_file = Path::new(&out_dir).join("./");
if gen_file.exists() {
remove_file(&gen_file).expect("Failed to remove generated file.");
let header_dir = Path::new(".");
let header_path = header_dir.join("crossystem.h");
println!("cargo:rerun-if-changed={}", header_path.display());
let status = Command::new(&bindgen)
.args(&["--default-enum-style", "rust"])
.args(&["--blacklist-type", "__rlim64_t"])
.args(&["--raw-line", "pub type __rlim64_t = u64;"])
.args(&["--blacklist-type", "__u\\d{1,2}"])
.args(&["--raw-line", "pub type __u8 = u8;"])
.args(&["--raw-line", "pub type __u16 = u16;"])
.args(&["--raw-line", "pub type __u32 = u32;"])
.args(&["--blacklist-type", "__uint64_t"])
.args(&["--output", gen_file.to_str().unwrap()])
fn main() -> io::Result<()> {