Skip to content

Commit

Permalink
fixed some things and added/changed some documentation
Browse files Browse the repository at this point in the history
also added some config for vscode
  • Loading branch information
AverseABFun committed Dec 27, 2024
1 parent 4889912 commit 9326f9b
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"[toml]": {
"editor.formatOnSave": false
// ^^ because of src/template/rust-toolchain.toml and the toml formatter not playing well with the weird template things I added
},
"markdownlint.config": {
"MD041": false // disable it wanting the first line to be a top-level heading
}
}
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust-pkg-gen"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/AverseABFun/rust-pkg-gen"
Expand All @@ -10,12 +10,14 @@ authors = ["Arthur Beck <[email protected]>"]
[dependencies]
anyhow = "1.0.94"
cargo-local-registry = { version = "0.2.7", artifact = "bin" }
chrono = "0.4.39"
clap = { version = "4.5.23", features = ["derive"] }
clap_complete = "4.5.38"
clap_mangen = "0.2.24"
dialoguer = "0.11.0"
env_logger = "0.11.6"
filebuffer = "1.0.0"
flate2 = "1.0.35"
hex = "0.4.3"
log = { version = "0.4.22", features = ["std"] }
rand = "0.8.5"
Expand All @@ -24,12 +26,13 @@ reqwest = { version = "0.12.9", features = ["blocking"] }
rust-embed = "8.5.0"
serde = { version = "1.0.215", features = ["derive"] }
sha2 = "0.10.8"
tar = "0.4.43"
toml = "0.8.19"
url = "2.5.4"

[profile.release]
opt-level = "s"
debug-assertions = false # required to change the default behavior of --temp-dir
debug-assertions = false # required to change the default value of --temp-dir

[dev-dependencies]
proptest = "1.5.0"
55 changes: 44 additions & 11 deletions rust-config.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
[x64_package_linux_rust_pkg_gen]
# [x64_package_linux_rust_pkg_gen]
# toolchains = [
# { edition = "2021", channel = "nightly", components = [
# "rustfmt",
# "rustc",
# "cargo",
# ], crate-id = "2021-nightly-complete", platforms = [
# "x86_64-unknown-linux-gnu",
# "x86_64-pc-windows-gnu",
# ], targets = [
# "aarch64-apple-darwin",
# ], format-map = { "x86_64-pc-windows-gnu" = "x86_64-pc-windows-gnu", "x86_64-unknown-linux-gnu" = "x86_64-unknown-linux-gnu" } },
# ]

# [x64_package_linux_rust_pkg_gen.formats]
# x86_64-pc-windows-gnu = [
# "msi", # no suffix: assume "-if-available". "-if-available" will provide the requested format if it's available,
# # "-only" will error out if the requested format isn't available with the provided settings.
# # Excluding the suffix, should be one of "msi" "pkg" "gz" "xz".
# # msi and pkg should only be provided for windows and darwin, respectively

# # msi and pkg will only install rustc, cargo, rustdoc, and rust-std

# "gz",
# # elements past the first are only available if the suffix(or assumed suffix) is "-if-available". They should be one of "gz" "xz". Cannot include suffixes.
# ]

# x86_64-unknown-linux-gnu = ["gz-only"]

# [x64_package_linux_rust_pkg_gen.crates]
# "2021-nightly-complete" = { "syn" = "2.0.90" }

[x64_package_linux_rust_pkg_gen2]
toolchains = [
{ edition = "2021", channel = "nightly", components = [
"rustfmt",
{ edition = "2021", channel = "stable", components = [
"rust-docs",
"rustc",
"cargo",
], crate-id = "2021-nightly-complete", platforms = [
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-gnu",
], targets = [
"aarch64-apple-darwin",
], format-map = { "x86_64-pc-windows-gnu" = "x86_64-pc-windows-gnu", "x86_64-unknown-linux-gnu" = "x86_64-unknown-linux-gnu" } },
"x86_64-pc-windows-gnu",
], targets = [], format-map = { "x86_64-pc-windows-gnu" = "x86_64-pc-windows-gnu", "aarch64-apple-darwin" = "aarch64-apple-darwin" } },
]

[x64_package_linux_rust_pkg_gen.formats]
[x64_package_linux_rust_pkg_gen2.formats]
x86_64-pc-windows-gnu = [
"msi", # no suffix: assume "-if-available". "-if-available" will provide the requested format if it's available,
# "-only" will error out if the requested format isn't available with the provided settings.
Expand All @@ -25,7 +55,10 @@ x86_64-pc-windows-gnu = [
# elements past the first are only available if the suffix(or assumed suffix) is "-if-available". They should be one of "gz" "xz". Cannot include suffixes.
]

x86_64-unknown-linux-gnu = ["gz-only"]
aarch64-apple-darwin = [
"pkg",
"gz"
]

[x64_package_linux_rust_pkg_gen.crates]
"2021-nightly-complete" = { "syn" = "2.0.90" }
[x64_package_linux_rust_pkg_gen2.crates]
"2021-nightly-complete" = { "openssl" = "0.10.68" }
2 changes: 1 addition & 1 deletion src/copied.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub fn download_all(
components.swap_remove(idx.unwrap());
}
} else if ele.contains("apple") {
let artifacts = value["artifacts"]["installer-pkg"]["target"][ele]
let artifacts = value["artifacts"]["installer-pkg"]["target"][ele][0]
.as_table_mut()
.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions src/crates_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ registry = 'sparse+<https://index.crates.io/>'
replace-with = 'local-registry'

[source.local-registry]
local-registry = '{?TOOLCHAIN.CRATES_DIR}' # double-check this path is correct, especially if you are creating the package on a different machine than the machine you are creating the package for
local-registry = '' # add the path to the crates folder(the folder containing this file)
```

(psst- if you know how to install crate files to the registry manually, make an issue or PR on [rust-pkg-gen](https://github.com/AverseABFun/rust-pkg-gen)!)
(psst- if you know how to install crate files to the registry manually(smth like `cargo registry add /path/to/crate/file`), make an issue or PR on [rust-pkg-gen](https://github.com/AverseABFun/rust-pkg-gen)!)
26 changes: 25 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
//! The binary entrypoint to rust-pkg-gen. Currently contains most of the code,
//! but that will be changed eventually as a non-breaking change.
use chrono::prelude::*;
use clap::Parser;
use core::str;
use flate2::write::GzEncoder;
use flate2::Compression;
use log::*;
use rand::{Rng, SeedableRng};
use rust_pkg_gen::resources::{InstallAssets, TemplateAssets};
use std::{
fs::{self, write},
fs::{self, write, File},
path::{Path, PathBuf},
process::{self, Stdio},
};
Expand Down Expand Up @@ -160,6 +164,15 @@ fn main() {
for (item, cfg) in data {
let dir = dir.join(item);
for toolchain in &cfg.toolchains {
let chars: &[u8; 6] = &[
gen_char(),
gen_char(),
gen_char(),
gen_char(),
gen_char(),
gen_char(),
];
let dir = dir.join(str::from_utf8(chars).unwrap());
for ele in TemplateAssets::iter() {
let file = TemplateAssets::get(&ele).unwrap();

Expand Down Expand Up @@ -348,6 +361,17 @@ fn main() {
std::fs::write(path, file.data).unwrap();
}
}
let tar_gz = File::create(format!(
"rust-pkg-{}-{}-{}.tar.gz",
Local::now().date_naive().format("%Y-%m-%d"),
str::from_utf8(chars).unwrap(),
toolchain.channel
))
.unwrap();
let enc = GzEncoder::new(tar_gz, Compression::default());
let mut tar = tar::Builder::new(enc);
tar.append_dir_all("", dir).unwrap();
tar.finish().unwrap();
}
}
}

0 comments on commit 9326f9b

Please sign in to comment.