Avoid generating header files when they already exist

This commit is contained in:
Michael Vines 2020-08-07 17:42:46 -07:00
parent b5a9a43224
commit 735eafb7e0
4 changed files with 25 additions and 4 deletions

View File

@ -5,11 +5,14 @@ set -ex
# Test program
cd "$(dirname "$0")/.."
./do.sh update
./do.sh build token
./do.sh fmt token-swap --all -- --check
./do.sh build-lib token-swap -D warnings
./do.sh build token-swap
./do.sh clippy token-swap -- --deny=warnings
SPL_CBINDGEN=1 ./do.sh build-lib token-swap -D warnings
git diff --exit-code token-swap/inc/token-swap.h
./do.sh build token
./do.sh build token-swap
./do.sh doc token-swap
./do.sh test token-swap
cc token-swap/inc/token-swap.h -o token-swap/target/token-swap.gch

View File

@ -6,8 +6,12 @@ set -ex
cd "$(dirname "$0")/.."
./do.sh update
./do.sh fmt token --all -- --check
./do.sh build token
./do.sh clippy token -- --deny=warnings
SPL_CBINDGEN=1 ./do.sh build-lib token -D warnings
git diff --exit-code token/inc/token.h
./do.sh build token
./do.sh doc token
./do.sh test token
cc token/inc/token.h -o token/target/token.gch

View File

@ -3,6 +3,13 @@ extern crate cbindgen;
use std::env;
fn main() {
println!("cargo:rerun-if-env-changed=SPL_CBINDGEN");
println!("cargo:rerun-if-changed=inc/token-swap.h");
if std::path::Path::new("inc/token-swap.h").exists() && env::var("SPL_CBINDGEN").is_err() {
return;
}
println!("cargo:warning=Generating inc/token-swap.h");
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::generate(&crate_dir)
.unwrap()

View File

@ -3,6 +3,13 @@ extern crate cbindgen;
use std::env;
fn main() {
println!("cargo:rerun-if-env-changed=SPL_CBINDGEN");
println!("cargo:rerun-if-changed=inc/token.h");
if std::path::Path::new("inc/token.h").exists() && env::var("SPL_CBINDGEN").is_err() {
return;
}
println!("cargo:warning=Generating inc/token.h");
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let config = cbindgen::Config {
header: Some("/* Autogenerated SPL Token program C Bindings */".to_string()),