Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions anneal/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions anneal/v2/toolchain-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ tempfile = "3.27.0"
tar = "0.4"
zstd = "0.13"
digest = "0.10"
toml_const = "1.2"
6 changes: 3 additions & 3 deletions anneal/v2/toolchain-config/examples/static-toml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ toml = "0.8"

[package.metadata.toolchain.linux.x86_64]
checksum = "1111111111111111111111111111111111111111111111111111111111111111"
url = "http://example.com/archive.tar.zst"
url = "http://example.com/linux.x86_64.tar.zst"

[package.metadata.toolchain.macos.aarch64]
checksum = "2222222222222222222222222222222222222222222222222222222222222222"
url = "http://example.com/macos.tar.zst"
url = "http://example.com/macos.aarch64.tar.zst"

[package.metadata.toolchain.windows.x86_64]
checksum = "3333333333333333333333333333333333333333333333333333333333333333"
url = "http://example.com/windows.tar.zst"
url = "http://example.com/windows.x86_64.tar.zst"
27 changes: 14 additions & 13 deletions anneal/v2/toolchain-config/examples/static-toml/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::{Parser, Subcommand};
use std::process::Command;
use toolchain_config::{Config, LocalOverride, TarZstLibraryExtractor};
use toolchain_config::{Checksum, Config, LocalOverride, RemoteArchive, TarZstLibraryExtractor};

#[derive(Parser)]
#[command(name = "toolchain-config-example-static-toml")]
Expand All @@ -12,15 +12,12 @@ struct Cli {

#[derive(Subcommand)]
enum Commands {
Setup,
Install,
Hello,
}

fn decode_hex(s: &str) -> Vec<u8> {
(0..s.len())
.step_by(2)
.map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap())
.collect()
(0..s.len()).step_by(2).map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap()).collect()
}

fn get_root_dir() -> std::path::PathBuf {
Expand All @@ -34,13 +31,14 @@ fn main() {

let checksum_bytes = decode_hex(env!("TOOLCHAIN_CHECKSUM"));
let config = Config::<TarZstLibraryExtractor, sha2::Sha256>::new(
env!("TOOLCHAIN_URL"),
&checksum_bytes,
RemoteArchive::new(env!("TOOLCHAIN_URL")),
Checksum::new(&checksum_bytes),
);

match cli.command {
Commands::Setup => {
Commands::Install => {
// TODO: Probably use a flag, not an environment variable to activate override.
let archive_path;
let local_override = if std::env::var("__TOOLCHAIN_EXAMPLE_STATIC_TOML").is_ok() {
println!("Local testing override active. Assembling mock toolchain archive...");
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR")
Expand All @@ -52,14 +50,14 @@ fn main() {
.expect("Failed to execute build-toolchain.sh");
assert!(status.success(), "build-toolchain.sh script failed");

let archive_path = std::path::Path::new(&manifest_dir).join("toolchain.tar.zst");
Some(LocalOverride::<TarZstLibraryExtractor>::archive(archive_path))
archive_path = std::path::Path::new(&manifest_dir).join("toolchain.tar.zst");
Some(LocalOverride::<TarZstLibraryExtractor>::archive(&archive_path))
} else {
None
};

println!("Provisioning toolchain environment...");
toolchain_config::setup(&config, local_override, root_dir)
toolchain_config::install(&config, local_override, &root_dir)
.expect("Setup subcommand failed");
println!("Toolchain successfully set up.");
}
Expand All @@ -68,7 +66,10 @@ fn main() {
let hello_bin = toolchain_dir.join("bin").join("hello");

if !hello_bin.exists() {
eprintln!("Error: Toolchain executable missing at {:?}. Please run setup first.", hello_bin);
eprintln!(
"Error: Toolchain executable missing at {:?}. Please run install first.",
hello_bin
);
std::process::exit(1);
}

Expand Down
Binary file not shown.
Loading
Loading