-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
42 lines (36 loc) · 1.25 KB
/
build.rs
File metadata and controls
42 lines (36 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use anyhow::Result;
use vergen_gix::{BuildBuilder, CargoBuilder, Emitter, GixBuilder};
#[cfg(feature = "blog")]
const ATPROTO_LEXICON_DIR: &str = "src/atproto/lexicons";
#[cfg(feature = "blog")]
const ATPROTO_CLIENT_DIR: &str = "src/atproto";
fn main() -> Result<()> {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/atproto/lexicons");
println!("cargo:rerun-if-changed=Cargo.toml");
// Generate ATProto client with lexicon validation
#[cfg(feature = "blog")]
atrium_codegen::genapi(
ATPROTO_LEXICON_DIR,
ATPROTO_CLIENT_DIR,
&[("com.whtwnd", Some("blog"))],
)
.unwrap();
// Emit the build information
let build = BuildBuilder::all_build()?;
let gix = GixBuilder::all_git()?;
let cargo = CargoBuilder::all_cargo()?;
Emitter::default()
.add_instructions(&build)?
.add_instructions(&gix)?
.add_instructions(&cargo)?
.emit_and_set()?;
// Emit the full formatted version (vX.Y.Z-COMMIT_HASH[-dirty]?)
println!(
"cargo:rustc-env=PKG_FULL_VERSION=v{}-{}{}",
env!("CARGO_PKG_VERSION"),
&env!("VERGEN_GIT_SHA")[..7],
if env!("VERGEN_GIT_DIRTY") == "true" { "-dirty" } else { "" }
);
Ok(())
}