-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make MAX_HANDLES configurable at runtime
To build DPE with a non-default number of MAX_HANDLES, you can run ARBITRARY_MAX_HANDLES=10 cargo build --features arbitrary_max_handles. If the ARBITRARY_MAX_HANDLES env var is not provided or is badly formatted, the default value of 24 will be used. Some of the tests will fail for small numbers of max handles, but this is expected since the tests are intended for a DPE with 24 handles. In the future, we should add tests for DPEs where MAX_HANDLES=1, 2, etc. Also, make support features configurable at compile time.
- Loading branch information
1 parent
26a810c
commit 410f50d
Showing
7 changed files
with
119 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed under the Apache-2.0 license | ||
|
||
use std::env; | ||
use std::fs::File; | ||
use std::io::Write; | ||
|
||
fn main() { | ||
let default_value: usize = 24; | ||
|
||
let arbitrary_max_handles = env::var("ARBITRARY_MAX_HANDLES") | ||
.ok() | ||
.and_then(|value| value.parse().ok()) | ||
.unwrap_or(default_value); | ||
|
||
let out_dir = env::var("OUT_DIR").unwrap(); | ||
let dest_path = format!("{}/arbitrary_max_handles.rs", out_dir); | ||
|
||
println!("cargo:rerun-if-env-changed=ARBITRARY_MAX_HANDLES"); | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
|
||
let mut file = File::create(&dest_path).unwrap(); | ||
write!( | ||
file, | ||
"pub const MAX_HANDLES: usize = {};", | ||
arbitrary_max_handles | ||
) | ||
.unwrap(); | ||
|
||
println!("cargo:rerun-if-changed={}", dest_path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters