-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added odra-build crate. * Bumped version to 0.8.1. * Bump cargo odra version for tests
- Loading branch information
Showing
19 changed files
with
94 additions
and
46 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
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
//! Odra's contracts build script. | ||
use std::env; | ||
/// Uses the ENV variable `ODRA_MODULE` to set the `odra_module` cfg flag. | ||
pub fn main() { | ||
println!("cargo:rerun-if-env-changed=ODRA_MODULE"); | ||
let module = env::var("ODRA_MODULE").unwrap_or_else(|_| "".to_string()); | ||
let msg = format!("cargo:rustc-cfg=odra_module=\"{}\"", module); | ||
println!("{}", msg); | ||
odra_build::build(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
//! Odra's contracts build script. | ||
use std::env; | ||
/// Uses the ENV variable `ODRA_MODULE` to set the `odra_module` cfg flag. | ||
pub fn main() { | ||
println!("cargo:rerun-if-env-changed=ODRA_MODULE"); | ||
let module = env::var("ODRA_MODULE").unwrap_or_else(|_| "".to_string()); | ||
let msg = format!("cargo:rustc-cfg=odra_module=\"{}\"", module); | ||
println!("{}", msg); | ||
odra_build::build(); | ||
} |
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,9 @@ | ||
[package] | ||
name = "odra-build" | ||
description = "Function used in build.rs files of Odra projects" | ||
edition = "2021" | ||
version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true |
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,33 @@ | ||
pub fn build() { | ||
flags().iter().for_each(|flag| println!("{}", flag)); | ||
} | ||
|
||
fn flags() -> Vec<String> { | ||
let mut flags = vec![]; | ||
flags.push("cargo:rerun-if-env-changed=ODRA_MODULE".to_string()); | ||
let module = std::env::var("ODRA_MODULE").unwrap_or_else(|_| "".to_string()); | ||
let msg = format!("cargo:rustc-cfg=odra_module=\"{}\"", module); | ||
flags.push(msg); | ||
flags | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
#[test] | ||
fn test_flags() { | ||
std::env::remove_var("ODRA_MODULE"); | ||
let flags = super::flags(); | ||
assert_eq!(flags.len(), 2); | ||
assert_eq!(flags[0], "cargo:rerun-if-env-changed=ODRA_MODULE"); | ||
assert_eq!(flags[1], "cargo:rustc-cfg=odra_module=\"\""); | ||
} | ||
|
||
#[test] | ||
fn test_flags_with_env() { | ||
std::env::set_var("ODRA_MODULE", "test"); | ||
let flags = super::flags(); | ||
assert_eq!(flags.len(), 2); | ||
assert_eq!(flags[0], "cargo:rerun-if-env-changed=ODRA_MODULE"); | ||
assert_eq!(flags[1], "cargo:rustc-cfg=odra_module=\"test\""); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
use std::env; | ||
//! Odra's contracts build script. | ||
/// Uses the ENV variable `ODRA_MODULE` to set the `odra_module` cfg flag. | ||
pub fn main() { | ||
println!("cargo:rerun-if-env-changed=ODRA_MODULE"); | ||
let module = env::var("ODRA_MODULE").unwrap_or_else(|_| "".to_string()); | ||
let msg = format!("cargo:rustc-cfg=odra_module=\"{}\"", module); | ||
println!("{}", msg); | ||
odra_build::build(); | ||
} |
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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
use std::env; | ||
//! Odra's contracts build script. | ||
/// Uses the ENV variable `ODRA_MODULE` to set the `odra_module` cfg flag. | ||
pub fn main() { | ||
println!("cargo:rerun-if-env-changed=ODRA_MODULE"); | ||
let module = env::var("ODRA_MODULE").unwrap_or_else(|_| "".to_string()); | ||
let msg = format!("cargo:rustc-cfg=odra_module=\"{}\"", module); | ||
println!("{}", msg); | ||
odra_build::build(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
use std::env; | ||
//! Odra's contracts build script. | ||
/// Uses the ENV variable `ODRA_MODULE` to set the `odra_module` cfg flag. | ||
pub fn main() { | ||
println!("cargo:rerun-if-env-changed=ODRA_MODULE"); | ||
let module = env::var("ODRA_MODULE").unwrap_or_else(|_| "".to_string()); | ||
let msg = format!("cargo:rustc-cfg=odra_module=\"{}\"", module); | ||
println!("{}", msg); | ||
odra_build::build(); | ||
} |
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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
use std::env; | ||
//! Odra's contracts build script. | ||
/// Uses the ENV variable `ODRA_MODULE` to set the `odra_module` cfg flag. | ||
pub fn main() { | ||
println!("cargo:rerun-if-env-changed=ODRA_MODULE"); | ||
let module = env::var("ODRA_MODULE").unwrap_or_else(|_| "".to_string()); | ||
let msg = format!("cargo:rustc-cfg=odra_module=\"{}\"", module); | ||
println!("{}", msg); | ||
odra_build::build(); | ||
} |