-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.rs
More file actions
67 lines (61 loc) · 1.97 KB
/
Copy pathbuild.rs
File metadata and controls
67 lines (61 loc) · 1.97 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// SPDX-FileCopyrightText: 2026 Roman Valls Guimera <brainstorm@nopcode.org>
// SPDX-FileCopyrightText: 2026 Marko Malenic <mmalenic1@gmail.com>
//
// SPDX-License-Identifier: GPL-3.0-or-later
//! Build configuration
use esp_config::{ConfigOption, Validator, Value, generate_config};
fn main() {
emit_ssh_ident();
generate_config(
"ssh-stamp",
&[option(
"heap_size",
"Global allocator heap size in bytes",
60 * 1024,
16 * 1024..257 * 1024,
)],
true,
true,
);
}
/// Emits `SSH_STAMP_IDENT` from the `sunset` version.
fn emit_ssh_ident() {
println!("cargo:rerun-if-changed=Cargo.lock");
let lock_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.lock");
// A missing lockfile (e.g. an unusual packaged build) only costs the
// version in the ident string, so don't fail the build over it.
let lock = std::fs::read_to_string(&lock_path).unwrap_or_default();
let sunset_ver = lock
.split("[[package]]")
.find(|s| s.contains("name = \"sunset\""))
.and_then(|s| {
s.lines().find_map(|l| {
l.trim()
.strip_prefix("version = ")
.map(|v| v.trim_matches('"'))
})
})
.unwrap_or("unknown");
let ident = format!(
"SSH-2.0-Sunset-{sunset_ver}-ssh-stamp-{}",
env!("CARGO_PKG_VERSION")
);
println!("cargo::rustc-env=SSH_STAMP_IDENT={ident}");
}
/// A byte integer option.
fn option(
name: &str,
description: &str,
default: i128,
range: std::ops::Range<i128>,
) -> ConfigOption {
ConfigOption {
name: name.to_string(),
description: description.to_string(),
default_value: Value::Integer(default),
constraint: Some(Validator::IntegerInRange(range)),
stability: esp_config::Stability::Unstable,
active: true,
display_hint: esp_config::DisplayHint::None,
}
}