Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conditional compilation to early-boot-config #1288

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions sources/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions sources/api/early-boot-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ exclude = ["README.md"]

[dependencies]
apiclient = { path = "../apiclient" }
base64 = "0.13"
http = "0.2"
log = "0.4"
reqwest = { version = "0.10", default-features = false, features = ["blocking"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
serde-xml-rs = "0.4.1"
simplelog = "0.9"
snafu = "0.6"
tokio = { version = "0.2", default-features = false, features = ["macros", "rt-threaded"] }
Expand Down
23 changes: 23 additions & 0 deletions sources/api/early-boot-config/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use std::process;

fn main() {
// The code below emits `cfg` operators to conditionally compile this program based on the
// current variant.
// TODO: Replace this approach when the build system supports ideas like "variant
// tags": https://github.com/bottlerocket-os/bottlerocket/issues/1260
println!("cargo:rerun-if-env-changed=VARIANT");
if let Ok(variant) = env::var("VARIANT") {
if variant == "aws-dev" {
println!("cargo:rustc-cfg=bottlerocket_platform=\"aws-dev\"");
} else if variant.starts_with("aws") {
println!("cargo:rustc-cfg=bottlerocket_platform=\"aws\"");
} else if variant.starts_with("vmware") {
println!("cargo:rustc-cfg=bottlerocket_platform=\"vmware\"");
} else {
eprintln!(
"For local builds, you must set the 'VARIANT' environment variable so we know which data \
provider to build. Valid values are the directories in models/src/variants/, for \
example 'aws-k8s-1.17'."
);
process::exit(1);
}
}

// Check for environment variable "SKIP_README". If it is set,
// skip README generation
if env::var_os("SKIP_README").is_some() {
Expand Down
Loading