-
Notifications
You must be signed in to change notification settings - Fork 0
[build] E: Benchmark specific environment variables #21
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
// Imports | ||
//================================================================================================== | ||
|
||
use std::{fs, io::Read}; | ||
use ::std::{ | ||
env, | ||
path::Path, | ||
|
@@ -35,6 +36,35 @@ fn main() { | |
Err(_) => panic!("failed to get OUT_DIR environment variable"), | ||
}; | ||
|
||
//============================================================================================== | ||
//Benchmark-Specific Environment Variables | ||
//============================================================================================== | ||
|
||
// Get CARGO_MANIFEST_DIR Environment Variable. | ||
let manifest_dir: String = match env::var("CARGO_MANIFEST_DIR") { | ||
Ok(mdir) => mdir, | ||
Err(_) => panic!("failed to get CARGO_MANIFEST_DIR envi"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a typo here: "environment". |
||
}; | ||
|
||
if manifest_dir.contains("benchmarks") { | ||
// Get "benchmarks" directory path. | ||
let benchmarks_dir = Path::new(&manifest_dir).ancestors() | ||
.find(|&p| p.ends_with("benchmarks")); | ||
|
||
if let Some(benchmarks_dir) = benchmarks_dir { | ||
let params_path = benchmarks_dir.join("parameters.json"); | ||
|
||
if params_path.exists() { | ||
let content = fs::read_to_string(¶ms_path) | ||
.expect("Failed to read JSON file"); | ||
// Debug content. | ||
println("cargo:warning=Read values: {:?}", content); | ||
// Pass `content` as an environment variable. | ||
println("cargo:rustc-env=PARAMETERS={}", content); | ||
} | ||
} | ||
Comment on lines
+49
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hard coding logic is always bad. Let's remove the constraint of finding a a file name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, please add type annotations to all declarations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So Inside the current directory, I should look for a file named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change it to look for a file named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lemosep you may also want to consider placing the search and replace logic of values in the So, if you have a file
You should search and replace all constants in the code base that are named Have you thought doing it differently? If so, how? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I've thought first was giving |
||
} | ||
|
||
//============================================================================================== | ||
// Configure Toolchain | ||
//============================================================================================== | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a
::
Before this? Note that this is the standard used in the project.