|
| 1 | +fn main() { |
| 2 | + let build_id = format!( |
| 3 | + "$Id: {}, Version: {}, Commit: {}, Branch: {}, Build ID: {}, Build Number: {}, Timestamp: {}$", |
| 4 | + env!("CARGO_PKG_NAME"), |
| 5 | + env!("CARGO_PKG_VERSION"), |
| 6 | + option_env!("BUILD_SOURCEVERSION").unwrap_or("unknown"), |
| 7 | + option_env!("BUILD_SOURCEBRANCH").unwrap_or("unknown"), |
| 8 | + option_env!("BUILD_BUILDID").unwrap_or("unknown"), |
| 9 | + option_env!("BUILD_BUILDNUMBER").unwrap_or("unknown"), |
| 10 | + std::time::SystemTime::now() |
| 11 | + .duration_since(std::time::UNIX_EPOCH) |
| 12 | + .unwrap_or_default() |
| 13 | + .as_secs(), |
| 14 | + ); |
| 15 | + println!("cargo:rustc-env=BUILD_IDENTIFIER={}", build_id); |
| 16 | + |
| 17 | + let mut header: String = r"// Copyright (c) Microsoft Corporation. All rights reserved. |
| 18 | +// Licensed under the MIT License. |
| 19 | +
|
| 20 | +// This file is auto-generated by cbindgen. Do not edit manually. |
| 21 | +" |
| 22 | + .to_string(); |
| 23 | + header.push_str(&format!("// Build identifier: {}\n", build_id)); |
| 24 | + |
| 25 | + let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); |
| 26 | + cbindgen::Builder::new() |
| 27 | + .with_crate(crate_dir) |
| 28 | + .with_language(cbindgen::Language::C) |
| 29 | + .with_after_include(format!( |
| 30 | + "\n// Specifies the version of cosmosclient this header file was generated from.\n// This should match the version of libcosmosclient you are referencing.\n#define COSMOSCLIENT_H_VERSION \"{}\"", |
| 31 | + env!("CARGO_PKG_VERSION") |
| 32 | + )) |
| 33 | + .with_cpp_compat(true) |
| 34 | + .with_header(header) |
| 35 | + .generate() |
| 36 | + .expect("unable to generate bindings") |
| 37 | + .write_to_file("include/cosmosclient.h"); |
| 38 | +} |
0 commit comments