-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
633: fix #628 r=jonas-schievink a=spookyvision open questions: also make this honor the env var? ```rust // print/src/main.rs:28 const READ_BUFFER_SIZE: usize = 1024; ``` (answered: no, irrelevant) --- add some hints in the app template? (answered: yes) Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com> Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
- Loading branch information
Showing
5 changed files
with
46 additions
and
17 deletions.
There are no files selected for viewing
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,21 @@ | ||
use std::{env, path::PathBuf}; | ||
|
||
fn main() { | ||
println!("cargo:rerun-if-env-changed=DEFMT_RTT_BUFFER_SIZE"); | ||
|
||
let size = env::var("DEFMT_RTT_BUFFER_SIZE") | ||
.map(|s| { | ||
s.parse() | ||
.expect("could not parse DEFMT_RTT_BUFFER_SIZE as usize") | ||
}) | ||
.unwrap_or(1024_usize); | ||
|
||
let out_dir_path = PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
let out_file_path = out_dir_path.join("consts.rs"); | ||
|
||
std::fs::write( | ||
out_file_path, | ||
format!("pub(crate) const BUF_SIZE: usize = {};", size), | ||
) | ||
.unwrap(); | ||
} |
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,2 @@ | ||
// see `build.rs` for contents | ||
include!(concat!(env!("OUT_DIR"), "/consts.rs")); |
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