diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-22 15:55:25 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-22 15:55:25 +0100 |
| commit | b4a779f040f18257fde1c357626461ab187490db (patch) | |
| tree | ff4006cff95e0048a6c2816678a640ca0891fe60 /crates | |
| parent | e3e54cfee6ebc17281bbbf906ff9035f594313cd (diff) | |
| download | tools.nes-b4a779f040f18257fde1c357626461ab187490db.tar.gz tools.nes-b4a779f040f18257fde1c357626461ab187490db.zip | |
Remove dependency to the rand crate
This dependency was easily avoidable and it brought with it a lot of
inner dependencies of its own, most notably 'zerocopy-derive', which
forbid us to compile the affected programs purely statically.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/xa65/Cargo.toml | 1 | ||||
| -rw-r--r-- | crates/xa65/src/main.rs | 13 |
2 files changed, 10 insertions, 4 deletions
diff --git a/crates/xa65/Cargo.toml b/crates/xa65/Cargo.toml index a6696bd..1ecceb0 100644 --- a/crates/xa65/Cargo.toml +++ b/crates/xa65/Cargo.toml @@ -6,4 +6,3 @@ authors = ["Miquel Sabaté Solà <mikisabate@gmail.com>"] [dependencies] clap = { version = "^4", features = ["derive"] } -rand = "0.8.5" diff --git a/crates/xa65/src/main.rs b/crates/xa65/src/main.rs index 5d46ec1..8a31e7b 100644 --- a/crates/xa65/src/main.rs +++ b/crates/xa65/src/main.rs @@ -1,5 +1,4 @@ use clap::Parser as ClapParser; -use rand::distributions::{Alphanumeric, DistString}; use std::path::PathBuf; use std::process::Command; @@ -63,6 +62,15 @@ fn get_binaries() -> Result<(PathBuf, PathBuf), String> { Ok((nasm, cl65)) } +// Returns the path to the temporary directory that can be used for the run. +fn temporary_dir() -> PathBuf { + let tmp = &std::env::temp_dir(); + let paths = std::fs::read_dir(tmp).unwrap(); + let name = format!("xa65-{}", paths.count()); + + tmp.join(name) +} + fn main() { // Make sure that the binaries are there. let (nasm, cl65) = match get_binaries() { @@ -87,8 +95,7 @@ fn main() { // Generate a temporary directory in which both binary files will be placed // as an intermediate step. - let random_string = &Alphanumeric.sample_string(&mut rand::thread_rng(), 16); - let dir = std::env::temp_dir().join(random_string); + let dir = temporary_dir(); if let Err(e) = std::fs::create_dir(&dir) { die(e.to_string()); return; |
