version tools (#5407)
* version tools * move bundling tools to `~/.dx/tools`
This commit is contained in:
1 parent
b2d01e6779
commit
7289256b0a
6 files changed
+27
-20
No files matched your search
@@ -69,9 +69,7 @@ impl<'a> BundleContext<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tools_dir = dirs::cache_dir()
|
let tools_dir = crate::Workspace::tools_dir();
|
||||||
.unwrap_or_else(|| PathBuf::from(".cache"))
|
|
||||||
.join("dioxus");
|
|
||||||
let _ = std::fs::create_dir_all(&tools_dir);
|
let _ = std::fs::create_dir_all(&tools_dir);
|
||||||
|
|
||||||
let arch = {
|
let arch = {
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ impl Esbuild {
|
|||||||
|
|
||||||
/// The path where we cache the esbuild binary.
|
/// The path where we cache the esbuild binary.
|
||||||
fn installed_bin_path() -> PathBuf {
|
fn installed_bin_path() -> PathBuf {
|
||||||
let dir = Workspace::dioxus_data_dir().join("esbuild");
|
let dir = Workspace::tools_dir().join(format!("esbuild-{ESBUILD_VERSION}"));
|
||||||
let name = if cfg!(windows) {
|
let name = if cfg!(windows) {
|
||||||
format!("esbuild-{ESBUILD_VERSION}.exe")
|
"esbuild.exe"
|
||||||
} else {
|
} else {
|
||||||
format!("esbuild-{ESBUILD_VERSION}")
|
"esbuild"
|
||||||
};
|
};
|
||||||
dir.join(name)
|
dir.join(name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,12 +167,12 @@ impl TailwindCli {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn installed_bin_name(&self) -> String {
|
fn installed_bin_name(&self) -> &'static str {
|
||||||
let mut name = format!("tailwindcss-{}", self.version);
|
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
name = format!("{name}.exe");
|
"tailwindcss.exe"
|
||||||
|
} else {
|
||||||
|
"tailwindcss"
|
||||||
}
|
}
|
||||||
name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn install_github(&self) -> anyhow::Result<()> {
|
async fn install_github(&self) -> anyhow::Result<()> {
|
||||||
@@ -232,8 +232,7 @@ impl TailwindCli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn install_dir(&self) -> Result<PathBuf> {
|
fn install_dir(&self) -> Result<PathBuf> {
|
||||||
let bindgen_dir = Workspace::dioxus_data_dir().join("tailwind/");
|
Ok(Workspace::tools_dir().join(format!("tailwindcss-{}", self.version)))
|
||||||
Ok(bindgen_dir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn git_install_url(&self) -> Option<String> {
|
fn git_install_url(&self) -> Option<String> {
|
||||||
|
|||||||
@@ -400,17 +400,17 @@ impl WasmBindgen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn install_dir(&self) -> anyhow::Result<PathBuf> {
|
fn install_dir(&self) -> anyhow::Result<PathBuf> {
|
||||||
let bindgen_dir = Workspace::dioxus_data_dir().join("wasm-bindgen/");
|
let dir = Workspace::tools_dir().join(format!("wasm-bindgen-{}", self.version));
|
||||||
std::fs::create_dir_all(&bindgen_dir)?;
|
std::fs::create_dir_all(&dir)?;
|
||||||
Ok(bindgen_dir)
|
Ok(dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn installed_bin_name(&self) -> String {
|
fn installed_bin_name(&self) -> &'static str {
|
||||||
let mut name = format!("wasm-bindgen-{}", self.version);
|
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
name = format!("{name}.exe");
|
"wasm-bindgen.exe"
|
||||||
|
} else {
|
||||||
|
"wasm-bindgen"
|
||||||
}
|
}
|
||||||
name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cargo_bin_name(&self) -> String {
|
fn cargo_bin_name(&self) -> String {
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ use std::path::{Path, PathBuf};
|
|||||||
use tar::Archive;
|
use tar::Archive;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
|
/// Pinned binaryen version (contains wasm-opt).
|
||||||
|
const BINARYEN_VERSION: &str = "127";
|
||||||
|
|
||||||
/// Write these wasm bytes with a particular set of optimizations
|
/// Write these wasm bytes with a particular set of optimizations
|
||||||
pub async fn write_wasm(bytes: &[u8], output_path: &Path, cfg: &WasmOptConfig) -> Result<()> {
|
pub async fn write_wasm(bytes: &[u8], output_path: &Path, cfg: &WasmOptConfig) -> Result<()> {
|
||||||
std::fs::write(output_path, bytes)?;
|
std::fs::write(output_path, bytes)?;
|
||||||
@@ -245,7 +248,7 @@ pub fn installed_location() -> Option<PathBuf> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn install_dir() -> PathBuf {
|
fn install_dir() -> PathBuf {
|
||||||
Workspace::dioxus_data_dir().join("binaryen")
|
Workspace::tools_dir().join(format!("binaryen-{BINARYEN_VERSION}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn installed_bin_name() -> &'static str {
|
fn installed_bin_name() -> &'static str {
|
||||||
|
|||||||
@@ -613,6 +613,13 @@ impl Workspace {
|
|||||||
.to_path_buf()
|
.to_path_buf()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The directory where managed tool binaries are installed.
|
||||||
|
///
|
||||||
|
/// Layout: `~/.dx/tools/{tool-name}-{version}/`
|
||||||
|
pub(crate) fn tools_dir() -> PathBuf {
|
||||||
|
Self::dioxus_data_dir().join("tools")
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn global_settings_file() -> PathBuf {
|
pub(crate) fn global_settings_file() -> PathBuf {
|
||||||
Self::dioxus_data_dir().join("settings.toml")
|
Self::dioxus_data_dir().join("settings.toml")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user