From b4a779f040f18257fde1c357626461ab187490db Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 22 Jan 2025 15:55:25 +0100 Subject: Remove dependency to the rand crate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- crates/xa65/Cargo.toml | 1 - crates/xa65/src/main.rs | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'crates/xa65') 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à "] [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; -- cgit v1.2.3