Skip to content

Commit

Permalink
Merge pull request #1288 from zmrow/ebc_refactor
Browse files Browse the repository at this point in the history
Add conditional compilation to early-boot-config
  • Loading branch information
zmrow authored Jan 29, 2021
2 parents 7a2f125 + 733f2f3 commit fdadb17
Show file tree
Hide file tree
Showing 11 changed files with 739 additions and 300 deletions.
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

0 comments on commit fdadb17

Please sign in to comment.