Skip to content

Commit

Permalink
fix(cli): isolate build.rs to not modify source directory
Browse files Browse the repository at this point in the history
fix "Source directory was modified by build.rs during cargo publish. Build scripts should not modify anything outside of OUT_DIR."
  • Loading branch information
SaadiSave committed Dec 14, 2023
1 parent fa152f4 commit c60341c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
.vscode
.idea
Cargo.lock

# build script artifacts
cli/LIBRARY_VERSION
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ version = "4"
features = ["derive"]

[build-dependencies]
cargo_toml = "0.16"
cargo_toml = "0.17"
6 changes: 5 additions & 1 deletion cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ fn main() {
.as_ref()
.unwrap();

std::fs::write(PathBuf::from_iter([ROOT, "LIBRARY_VERSION"]), version).unwrap();
std::fs::write(
PathBuf::from_iter([std::env::var("OUT_DIR").unwrap(), "LIBRARY_VERSION".into()]),
version,
)
.unwrap();
}
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::ffi::OsString;

#[derive(Parser)]
#[clap(name = "Cambridge Pseudoassembly Interpreter")]
#[clap(version = concat!("v", env!("CARGO_PKG_VERSION"), "\nCambridge Pseudoassembly v", include_str!("../LIBRARY_VERSION")))]
#[clap(version = concat!("v", env!("CARGO_PKG_VERSION"), "\nCambridge Pseudoassembly v", include_str!(concat!(env!("OUT_DIR"), "/LIBRARY_VERSION"))))]
#[clap(author = "Saadi Save <github.com/SaadiSave>")]
#[clap(about = "Run pseudoassembly from Cambridge International syllabus 9618 (2021)")]
enum Commands {
Expand Down

0 comments on commit c60341c

Please sign in to comment.