Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Fix wen_restart proto compilation: (#33596)
Browse files Browse the repository at this point in the history
* Fix wen_restart proto compilation:
- should recompile when proto changes
- no need for customization

* There is only one proto file, no need for loop.
  • Loading branch information
wen-coding authored Oct 9, 2023
1 parent 1d91b60 commit 2d5496a
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions wen-restart/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
extern crate rustc_version;

use {
rustc_version::{version_meta, Channel},
std::io::Result,
};
use std::io::Result;

fn main() -> Result<()> {
const PROTOC_ENVAR: &str = "PROTOC";
Expand All @@ -12,30 +9,11 @@ fn main() -> Result<()> {
std::env::set_var(PROTOC_ENVAR, protobuf_src::protoc());
}

// Copied and adapted from
// https://github.com/Kimundi/rustc-version-rs/blob/1d692a965f4e48a8cb72e82cda953107c0d22f47/README.md#example
// Licensed under Apache-2.0 + MIT
match version_meta().unwrap().channel {
Channel::Stable => {
println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION");
}
Channel::Beta => {
println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION");
}
Channel::Nightly => {
println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION");
}
Channel::Dev => {
println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION");
// See https://github.com/solana-labs/solana/issues/11055
// We may be running the custom `rust-bpf-builder` toolchain,
// which currently needs `#![feature(proc_macro_hygiene)]` to
// be applied.
println!("cargo:rustc-cfg=RUSTC_NEEDS_PROC_MACRO_HYGIENE");
}
}
let proto_base_path = std::path::PathBuf::from("proto");
let proto = proto_base_path.join("wen_restart.proto");
println!("cargo:rerun-if-changed={}", proto.display());

// Generate rust files from protos.
prost_build::compile_protos(&["proto/wen_restart.proto"], &["proto/"])?;
prost_build::compile_protos(&[proto], &[proto_base_path])?;
Ok(())
}

0 comments on commit 2d5496a

Please sign in to comment.