crosvm/crosvm_control/build.rs
Dennis Kempin 4fea399df9 Reformat imports
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.

Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.

BUG=b:239937122
TEST=CQ

Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-28 00:15:50 +00:00

54 lines
1.6 KiB
Rust

// Copyright 2022 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.
use std::env;
use std::path::PathBuf;
use anyhow::Context;
use anyhow::Result;
use cbindgen::Config;
use cbindgen::Language;
static COPYRIGHT_CLAUSE: &str = "// Copyright 2022 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.";
static AUTOGENERATED_DISCLAIMER: &str =
"/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */";
static INCLUDE_GUARD: &str = "CROSVM_CONTROL_H_";
fn main() -> Result<()> {
// Skip building dependencies when generating documents.
if std::env::var("CARGO_DOC").is_ok() {
return Ok(());
}
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let target_dir = env::var("OUT_DIR").context("failed to get OUT_DIR")?;
let output_file = PathBuf::from(target_dir)
.join("crosvm_control.h")
.display()
.to_string();
let config = Config {
language: Language::C,
cpp_compat: true,
header: Some(String::from(COPYRIGHT_CLAUSE)),
include_guard: Some(String::from(INCLUDE_GUARD)),
autogen_warning: Some(String::from(AUTOGENERATED_DISCLAIMER)),
include_version: true,
..Default::default()
};
cbindgen::Builder::new()
.with_crate(crate_dir)
.with_config(config)
.generate()
.context("Unable to generate bindings")?
.write_to_file(&output_file);
Ok(())
}