Compare commits

...

8 commits
v5.3.5 ... main

8 changed files with 219 additions and 27 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
/target
/releases
.intentionally-empty-file.o

2
Cargo.lock generated
View file

@ -153,7 +153,7 @@ dependencies = [
[[package]]
name = "sidestepper"
version = "5.0.0"
version = "5.3.6"
dependencies = [
"ignore",
]

View file

@ -1,7 +1,13 @@
[package]
name = "sidestepper"
version = "5.0.0"
version = "5.3.6"
edition = "2021"
[dependencies]
ignore = "0.4.23"
[profile.release]
strip = true
lto = true
codegen-units = 1
opt-level = "z"

View file

@ -15,17 +15,13 @@ there was a better way to check a boolean result lol
## quickstart
**note:** there aren't any releases nor a nix flake yet!
### installing a binary
**note:** all non-windows builds are statically linked
- Windows
- Linux
- macOS universal
- macOS amd64
- macOS aarch64
- [Windows](https://forge.joshwel.co/mark/sidestepper/releases/download/latest/sidestepper-windows-x86_64.exe)
- [Linux (static binary, musl)](https://forge.joshwel.co/mark/sidestepper/releases/download/latest/sidestepper-linux-x86_64)
- [macOS universal](https://forge.joshwel.co/mark/sidestepper/releases/download/latest/sidestepper-macos-universal)
- [macOS x86_64](https://forge.joshwel.co/mark/sidestepper/releases/download/latest/sidestepper-macos-x86_64)
- [macOS aarch64](https://forge.joshwel.co/mark/sidestepper/releases/download/latest/sidestepper-macos-aarch64)
(also available in the 'releases' tab wherever this repository is situated in)
@ -34,7 +30,9 @@ there was a better way to check a boolean result lol
1. [get rust and cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html#install-rust-and-cargo)
2. run `cargo build release`
**nix users, rejoice:** run `nix run github:markjoshwel/sidestepper` or `nix run git+:https://forge.joshwel.co/mark/sidestepper`
**nix users, rejoice:** `nix run github:markjoshwel/sidestepper` or
`git+https://forge.joshwel.co/mark/sidestepper.git` (or nix build it, or add it
to your profile, or your system configuration, whatever)
### running it
@ -59,7 +57,9 @@ but if you want it to output external-tool-friendly output to stdout, pass in
## historical changes
- v5 (i3/a5) - 3rd implementation, rewritten in rust lol (no longer using iod-ttt, just piggybacking off [ignore](https://crates.io/crates/ignore)'s WalkBuilder)
- v5 (i3/a6) - fix for a silly bug (not properly checking if a .sotaignore entry already exists before writing it)
- v5 (i3/a5) - 3rd implementation, rewritten in rust lol (no longer using iod-ttt,
just piggybacking off [ignore](https://crates.io/crates/ignore)'s WalkBuilder)
- v4 (i2/a4) - optimised single iod-ttt
- v3 (i2/a3) - faster matching by remembering ignored directories (ignore on demand, 'iod')
- v2 (i2/a2) - 2nd implementation, corrected ignored directory matching (named 'trytrytry', 'ttt')

28
build.ps1 Normal file
View file

@ -0,0 +1,28 @@
# powershell script to build all the binaries!!1!
# requires: NixOS-WSL under the distro name "NixOS" / "nixos"
# fish out the version via latest git tag, and mkdir in releases/
$version = git describe --tags --abbrev=0
New-Item -ItemType Directory -Force -Path "releases/$version"
# build 1/3: windows
cargo build --release
cp target/release/sidestepper.exe releases/$version/sidestepper-windows-x86_64.exe
# build 2/3: static linux
wsl -d nixos -- nix develop --command rustup default stable
wsl -d nixos -- nix develop --command rustup target add x86_64-unknown-linux-musl
wsl -d nixos -- nix develop --command cargo build --release --target x86_64-unknown-linux-musl
cp target/x86_64-unknown-linux-musl/release/sidestepper releases/$version/sidestepper-linux-x86_64
# build 3/3: universal macOS
wsl -d nixos -- nix develop --command rustup target add x86_64-apple-darwin
wsl -d nixos -- nix develop --command rustup target add aarch64-apple-darwin
wsl -d nixos -- nix develop --command cargo zigbuild --release --target x86_64-apple-darwin
wsl -d nixos -- nix develop --command cargo zigbuild --release --target aarch64-apple-darwin
wsl -d nixos -- nix develop --command cargo zigbuild --release --target universal2-apple-darwin
cp target/universal2-apple-darwin/release/sidestepper releases/$version/sidestepper-macos-universal
cp target/x86_64-apple-darwin/release/sidestepper releases/$version/sidestepper-macos-x86_64
cp target/aarch64-apple-darwin/release/sidestepper releases/$version/sidestepper-macos-aaarch64
echo done!

94
flake.lock generated Normal file
View file

@ -0,0 +1,94 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1736429655,
"narHash": "sha256-BwMekRuVlSB9C0QgwKMICiJ5EVbLGjfe4qyueyNQyGI=",
"owner": "nix-community",
"repo": "naersk",
"rev": "0621e47bd95542b8e1ce2ee2d65d6a1f887a13ce",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1737370608,
"narHash": "sha256-hFA6SmioeqvGW/XvZa9bxniAeulksCOcj3kokdNT/YE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "300081d0cc72df578b02d914df941b8ec62240e6",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1737062831,
"narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

29
flake.nix Normal file
View file

@ -0,0 +1,29 @@
{
description = "run + build + develop flake for sidestepper";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
};
outputs = { self, nixpkgs, flake-utils, naersk }:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (nixpkgs) lib;
pkgs = (import nixpkgs) {
inherit system;
};
naersk' = pkgs.callPackage naersk {};
in
{
defaultPackage = naersk'.buildPackage {
src = ./.;
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ rustup rustc cargo cargo-zigbuild zig ];
};
}
);
}

View file

@ -24,12 +24,16 @@ use std::time::{Duration, SystemTime};
use std::{env, fs, io, path};
const SOTA_SIDESTEP_LARGE_FILE_SIZE: u64 = 100000000; // 100mb
const VERSION_OVERALL: u8 = 5;
const VERSION_IMPLEMENTATION: u8 = 3;
const VERSION_ALGORITHM: u8 = 6;
struct Behaviour {
repo_dir_path: PathBuf,
repo_sotaignore_path: PathBuf,
large_file_size: u64,
plumbing: bool,
version: bool,
}
fn cli_get_behaviour() -> Result<Behaviour, Box<dyn Error>> {
@ -49,6 +53,15 @@ fn cli_get_behaviour() -> Result<Behaviour, Box<dyn Error>> {
if arg == "--plumbing" {
plumbing = true;
}
if arg == "--version" {
return Ok(Behaviour {
repo_dir_path: PathBuf::new(),
repo_sotaignore_path: PathBuf::new(),
large_file_size,
plumbing,
version: true,
});
}
}
let current_dir = env::current_dir().map_err(|_| "could not get current working directory")?;
@ -60,6 +73,7 @@ fn cli_get_behaviour() -> Result<Behaviour, Box<dyn Error>> {
repo_sotaignore_path: PathBuf::from(&current_dir.join(".sotaignore")),
large_file_size,
plumbing,
version: false,
});
}
@ -84,6 +98,7 @@ fn cli_get_behaviour() -> Result<Behaviour, Box<dyn Error>> {
repo_sotaignore_path: PathBuf::from(&repo_dir_path.join(".sotaignore")),
large_file_size,
plumbing,
version: false,
})
}
@ -141,20 +156,26 @@ fn ss_write_sotaignore(behaviour: &Behaviour, large_files: &Vec<PathBuf>) -> io:
let mut new_sotaignore = old_sotaignore.clone();
for file in large_files {
if let Ok(file_relative) = file.strip_prefix(&behaviour.repo_dir_path) {
let fallback = &file.to_string_lossy();
let relative_path_str = file_relative
.to_str()
.unwrap_or(file.to_str().unwrap_or(fallback));
let posix_relative_path_str = {
// try:
// - valid unicode relative path (may fail)
// - valid unicode absolute path (may fail)
// - potentially invalid unicode absolute path (always returns)
let relative_path_str = file_relative
.to_str()
.unwrap_or(file.to_str().unwrap_or(&file.to_string_lossy()))
.to_string();
// posix-path-ify it for cross compatibility
if !old_sotaignore.contains(&relative_path_str.to_string()) {
new_sotaignore.push({
if path::MAIN_SEPARATOR_STR == "\\" {
relative_path_str.to_string().replace("\\", "/")
} else {
relative_path_str.to_string()
}
})
// posix-path-ify it for cross compatibility
if path::MAIN_SEPARATOR_STR == "\\" {
relative_path_str.to_string().replace("\\", "/")
} else {
relative_path_str.to_string()
}
};
if !old_sotaignore.contains(&posix_relative_path_str) {
new_sotaignore.push(posix_relative_path_str)
}
}
}
@ -197,7 +218,10 @@ fn format_elapsed_time(secs: f64) -> String {
}
fn main() {
eprintln!("sota staircase SideStepper v5 (i3/a5)");
eprintln!(
"sota staircase SideStepper v{} (i{}/a{})",
VERSION_OVERALL, VERSION_IMPLEMENTATION, VERSION_ALGORITHM
);
let behaviour = {
let behaviour = cli_get_behaviour();
// huh. pattern matching consumes the variable, so we ref (&) it. damn.
@ -208,6 +232,15 @@ fn main() {
behaviour.unwrap()
};
// check if we're just printing the version
if behaviour.version {
println!(
"v{}.{}.{}",
VERSION_OVERALL, VERSION_IMPLEMENTATION, VERSION_ALGORITHM
);
exit(0);
}
eprintln!(
" repo root : {}\n .sotaignore : {}\n",
behaviour.repo_dir_path.to_string_lossy(),