Skip to content

Commit

Permalink
feat: crates know their versions
Browse files Browse the repository at this point in the history
Removed redundant `FIRECRACKER_VERSION` definitions from
`build.rs` in root and firecracker crate,
because `CARGO_PKG_VERSION` can be used instead.

Also removed `build.rs` from root as it is now
not used for anything.

Signed-off-by: Egor Lazarchuk <[email protected]>
  • Loading branch information
ShadowCurse committed Sep 21, 2023
1 parent 184011c commit 4a248b6
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 32 deletions.
15 changes: 0 additions & 15 deletions build.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/cpu-template-helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "cpu-template-helper"
version = "1.5.0-dev"
authors = ["Amazon Firecracker team <[email protected]>"]
edition = "2021"
build = "../../build.rs"
license = "Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion src/cpu-template-helper/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub mod aarch64;
#[cfg(target_arch = "x86_64")]
pub mod x86_64;

pub const CPU_TEMPLATE_HELPER_VERSION: &str = env!("FIRECRACKER_VERSION");
pub const CPU_TEMPLATE_HELPER_VERSION: &str = env!("CARGO_PKG_VERSION");

/// Trait for key of `HashMap`-based modifier.
///
Expand Down
6 changes: 0 additions & 6 deletions src/firecracker/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ const SECCOMPILER_SRC_DIR: &str = "../seccompiler/src";
// It compiles the JSON seccomp policies into a serializable BPF format, using seccompiler-bin.
// The generated binary code will get included in Firecracker's code, at compile-time.
fn main() {
let firecracker_version = env!("CARGO_PKG_VERSION").to_string();
println!(
"cargo:rustc-env=FIRECRACKER_VERSION={}",
firecracker_version
);

// Target triple
let target = std::env::var("TARGET").expect("Missing target.");
let out_dir = std::env::var("OUT_DIR").expect("Missing build-level OUT_DIR.");
Expand Down
2 changes: 1 addition & 1 deletion src/firecracker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::seccomp::SeccompConfig;
// see https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html for more information.
const DEFAULT_API_SOCK_PATH: &str = "/run/firecracker.socket";
const DEFAULT_INSTANCE_ID: &str = "anonymous-instance";
const FIRECRACKER_VERSION: &str = env!("FIRECRACKER_VERSION");
const FIRECRACKER_VERSION: &str = env!("CARGO_PKG_VERSION");
const MMDS_CONTENT_ARG: &str = "metadata";

#[derive(Debug, thiserror::Error, displaydoc::Display)]
Expand Down
1 change: 0 additions & 1 deletion src/jailer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "jailer"
version = "1.5.0-dev"
authors = ["Amazon Firecracker team <[email protected]>"]
edition = "2021"
build = "../../build.rs"
description = "Process for starting Firecracker in production scenarios; applies a cgroup/namespace isolation barrier and then drops privileges."
homepage = "https://firecracker-microvm.github.io/"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/jailer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod chroot;
mod env;
mod resource_limits;

const JAILER_VERSION: &str = env!("FIRECRACKER_VERSION");
const JAILER_VERSION: &str = env!("CARGO_PKG_VERSION");

#[derive(Debug, thiserror::Error)]
pub enum JailerError {
Expand Down
1 change: 0 additions & 1 deletion src/rebase-snap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "rebase-snap"
version = "1.5.0-dev"
authors = ["Amazon Firecracker team <[email protected]>"]
edition = "2021"
build = "../../build.rs"
license = "Apache-2.0"

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion src/rebase-snap/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::os::unix::io::AsRawFd;
use utils::arg_parser::{ArgParser, Argument, Arguments, Error as ArgError};
use utils::seek_hole::SeekHole;

const REBASE_SNAP_VERSION: &str = env!("FIRECRACKER_VERSION");
const REBASE_SNAP_VERSION: &str = env!("CARGO_PKG_VERSION");
const BASE_FILE: &str = "base-file";
const DIFF_FILE: &str = "diff-file";

Expand Down
1 change: 0 additions & 1 deletion src/seccompiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "seccompiler"
version = "1.5.0-dev"
authors = ["Amazon Firecracker team <[email protected]>"]
edition = "2021"
build = "../../build.rs"
description = "Program that compiles multi-threaded seccomp-bpf filters expressed as JSON into raw BPF programs, serializing them and outputting them to a file."
homepage = "https://firecracker-microvm.github.io/"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/seccompiler/src/seccompiler_bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use compiler::{CompilationError, Compiler, JsonFile};
use serde_json::error::Error as JSONError;
use utils::arg_parser::{ArgParser, Argument, Arguments as ArgumentsBag, Error as ArgParserError};

const SECCOMPILER_VERSION: &str = env!("FIRECRACKER_VERSION");
const SECCOMPILER_VERSION: &str = env!("CARGO_PKG_VERSION");
const DEFAULT_OUTPUT_FILENAME: &str = "seccomp_binary_filter.out";

#[derive(Debug, thiserror::Error)]
Expand Down
1 change: 0 additions & 1 deletion src/snapshot-editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "snapshot-editor"
version = "1.5.0"
authors = ["Amazon Firecracker team <[email protected]>"]
edition = "2021"
build = "../../build.rs"
license = "Apache-2.0"

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion src/snapshot-editor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum SnapEditorError {
}

#[derive(Debug, Parser)]
#[command(version = format!("v{}", env!("FIRECRACKER_VERSION")))]
#[command(version = format!("v{}", env!("CARGO_PKG_VERSION")))]
struct Cli {
#[command(subcommand)]
command: Command,
Expand Down

0 comments on commit 4a248b6

Please sign in to comment.